Can some one convert this game mod to ZP 5.0 plis

Eklenti sorunlarınız ve özel eklenti istekleriniz

Moderatör: Moderatörler

Cevapla
Prş Eyl 17, 2020 1:56 am

Konu Sahibi
Mesajlar: 2
Kayıt: Cum Ağu 21, 2020 2:06 am

Kod: Tümünü seç

     /*================================================================================

	-------------------------------------------
	-*- [ZPA] Game Mode: Cannibal || Update v.2.0 -*-
	-------------------------------------------
	Plugin by Re.Act!ve
	~~~~~~~~~~~~~~~
	- Description -
	~~~~~~~~~~~~~~~	
	[RU]
	Новый мод для ZPA 1.6 - Cannibal.

	~~~~~~~~~~~~~~~
	- Changelog -
	~~~~~~~~~~~~~~~
	v. 1.0 - Plugin created. Testing.

================================================================================*/

#include < amxmodx >
#include < cstrike >
#include < hamsandwich >
#include < fakemeta_util >
#include < zombie_plague_advance >

#define TASK_TEAM 1299
#define ID_TEAM (taskid - TASK_TEAM)
new const CS_TEAM_NAMES[][] = { "UNASSIGNED", "TERRORIST", "CT", "SPECTATOR" }
enum
{
	FM_CS_TEAM_UNASSIGNED = 0,
	FM_CS_TEAM_T,
	FM_CS_TEAM_CT,
	FM_CS_TEAM_SPECTATOR
}
const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
const OFFSET_CSTEAMS = 114

// Precache
new const g_cannibal[64] = 	"Cannibal"	// Model Name
const Float: g_can_speed = 200.0	// Speed
const Float: g_can_gravity = 1.0	// Gravity
new const p_GunMDL[64] = "models/p_m134.mdl"
new const g_chance = 40
new const g_access_flag[] = "a"
new const g_play_sounds[][] = {	"zombie_plague/nemesis1.wav" ,	"zombie_plague/survivor1.wav" }
new const g_sound_ambience[][] = { "zombie_plague/ambience.wav" }

// Duration in seconds of each sound
new const Float:g_sound_ambience_duration[] = { 58.0 , 56.0 }
const PEV_ADDITIONAL_AMMO = pev_iuser1;
new g_gameid, g_maxplayers, cvar_minplayers, cvar_dmg, bool:g_CanMode, cannibal_model[128], bool:i_cannibal[33], cvar_ammo, cvar_gun_type, cvar_hnum, cvar_health, cvar_clip
new g_msg_sync, g_msgTeamInfo, Float:g_teams_targettime;
//new g_ent_playermodel[33] // player model entity
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)

// Ambience sounds task
#define TASK_AMB 3256

public plugin_natives()
{
	register_native("zp_cannibal_mode", "native_cannibal_mode", 1)
	register_native("zp_get_user_cannibal", "native_get_user_cannibal", 1)
	//register_native("zp_make_user_cannibal", "native_make_user_cannibal", 1)
}

public plugin_init( )
{
	// Plugin registeration.
	register_plugin( "[ZPA] Cannibal Mode","2.0", "Re.Act!ve" )
	
	// Register some cvars
	// Edit these according to your liking
	cvar_minplayers = 		register_cvar("zp_cannibal_minplayers", "10")
	cvar_health = 			register_cvar("zp_cannibal_health", "0")	// < 0 - count humans * cvar_hnum>
	cvar_hnum = 			register_cvar("zp_cannibal_hnum", "90")
	//cvar_canclip = 	  	register_cvar("zp_cannibal_unlimclip", "0")
	cvar_dmg = 	  		register_cvar("zp_cannibal_damage", "1.0")	
	cvar_clip = 			register_cvar("zp_cannibal_gunclip", "100")
	cvar_ammo = 		register_cvar("zp_cannibal_gunammo", "400")	
	cvar_gun_type = 		register_cvar("zp_cannibal_guntype", "1")	// 0 - StandartGun m249, 1 - Force ZP Extra Item Gun
	register_cvar("zp_cannibal_extra", "Minigun")	// name extra
	register_clcmd("drop", "clcmd_drop")
	register_clcmd("ability1", "clcmd_drop")
	RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon")
	RegisterHam(Ham_Touch, "armoury_entity", "fw_TouchWeapon")
	RegisterHam(Ham_Touch, "weapon_shield", "fw_TouchWeapon")
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink") 
	g_maxplayers = get_maxplayers( )
	g_msgTeamInfo = get_user_msgid("TeamInfo")
	g_msg_sync = CreateHudSyncObj()
}

public plugin_precache( )
{
	// Read the access flag
	new access_flag = read_flags( g_access_flag )
	new i

	formatex(cannibal_model, charsmax(cannibal_model), "models/player/%s/%s.mdl", g_cannibal, g_cannibal)
	engfunc(EngFunc_PrecacheModel, cannibal_model)

	precache_model(p_GunMDL)

	for (i = 0; i < sizeof g_play_sounds; i++)
		precache_sound( g_play_sounds[i] )
	
	// Precache the ambience sounds
	new sound[100]
	for (i = 0; i < sizeof g_sound_ambience; i++)
	{
		if (equal(g_sound_ambience[i][strlen(g_sound_ambience[i])-4], ".mp3"))
		{
			formatex(sound, sizeof sound - 1, "sound/%s", g_sound_ambience[i])
			precache_generic( sound )
		}
		else
		{
			precache_sound( g_sound_ambience[i] )
		}
	}
	
	// Register our game mode
	g_gameid = zp_register_game_mode( "Cannibal Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if (victim != attacker && is_user_connected(attacker))
	{
		if(i_cannibal[attacker])
			SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg))
	}
}

public fw_PlayerPreThink(id)
{
	if(!is_user_alive(id) || !i_cannibal[id]) return;
	set_pev(id, pev_maxspeed, g_can_speed);
}

public fw_PlayerKilled(victim, attacker, shouldgib)
{
	if(i_cannibal[victim]) i_cannibal[victim] = false;
}

public zp_round_started_pre( game )
{
	// Check if it is our game mode
	if( game == g_gameid )
	{
		// Check for min players
		if( fnGetAlive() < get_pcvar_num(cvar_minplayers) )
			return ZP_PLUGIN_HANDLED

		// Start our new mode
		start_cannibal( )
	}
	// Make the compiler happy =)
	return PLUGIN_CONTINUE
}

public zp_round_started( game, id )
{
	// Check if it is our game mode
	if( game == g_gameid )
	{
		// Play the starting sound
		client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
		
		// Remove ambience task affects
		remove_task( TASK_AMB )
		
		// Set task to start ambience sounds
		#if defined AMBIENCE_SOUNDS
		set_task( 2.0, "start_ambience_sounds", TASK_AMB )
		#endif
	}
}

public zp_game_mode_selected( gameid, id )
{
	// Check if our game mode was called
	if( gameid == g_gameid )
		start_cannibal( )
	
	// Make the compiler happy again =)
	return PLUGIN_CONTINUE
}

// This function contains the whole code behind this game mode
start_cannibal( )
{
	new id, iPlayersnum;
	iPlayersnum = fnGetAlive();
	g_CanMode = true;
	id = fnGetRandomAlive(random_num(1, iPlayersnum));

	if(is_user_connected(id)) {
		new name[32];
		get_user_name(id, name, sizeof name - 1);
		zp_infect_user(id, 0, 1, 0);
		//zp_make_user_nemesis(id);
		i_cannibal[id] = true;
		set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
		ShowSyncHudMsg(0, g_msg_sync, "Осторожно, %s Каннибал!!!", name)
		do_screen_fade(id, 1.5, 1.5, 0, 0, 0, 255);
		fm_set_user_rendering(id, kRenderFxGlowShell,155,50,0,kRenderNormal,25) 
		zp_set_user_model(id, g_cannibal);

		drop_weapons(id, 1);
		drop_weapons(id, 2);
		if(get_pcvar_num(cvar_gun_type) != 0) 
		{
			fm_strip_user_weapons(id);
			new iWep2 = fm_give_item(id, "weapon_m249");
			if( iWep2 > 0 )
			{
				cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip))
				cs_set_user_bpammo (id, CSW_M249, get_pcvar_num(cvar_ammo))	
				//set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
			}
			ReplaceModels(id);
		}
		else 	{
			new extra_item[32]
			get_cvar_string("zp_cannibal_extra", extra_item, 31)
			zp_force_buy_extra_item(id, zp_get_extra_item_id(extra_item))
		}

		if(get_pcvar_num(cvar_health) == 0)
			fm_set_user_health(id, (iPlayersnum - 1) * get_pcvar_num(cvar_hnum))
		else
			fm_set_user_health(id, get_pcvar_num(cvar_health))

		fm_set_user_gravity(id, fm_get_user_gravity(id) * g_can_gravity);
		client_cmd(id, "spk items/gunpickup2")
	}
	// Remaining players should be humans (CTs)
	for (id = 1; id <= g_maxplayers; id++)
	{
		// Not alive
		if (!is_user_alive(id))
			continue;
		
		// First nemesis
		if (i_cannibal[id])
			continue;
		
		// Switch to CT
		if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
		{
			fm_cs_set_user_team(id, FM_CS_TEAM_CT)
			fm_user_team_update(id)
		}
	}
}

ReplaceModels(id) {
	//set_pev(id, pev_viewmodel2, v_GunMDL)
	set_pev(id, pev_weaponmodel2, p_GunMDL)
}

public clcmd_drop(id)
{
	if (i_cannibal[id])
		return PLUGIN_HANDLED
	
	return PLUGIN_CONTINUE;
}

// Ham Weapon Touch Forward
public fw_TouchWeapon(weapon, id)
{
	// Not a player
	if (!is_user_connected(id))
		return HAM_IGNORED;
	
	// Dont pickup weapons if zombie, survivor or sniper (+PODBot MM fix)
	if (i_cannibal[id])
		return HAM_SUPERCEDE;
	
	return HAM_IGNORED;
}

public start_ambience_sounds( )
{
	// Variables
	static amb_sound[64], sound, Float:duration
	
	// Select our ambience sound
	sound = random_num( 0, sizeof g_sound_ambience - 1 )
	copy( amb_sound, sizeof amb_sound - 1 , g_sound_ambience[ sound ] )
	duration = g_sound_ambience_duration[ sound ]
	
	// Check whether it's a wav or mp3, then play it on clients
	if ( equal( amb_sound[ strlen( amb_sound ) - 4 ], ".mp3" ) )
		client_cmd( 0, "mp3 play ^"sound/%s^"", amb_sound )
	else
		client_cmd( 0, "spk ^"%s^"", sound )
	
	// Start the ambience sounds
	set_task( duration, "start_ambience_sounds", TASK_AMB )
}

public client_disconnect(id) {
if(i_cannibal[id]) i_cannibal[id] = false;
}

public zp_round_ended( winteam )
{
	new id;
	for (id = 1; id <= g_maxplayers; id++)
	{
		if (is_user_connected(id) && i_cannibal[id])
		{
			fm_set_user_rendering(id, 0, 0, 0, 0, kRenderNormal, 25 ) 
			i_cannibal[id] = false;
		}
	}	
	g_CanMode = false;
	// Stop ambience sounds on round end
	remove_task( TASK_AMB )
}

// Code ZPA (by MeRcyLeZZ)
fnGetRandomAlive(n)
{
	static iAlive, id
	iAlive = 0
	
	for (id = 1; id <= g_maxplayers; id++)
	{
		if (is_user_alive(id))
			iAlive++
		
		if (iAlive == n)
			return id;
	}
	
	return -1;
}

// Code ZPA (by MeRcyLeZZ)
fnGetAlive()
{
	static iAlive, id
	iAlive = 0
	
	for (id = 1; id <= g_maxplayers; id++)
	{
		if (is_user_alive(id))
			iAlive++
	}
	
	return iAlive;
}

// Drop primary/secondary weapons
stock drop_weapons(id, dropwhat)
{
	// Get user weapons
	static weapons[32], num, i, weaponid
	num = 0 // reset passed weapons count (bugfix)
	get_user_weapons(id, weapons, num)
	
	// Loop through them and drop primaries or secondaries
	for (i = 0; i < num; i++)
	{
		// Prevent re-indexing the array
		weaponid = weapons[i]
		
		if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
		{
			// Get weapon entity
			static wname[32], weapon_ent
			get_weaponname(weaponid, wname, charsmax(wname))
			weapon_ent = fm_find_ent_by_owner(-1, wname, id)
			
			// Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO
			set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid))
			
			// Player drops the weapon and looses his bpammo
			engclient_cmd(id, "drop", wname)
			cs_set_user_bpammo(id, weaponid, 0)
		}
	}
}

/*stock fm_cs_set_user_model_index(id, value)
{
	set_pdata_int(id, OFFSET_MODELINDEX, value, OFFSET_LINUX)
}

stock fm_set_playermodel_ent(id)
{
	// Make original player entity invisible without hiding shadows or firing effects
	fm_set_rendering(id, kRenderFxNone, 255, 255, 255, kRenderTransTexture, 1)
	
	// Format model string
	static model[100]
	formatex(model, charsmax(model), "models/player/%s/%s.mdl", g_cannibal, g_cannibal)
	
	// Set model on entity or make a new one if unexistant
	if (!pev_valid(g_ent_playermodel[id]))
	{
		g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
		if (!pev_valid(g_ent_playermodel[id])) return;
		
		set_pev(g_ent_playermodel[id], pev_classname, MODEL_ENT_CLASSNAME)
		set_pev(g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW)
		set_pev(g_ent_playermodel[id], pev_aiment, id)
		set_pev(g_ent_playermodel[id], pev_owner, id)
	}
	
	engfunc(EngFunc_SetModel, g_ent_playermodel[id], model)
}*/

stock do_screen_fade(       id, Float:fadeTime, Float:holdTime, red, green, blue, alpha, type = 0x0000       )
{
   static msgScreenFade;
   if (      !msgScreenFade    ) { msgScreenFade = get_user_msgid(    "ScreenFade"           ); }
   new fade, hold;
   fade = clamp(    floatround(     fadeTime * float(1<<12)), 0, 0xFFFF    );
   hold = clamp(     floatround(         holdTime * float(1<<12)), 0, 0xFFFF      );
   message_begin(    MSG_ONE_UNRELIABLE, msgScreenFade, _, id          );
   write_short(          fade    );
   write_short(    hold    );
   write_short(    type   );
   write_byte(      red    );
   write_byte(  green    );
   write_byte(    blue    );
   write_byte(     alpha    );
   message_end(    );
}

// Set a Player's Team
stock fm_cs_set_user_team(id, team)
{
	set_pdata_int(id, OFFSET_CSTEAMS, team, OFFSET_LINUX)
}

// Get User Team
stock fm_cs_get_user_team(id)
{
	return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
}

// Update Player's Team on all clients (adding needed delays)
stock fm_user_team_update(id)
{
	static Float:current_time
	current_time = get_gametime()
	
	if (current_time - g_teams_targettime >= 0.1)
	{
		set_task(0.1, "fm_cs_set_user_team_msg", id+TASK_TEAM)
		g_teams_targettime = current_time + 0.1
	}
	else
	{
		set_task((g_teams_targettime + 0.1) - current_time, "fm_cs_set_user_team_msg", id+TASK_TEAM)
		g_teams_targettime = g_teams_targettime + 0.1
	}
}

// Send User Team Message
public fm_cs_set_user_team_msg(taskid)
{
	// Tell everyone my new team
	emessage_begin(MSG_ALL, g_msgTeamInfo)
	ewrite_byte(ID_TEAM) // player
	ewrite_string(CS_TEAM_NAMES[fm_cs_get_user_team(ID_TEAM)]) // team
	emessage_end()
}

public native_cannibal_mode() {
	new i;
	if(g_CanMode) i = 1;
	else i = 0;
	return i;
}

/*public native_make_user_cannibal() {

}*/

public native_get_user_cannibal(id)
{
	new bool:gPl
	if(i_cannibal[id]) gPl=true;
	else gPl=false;

	return gPl;
} 

Link:
Linklerini gizle
Linki Kopyala

Prş Eyl 17, 2020 8:30 am
Kullanıcı avatarı

Mesajlar: 1844
Kayıt: Çrş Ağu 23, 2017 9:17 pm
İletişim:
I don't know if it works or not but why not trying?

hazir-mod-paylasimi/topic-t34604.html
Dost dediğin kalbini soymuş.


Bâkî kalan bu kubbede bir hoş sadâ imiş

Link:
Linklerini gizle
Linki Kopyala

Prş Eyl 17, 2020 8:16 pm

Konu Sahibi
Mesajlar: 2
Kayıt: Cum Ağu 21, 2020 2:06 am
Yes i have zp 5.0.8 but I dont have game mod cannibal spchel for zp 5.0.8 that what I need

Link:
Linklerini gizle
Linki Kopyala

Cevapla