Simple coding bugs

Coding Help/Re-API Supported
Post Reply
User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 633
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

Simple coding bugs

#1

Post by Spir0x » 3 Months Ago

hi guys i'm facing some problems on server and i need to fix them as soon as possible, first is water gun can't reload it when ammo is done.
Water Gun:

Code: Select all

#include <zombie_escape>

#include <engine>

#include <fun>

#include <xs>

#include <cstrike>



#define ENG_NULLENT		-1

#define EV_INT_WEAPONKEY	EV_INT_impulse

#define watergun_WEAPONKEY 893

#define MAX_PLAYERS  			  32

#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)



#define TASK_FBURN				100

#define ID_FBURN					( taskid - TASK_FBURN )



new bool:g_fRoundEnd



#define FIRE_DURATION		6

#define FIRE_DAMAGE		25



const USE_STOPPED = 0

const OFFSET_ACTIVE_ITEM = 373

const OFFSET_WEAPONOWNER = 41

const OFFSET_LINUX = 5

const OFFSET_LINUX_WEAPONS = 4



#define WEAP_LINUX_XTRA_OFF		4

#define m_fKnown					44

#define m_flNextPrimaryAttack 		46

#define m_flTimeWeaponIdle			48

#define m_iClip					50

#define m_fInReload				54

#define PLAYER_LINUX_XTRA_OFF	5

#define m_flNextAttack				83



#define watergun_RELOAD_TIME 	3.5

#define watergun_RELOAD		1

#define watergun_DRAW		2

#define watergun_SHOOT1		3

#define watergun_SHOOT2		4



new g_flameSpr

new g_smokeSpr



new g_burning_duration[33]



#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)



new const Fire_Sounds[][] = { "weapons/waterp.wav" }



new watergun_V_MODEL[64] = "models/Premuim_ZE/v_water_gun.mdl"

new watergun_P_MODEL[64] = "models/Premuim_ZE/p_water_gun.mdl"

new watergun_W_MODEL[64] = "models/Premuim_ZE/w_water_gun.mdl"



//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }



new cvar_dmg_watergun, cvar_recoil_watergun, g_itemid_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo

new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack

new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]

new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]

new watergun_sprite



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)

new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",

			"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",

			"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",

			"weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",

			"weapon_ak47", "weapon_knife", "weapon_p90" }



public plugin_init()

{

	register_plugin("[ZE] Extra: Water Gun", "1.0", "Sm!LeY")

	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")

	register_event("CurWeapon","CurrentWeapon","be","1=1")

	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")

	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)

	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)

	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)

	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)

	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)

	if (WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES[i], "fw_Item_Deploy_Post", 1)

	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")

	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)

	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")

	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")

	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)

	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")

	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );

	register_forward(FM_SetModel, "fw_SetModel")

	register_event( "DeathMsg", "EV_DeathMsg", "a" );

	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)

	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")



	cvar_dmg_watergun = register_cvar("ze_watergun_dmg", "1.5")

	cvar_recoil_watergun = register_cvar("ze_watergun_recoil", "0.75")

	cvar_clip_watergun = register_cvar("ze_watergun_clip", "30")

	cvar_spd_watergun = register_cvar("ze_watergun_spd", "0.75")

	cvar_watergun_ammo = register_cvar("ze_watergun_ammo", "200")

	

	g_itemid_watergun = ze_register_item("Water Gun", 65, 0)

	g_MaxPlayers = get_member_game(m_nMaxPlayers)

}



public plugin_precache()

{

	precache_model(watergun_V_MODEL)

	precache_model(watergun_P_MODEL)

	precache_model(watergun_W_MODEL)

	for(new i = 0; i < sizeof Fire_Sounds; i++)

	precache_sound(Fire_Sounds[i])	

	m_iBlood[0] = precache_model("sprites/blood.spr")

	m_iBlood[1] = precache_model("sprites/bloodspray.spr")

	watergun_sprite = precache_model("sprites/watergun.spr")



	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)

}



public ze_user_humanized(id)

{

	g_has_watergun[id] = false

}



public fwPrecacheEvent_Post(type, const name[])

{

	if (equal("events/mp5n.sc", name))

	{

		g_orig_event_watergun = get_orig_retval()

		return FMRES_HANDLED

	}

	return FMRES_IGNORED

}



public client_connect(id)

{

	g_has_watergun[id] = false

}



public client_disconnected(id)

{

	g_has_watergun[id] = false



	remove_task(id + TASK_FBURN )

}



public ze_user_infected(id)

{

	if (ze_is_user_zombie(id))

	{

		g_has_watergun[id] = false



		remove_task(id + TASK_FBURN)

	}

}



public fw_SetModel(entity, model[])

{

	if(!is_valid_ent(entity))

		return FMRES_IGNORED

	

	static szClassName[33]

	entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))

		

	if(!equal(szClassName, "weaponbox"))

		return FMRES_IGNORED

	

	static iOwner

	

	iOwner = entity_get_edict(entity, EV_ENT_owner)

	

	if(equal(model, "models/w_mp5.mdl"))

	{

		static iStoredAugID

		

		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)

	

		if(!is_valid_ent(iStoredAugID))

			return FMRES_IGNORED

	

		if(g_has_watergun[iOwner])

		{

			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)

			

			g_has_watergun[iOwner] = false

			

			entity_set_model(entity, watergun_W_MODEL)

			

			return FMRES_SUPERCEDE

		}

	}

	return FMRES_IGNORED

}



public EV_DeathMsg( )

{

	static pevVictim;

	pevVictim = read_data( 2 )

	

	if( !is_user_connected( pevVictim ) )

		return

		

	remove_task( pevVictim + TASK_FBURN )

}



public PlayerSpawn_Post( Player )

{

	if( !is_user_alive( Player ) )

		return;

		

	g_burning_duration[ Player ] = 0

}



public give_watergun(id)

{

	drop_weapons(id, 1)

	new iWep2 = give_item(id,"weapon_mp5navy")

	if( iWep2 > 0 )

	{

		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))

		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	

		UTIL_PlayWeaponAnimation(id, watergun_DRAW)

		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)

	}

	g_has_watergun[id] = true

}



public ze_select_item_pre(id, itemid)

{

	if (itemid != g_itemid_watergun)

		return ZE_ITEM_AVAILABLE



	if (ze_is_user_zombie(id))

		return ZE_ITEM_DONT_SHOW



	return ZE_ITEM_AVAILABLE

}



public ze_select_item_post(id, itemid)

{

	if(itemid != g_itemid_watergun)

		return



	give_watergun(id)

}



public fw_watergun_AddToPlayer(watergun, id)

{

	if(!is_valid_ent(watergun) || !is_user_connected(id))

		return HAM_IGNORED

	

	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)

	{

		g_has_watergun[id] = true

		

		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)

		

		return HAM_HANDLED

	}

	return HAM_IGNORED

}



public fw_UseStationary_Post(entity, caller, activator, use_type)

{

	if (use_type == USE_STOPPED && is_user_connected(caller))

		replace_weapon_models(caller, get_user_weapon(caller))

}



public fw_Item_Deploy_Post(weapon_ent)

{

	static owner

	owner = fm_cs_get_weapon_ent_owner(weapon_ent)

	

	static weaponid

	weaponid = cs_get_weapon_id(weapon_ent)

	

	replace_weapon_models(owner, weaponid)

}



public CurrentWeapon(id)

{

     replace_weapon_models(id, read_data(2))



     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])

          return

     

     static Float:iSpeed

     if(g_has_watergun[id])

          iSpeed = get_pcvar_float(cvar_spd_watergun)

     

     static weapon[32],Ent

     get_weaponname(read_data(2),weapon,31)

     Ent = find_ent_by_owner(-1,weapon,id)

     if(Ent)

     {

          static Float:Delay

          Delay = get_pdata_float( Ent, 46, 4) * iSpeed

          if (Delay > 0.0)

          {

               set_pdata_float(Ent, 46, Delay, 4)

          }

     }

}



replace_weapon_models(id, weaponid)

{

	switch (weaponid)

	{

		case CSW_MP5NAVY:

		{

			if (ze_is_user_zombie(id))

				return

			

			if(g_has_watergun[id])

			{

				set_pev(id, pev_viewmodel2, watergun_V_MODEL)

				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)

				if(oldweap[id] != CSW_MP5NAVY) 

				{

					UTIL_PlayWeaponAnimation(id, watergun_DRAW)

					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)

				}

			}

		}

	}

	oldweap[id] = weaponid

}



public fw_UpdateClientData_Post(Player, SendWeapons, CD_Handle)

{

	if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_MP5NAVY || !g_has_watergun[Player]))

		return FMRES_IGNORED

	

	set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)

	return FMRES_HANDLED

}



public fw_watergun_PrimaryAttack(Weapon)

{

	new Player = get_pdata_cbase(Weapon, 41, 4)

	

	if (!g_has_watergun[Player])

		return

	

	g_IsInPrimaryAttack = 1

	pev(Player,pev_punchangle,cl_pushangle[Player])

	

	g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)

}



public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)

{

	if ((eventid != g_orig_event_watergun) || !g_IsInPrimaryAttack)

		return FMRES_IGNORED

	if (!(1 <= invoker <= g_MaxPlayers))

    return FMRES_IGNORED



	playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)

	return FMRES_SUPERCEDE

}



public fw_watergun_PrimaryAttack_Post(Weapon)

{

	g_IsInPrimaryAttack = 0

	new Player = get_pdata_cbase(Weapon, 41, 4)

	

	new szClip, szAmmo

	get_user_weapon(Player, szClip, szAmmo)

	

	if(!is_user_alive(Player))

		return



	if(g_has_watergun[Player])

	{

		if (!g_clip_ammo[Player])

			return



		new Float:push[3]

		pev(Player,pev_punchangle,push)

		xs_vec_sub(push,cl_pushangle[Player],push)

		

		xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_watergun),push)

		xs_vec_add(push,cl_pushangle[Player],push)

		set_pev(Player,pev_punchangle,push)

		

		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))



		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]

		pev(Player, pev_v_angle, plrViewAngles)



		static Float:VecSrc[3], Float:VecDst[3]

	

		//VecSrc = pev->origin + pev->view_ofs

		pev(Player, pev_origin, PlrOrigin)

		pev(Player, pev_view_ofs, VecSrc)

		xs_vec_add(VecSrc, PlrOrigin, VecSrc)



		//VecDst = VecDir * 8192.0

		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);

		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);

		xs_vec_add(VecDst, VecSrc, VecDst);

	

		new hTrace = create_tr2()

		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)

		get_tr2(hTrace, TR_vecEndPos, VecEnd);



		create_tracer_water(Player, VecSrc, VecEnd)	

	}

}



public fw_TakeDamage(victim, inflictor, attacker, Float:damage)

{

	if(!is_user_alive(attacker))

		return;



	if (victim != attacker && is_user_connected(attacker))

	{

		if(get_user_weapon(attacker) == CSW_MP5NAVY)

		{

			if(g_has_watergun[attacker])

			{

				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))



				if( !task_exists( victim + TASK_FBURN ) )

				{

					g_burning_duration[ victim ] += FIRE_DURATION * 5

				

					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )

				}

			}

		}

	}

}



public message_DeathMsg(msg_id, msg_dest, id)

{

	static szTruncatedWeapon[33], iAttacker, iVictim

	

	get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))

	

	iAttacker = get_msg_arg_int(1)

	iVictim = get_msg_arg_int(2)

	

	if(!is_user_connected(iAttacker) || iAttacker == iVictim)

		return PLUGIN_CONTINUE

	

	if(equal(szTruncatedWeapon, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)

	{

		if(g_has_watergun[iAttacker])

			set_msg_arg_string(4, "mp5navy")

	}

	return PLUGIN_CONTINUE

}



stock fm_cs_get_current_weapon_ent(id)

{

	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)

}



stock fm_cs_get_weapon_ent_owner(ent)

{

	return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)

}



stock UTIL_PlayWeaponAnimation(const Player, const Sequence)

{

	set_pev(Player, pev_weaponanim, Sequence)

	

	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)

	write_byte(Sequence)

	write_byte(pev(Player, pev_body))

	message_end()

}



public watergun_ItemPostFrame(weapon_entity) 

{

     new id = pev(weapon_entity, pev_owner)

     if (!is_user_connected(id))

          return HAM_IGNORED



     if (!g_has_watergun[id])

          return HAM_IGNORED



     static iClipExtra

     

     iClipExtra = get_pcvar_num(cvar_clip_watergun)

     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)



     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);

     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)



     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 



     if( fInReload && flNextAttack <= 0.0 )

     {

	     new j = min(iClipExtra - iClip, iBpAmmo)

	

	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)

	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)

		

	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)

	     fInReload = 0

     }

     return HAM_IGNORED

}



public watergun_Reload(weapon_entity) 

{

     new id = pev(weapon_entity, pev_owner)

     if (!is_user_connected(id))

          return HAM_IGNORED



     if (!g_has_watergun[id])

          return HAM_IGNORED



     static iClipExtra



     if(g_has_watergun[id])

          iClipExtra = get_pcvar_num(cvar_clip_watergun)



     g_watergun_TmpClip[id] = -1



     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)

     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)



     if (iBpAmmo <= 0)

          return HAM_SUPERCEDE



     if (iClip >= iClipExtra)

          return HAM_SUPERCEDE



     g_watergun_TmpClip[id] = iClip



     return HAM_IGNORED

}



public watergun_Reload_Post(weapon_entity) 

{

	new id = pev(weapon_entity, pev_owner)

	if (!is_user_connected(id))

		return HAM_IGNORED



	if (!g_has_watergun[id])

		return HAM_IGNORED



	if (g_watergun_TmpClip[id] == -1)

		return HAM_IGNORED



	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)



	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)



	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)



	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)



	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)



	return HAM_IGNORED

}



stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])

{

	static iVec1[3]

	FVecIVec(fVec1, iVec1)



	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]

	pev(id, pev_v_angle, angles)

	engfunc(EngFunc_MakeVectors, angles)

	global_get(glb_v_forward, v_forward)

	global_get(glb_v_right, v_right)

	global_get(glb_v_up, v_up)



	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs

	pev(id, pev_origin, player_origin)

	pev(id, pev_view_ofs, player_view_offset)

	xs_vec_add(player_origin, player_view_offset, gun_position)



	xs_vec_mul_scalar(v_forward, 24.0, v_forward)

	xs_vec_mul_scalar(v_right, 3.0, v_right)



	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)

		xs_vec_mul_scalar(v_up, 6.0, v_up)

	else

		xs_vec_mul_scalar(v_up, -2.0, v_up)



	xs_vec_add(gun_position, v_forward, origin)

	xs_vec_add(origin, v_right, origin)

	xs_vec_add(origin, v_up, origin)



	vSrc[0] = origin[0]

	vSrc[1] = origin[1]

	vSrc[2] = origin[2]



	new Float:dist = get_distance_f(vSrc, fVec2)

	new CountDrops = floatround(dist / 50.0)

	

	if (CountDrops > 20)

		CountDrops = 20

	

	if (CountDrops < 2)

		CountDrops = 2



	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)

	write_byte(TE_SPRITETRAIL)

	engfunc(EngFunc_WriteCoord, vSrc[0])

	engfunc(EngFunc_WriteCoord, vSrc[1])

	engfunc(EngFunc_WriteCoord, vSrc[2])

	engfunc(EngFunc_WriteCoord, fVec2[0])

	engfunc(EngFunc_WriteCoord, fVec2[1])

	engfunc(EngFunc_WriteCoord, fVec2[2])

	write_short(watergun_sprite)

	write_byte(CountDrops)

	write_byte(0)

	write_byte(1)

	write_byte(60)

	write_byte(10)

	message_end()



	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)

	write_byte(TE_BEAMPOINTS)

	engfunc(EngFunc_WriteCoord, fVec2[0])

	engfunc(EngFunc_WriteCoord, fVec2[1])

	engfunc(EngFunc_WriteCoord, fVec2[2])

	engfunc(EngFunc_WriteCoord, vSrc[0])

	engfunc(EngFunc_WriteCoord, vSrc[1])

	engfunc(EngFunc_WriteCoord, vSrc[2])

	write_short(watergun_sprite)

	write_byte(6)

	write_byte(200) 

	write_byte(1)

	write_byte(100)

	write_byte(0)

	write_byte(64); write_byte(64); write_byte(192);

	write_byte(192)

	write_byte(250) 

	message_end()

}



stock drop_weapons(id, dropwhat)

{

     static weapons[32], num, i, weaponid

     num = 0

     get_user_weapons(id, weapons, num)

     

     for (i = 0; i < num; i++)

     {

          weaponid = weapons[i]

          

          if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))

          {

               static wname[32]

               get_weaponname(weaponid, wname, sizeof wname - 1)

               engclient_cmd(id, "drop", wname)

          }

     }

}



public CTask__BurningFlame( taskid )

{

	// Get player origin and flags

	static origin[3], flags

	get_user_origin(ID_FBURN, origin)

	flags = pev(ID_FBURN, pev_flags)

	

	// Madness mode - in water - burning stopped

	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))

	{

		// Smoke sprite

		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)

		write_byte(TE_SMOKE) // TE id

		write_coord(origin[0]) // x

		write_coord(origin[1]) // y

		write_coord(origin[2]-50) // z

		write_short(g_smokeSpr) // sprite

		write_byte(random_num(15, 20)) // scale

		write_byte(random_num(10, 20)) // framerate

		message_end()

		

		// Task not needed anymore

		remove_task(taskid)

		return

	}

	

	// Get player's health

	static health

	health = pev(ID_FBURN, pev_health)

	

	// Take damage from the fire

	if (health - FIRE_DAMAGE > 0)

		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)

	

	// Flame sprite

	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)

	write_byte(TE_SPRITE) // TE id

	write_coord(origin[0]+random_num(-5, 5)) // x

	write_coord(origin[1]+random_num(-5, 5)) // y

	write_coord(origin[2]+random_num(-10, 10)) // z

	write_short(g_flameSpr) // sprite

	write_byte(random_num(5, 10)) // scale

	write_byte(200) // brightness

	message_end()



	

	g_burning_duration[ID_FBURN]--

}



stock fm_set_user_health( index, health ) 

	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE

*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }

*/

and i want to make max levels on 50 so when players level up to 50 none can be 51 or 52 just xp stop at level 50.
Levels System:

Code: Select all

#include <zombie_escape>

 

// Defines

#define MAX_LEVEL 50

#define MAX_XP 500000

#define TASK_DOUBLE 1133

#define REPEAT_TIME 60.0

#define TASK_SHOWHUD 2020

#define ID_SHOWHUD (taskid - TASK_SHOWHUD)

#define LEVELUP "Premuim_ZE/ze_promoted.mp3"

 

enum

{

    Host = 0,

    User,

    Pass,

    DB

}

 

// Constants

new const g_szLevelsVault[] = "Levels"

new const g_szRanksVault[] = "Ranks"

new const g_szLogFile[] = "Levels.log" // MySQL Errors log file

new const g_szTable[] = "CREATE TABLE IF NOT EXISTS `Players_Information` ( `id` int(12) NOT NULL AUTO_INCREMENT, `SteamID` varchar(36) NOT NULL,`Level` int(20) NOT NULL,`XP` int(20) NOT NULL,`Max_XP` int(20) NOT NULL, PRIMARY KEY (`id`) );"

 

// Messages

const Float:HUD_SPECT_X = -1.0

const Float:HUD_SPECT_Y = 0.70

const Float:HUD_STATS_X = 0.01

const Float:HUD_STATS_Y = 0.15

 

const HUD_STATS_ZOMBIE_R = 0

const HUD_STATS_ZOMBIE_G = 230

const HUD_STATS_ZOMBIE_B = 255

 

const HUD_STATS_HUMAN_R = 0

const HUD_STATS_HUMAN_G = 230

const HUD_STATS_HUMAN_B = 255

 

const HUD_STATS_SPEC_R = 100

const HUD_STATS_SPEC_G = 100

const HUD_STATS_SPEC_B = 100

 

// Variables

new g_iLevel[33],

    g_iXP[33],

    g_iMaxXP[33],

    Float:g_fDamage[33],

    g_MsgSync,

    g_iLevelsVaultHandle,

    g_iRanksVaultHandle,

    Handle:g_hTuple,

    Fw_LevelUP,

    ForwardReturn,

    bool:g_bIsDoubleHours

 

// Cvars

new g_pCvarZombieInfect,

    g_pCvarEscapeSuccess,

    g_pCvarEnableDamage,

    g_pCvarRequiredDamage,

    g_pCvarDamageAward,

    g_pCvarStartXP,

    g_pCvarMaxLevelsIncrement,

    g_pCvarMaxXPFirstLevel,

    g_pCvarPercentageStyle,

    g_pCvarStartFromZero,

    g_pCvarAddCommas,

    g_pCvarLevelEffects,

    g_pCvarSaveType,

    g_pCvarDBInfo[4],

    g_pCvarDoubleXP

 

public plugin_natives()

{

    register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)

    register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)

    register_native("ze_get_user_level", "native_ze_get_user_level", 1)

    register_native("ze_set_user_level", "native_ze_set_user_level", 1)

    register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)

    register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)

}

 

public plugin_precache()

{

    precache_sound(LEVELUP)

}

 

public plugin_init()

{

    register_plugin("[ZE] Level-XP System", "1.9", "Raheem/JaCk")

   

    // Hook Chains

    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)

 

    Fw_LevelUP = CreateMultiForward("ze_on_levelup", ET_IGNORE, FP_CELL)

   

    // Cvars

    g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "3")

    g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "5")

    g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "1")

    g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "50.0")

    g_pCvarDamageAward = register_cvar("ze_dmg_award", "3")

    g_pCvarStartXP = register_cvar("ze_start_xp", "50")

    g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "2.0")

    g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "100")

    g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "1")

    g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "0")

    g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")

    g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "1")

    g_pCvarSaveType = register_cvar("ze_levels_save_type", "0")

    g_pCvarDBInfo[Host] = register_cvar("ze_levels_host", "127.0.0.1")

    g_pCvarDBInfo[User] = register_cvar("ze_levels_user", "root")

    g_pCvarDBInfo[Pass] = register_cvar("ze_levels_pass", "password")

    g_pCvarDBInfo[DB] = register_cvar("ze_levels_dbname", "levels_db")

    g_pCvarDoubleXP = register_cvar("ze_double_xp", "9-12")

   

    // Messages

    g_MsgSync = CreateHudSyncObj()

 

    if (get_pcvar_num(g_pCvarSaveType))

    {

        set_task(0.1, "Delay_MySQL_Init")

    }

}

 

public plugin_end()

{

    if (get_pcvar_num(g_pCvarSaveType))

    {

        if (g_hTuple != Empty_Handle)

        {

            SQL_FreeHandle(g_hTuple)

        }

    }

}

 

public Delay_MySQL_Init()

{

    MySQL_Init()

}

 

public MySQL_Init()

{

    if (!get_pcvar_num(g_pCvarSaveType))

        return

   

    new szHost[64], szUser[32], szPass[32], szDB[128]

   

    get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))

    get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))

    get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))

    get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))

   

    g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)

   

    // Let's ensure that the g_hTuple will be valid, we will access the database to make sure

    new iErrorCode, szError[512], Handle:hSQLConnection

   

    hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))

   

    if (hSQLConnection != Empty_Handle)

    {

        log_amx("[MySQL][LVL] Successfully connected to host: %s (ALL IS OK).", szHost)

        SQL_FreeHandle(hSQLConnection)

    }

    else

    {

        // Disable plugin

        set_fail_state("[LVL] Failed to connect to MySQL database: %s.", szError)

    }

   

    SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)

}

 

public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)

{

    SQL_IsFail(iFailState, iError, szError, g_szLogFile)

}

 

public client_putinserver(id)

{

    if(is_user_hltv(id) || is_user_bot(id))

        return

   

    // Just 1 second delay

    set_task(1.0, "DelayLoad", id)

 

    // Other tasks

    //set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")

    set_task(0.1, "Check_MaxXP", id, _, _, "b")

   

    // Message task

    DoubleHours()

   

    if (g_bIsDoubleHours)

    {

        set_task(REPEAT_TIME, "HappyHours", id+TASK_DOUBLE, _, _, "b")

    }

}

 

public HappyHours(taskid)

{

    new id = taskid - TASK_DOUBLE

   

    DoubleHours()

   

    if (!g_bIsDoubleHours)

        remove_task(taskid)

   

    new szDoubleHours[32]

   

    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))

   

    set_dhudmessage(0, 255, 0, -1.0, 0.5, 0, 0.0, 10.0)

    show_dhudmessage(id, "DOUBLE XP: %s", szDoubleHours)

}

 

public DelayLoad(id)

{

    // Load his data

    LoadData(id)

}

 

public client_disconnected(id)

{

    if(is_user_hltv(id) || is_user_bot(id))

        return

       

    remove_task(id+TASK_SHOWHUD)

    remove_task(id)

}

 

public Check_MaxXP(id)

{

    new iCurrentMaxXP = g_iMaxXP[id]

   

    new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)

   

    for (new i = 1; i <= g_iLevel[id]; i++)

    {

        iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))

    }

   

    if (iCurrentMaxXP != iMaxXP)

    {

        g_iMaxXP[id] = iMaxXP

    }

}

 

public Show_Hud(taskid)

{  

    new iPlayer = ID_SHOWHUD

   

    if (!is_user_alive(iPlayer))

    {

        iPlayer = pev(iPlayer, pev_iuser2)

       

        if (!is_user_alive(iPlayer))

            return

    }

   

    if (get_pcvar_num(g_pCvarPercentageStyle) != 0)

    {

        if(iPlayer != ID_SHOWHUD)

        {

            set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %0.2f %]", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)

        }

        else if (ze_is_user_zombie(iPlayer))

        {

            set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %0.2f %]", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)

        }

        else

        {

            set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

            ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %0.2f %]", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)

        }

    }

    else

    {

        if(iPlayer != ID_SHOWHUD)

        {

            if (get_pcvar_num(g_pCvarAddCommas) == 1)

            {

                new szSpecXP[15], szSpecMaxXP[15]

               

                AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))

                AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))

               

                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %s/%s]", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)

            }

            else

            {

                set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %d/%d]", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])

            }  

        }

        else if (ze_is_user_zombie(iPlayer))

        {

            if (get_pcvar_num(g_pCvarAddCommas) == 1)

            {

                new szZombieXP[15], szZombieMaxXP[15]

               

                AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))

                AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))

               

                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %s/%s]", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)

            }

            else

            {

                set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %d/%d]", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])

            }

        }

        else

        {

            if (get_pcvar_num(g_pCvarAddCommas) == 1)

            {

                new szHumanXP[15], szHumanMaxXP[15]

               

                AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))

                AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))

               

                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %s/%s]", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)

            }

            else

            {

                set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)

                ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "[Level: %d/50 || XP: %d/%d]", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])

            }

        }

    }

}

 

public ze_roundend(WinTeam)

{

    if (WinTeam == ZE_TEAM_HUMAN)

    {

        for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)

        {

            if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)

                continue

           

            DoubleHours()

           

            if (g_bIsDoubleHours)

            {

                g_iXP[id] = g_iXP[id] + (get_pcvar_num(g_pCvarEscapeSuccess) * 2)

            }

            else

            {

                g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)

            }

           

            SaveData(id)

            Check_User_Level(id)

        }

    }

   

    remove_task(TASK_SHOWHUD)

}

 

public Check_User_Level(id)

{

    if(!is_user_connected(id))

        return

 

    if(g_iXP[id] >= g_iMaxXP[id])

    {

        if (get_pcvar_num(g_pCvarStartFromZero) == 1)

        {

            g_iXP[id] = 0

        }

       

        new szName[32]

        g_iLevel[id] ++

        g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))

        get_user_name(id, szName, charsmax(szName))

        ze_colored_print(0, "!tPlayer !g%s !tNow in Level %i!y!", szName, g_iLevel[id])

        ExecuteForward(Fw_LevelUP, ForwardReturn, id)

       

        SaveData(id)

       

        PlaySound(id, LEVELUP)

       

        if (get_pcvar_num(g_pCvarLevelEffects) != 0)

        {

            // Screen Fade

            message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)

            write_short(4096*2)

            write_short(4096*5)

            write_short(0x0001)

            write_byte(random(256))

            write_byte(random(256))

            write_byte(random(256))

            write_byte(150)

            message_end()

           

            // Screen Shake

            message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)

            write_short(255<<14)

            write_short(10<<14)

            write_short(255<<14)

            message_end()

        }

    }

}

 

public ze_user_infected(iVictim, iInfector)

{

    if (iInfector == 0)

        return

   

    DoubleHours()

   

    if (g_bIsDoubleHours)

    {

        g_iXP[iInfector] = g_iXP[iInfector] + (get_pcvar_num(g_pCvarZombieInfect) * 2)

    }

    else

    {

        g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)

    }

   

    SaveData(iInfector)

    Check_User_Level(iInfector)

}

 

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)

{

    // Player Damage Himself

    if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))

        return HC_CONTINUE

   

    // Same Team?

    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))

        return HC_CONTINUE

   

    // Store Damage For every Player

    g_fDamage[iAttacker] += fDamage

   

    // Damage Calculator Equal or Higher than needed damage

    if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))

    {

        // Give Player The Coins

        DoubleHours()

       

        if (g_bIsDoubleHours)

        {

            g_iXP[iAttacker] = g_iXP[iAttacker] + (get_pcvar_num(g_pCvarDamageAward) * 2)

        }

        else

        {

            g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)

        }

       

        SaveData(iAttacker)

        Check_User_Level(iAttacker)

       

        // Rest The Damage Calculator

        g_fDamage[iAttacker] = 0.0

    }

    return HC_CONTINUE

}

 

public SaveData(id)

{

    new szAuthID[35], szName[32]

    get_user_authid(id, szAuthID, charsmax(szAuthID))

    get_user_name(id, szName, charsmax(szName))

   

    // Set Him to max if he Higher than Max Value

    if (g_iLevel[id] > MAX_LEVEL)

    {

        g_iLevel[id] = MAX_LEVEL

    }

   

    if (g_iXP[id] > MAX_XP)

    {

        g_iXP[id] = MAX_XP

    }

 

    if (!get_pcvar_num(g_pCvarSaveType))

    {

        new szData[256]

        formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])

       

        // Open the Vaults

        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)

        g_iRanksVaultHandle = nvault_open(g_szRanksVault)

 

        // Saves His Data

        nvault_set(g_iLevelsVaultHandle, szAuthID, szData)

        nvault_set(g_iRanksVaultHandle, szAuthID, szName)

       

        // Close Vaults

        nvault_close(g_iLevelsVaultHandle)

        nvault_close(g_iRanksVaultHandle)

    }

    else

    {

        new szQuery[128]

        formatex(szQuery, charsmax(szQuery), "UPDATE `Players_Information` SET `Level` = '%d', `XP` = '%d', `Max_XP` = '%d' WHERE ( `SteamID` = '%s' );", g_iLevel[id], g_iXP[id], g_iMaxXP[id], szAuthID)

        SQL_ThreadQuery(g_hTuple, "QuerySetData", szQuery)

    }

}

 

public QuerySetData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)

{

    SQL_IsFail(iFailState, iError, szError, g_szLogFile)

}

 

public QuerySetData2(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)

{

    SQL_IsFail(iFailState, iError, szError, g_szLogFile)

}

 

public LoadData(id)

{

    new szData[256], szAuthID[35]

   

    get_user_authid(id, szAuthID, charsmax(szAuthID))

   

    if (!get_pcvar_num(g_pCvarSaveType))

    {

        // Useless Variable

        new iTimestamp, iExists

       

        // Open the Vault

        g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)

       

        iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)

       

        // Close Vault

        nvault_close(g_iLevelsVaultHandle)

       

        if (!iExists)

        {

            g_iLevel[id] = 0

            g_iXP[id] = get_pcvar_num(g_pCvarStartXP)

            g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)

            SaveData(id)

        }

        else

        {

            new iLevel[32], iXP[32], iMaxLevel[32]

            parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)

           

            g_iLevel[id] = str_to_num(iLevel)

            g_iXP[id] = str_to_num(iXP)

            g_iMaxXP[id] = str_to_num(iMaxLevel)

        }

    }

    else

    {

        new szQuery[128], szData[5]

        formatex(szQuery, charsmax(szQuery), "SELECT * FROM `Players_Information` WHERE ( `SteamID` = '%s' );", szAuthID)

     

        num_to_str(id, szData, charsmax(szData))

        SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))

    }

}

 

public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])

{

    if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))

        return

   

    new id = str_to_num(szData)

   

    // No results for this query means this is new player

    if (!SQL_NumResults(hQuery))

    {

        new szSteamId[36], szQuery[128]

        get_user_authid(id, szSteamId, charsmax(szSteamId))

 

        g_iLevel[id] = 0

        g_iXP[id] = 0

        g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)

       

        // now we will insturt the values into our table.

        formatex(szQuery, charsmax(szQuery), "INSERT INTO `Players_Information` ( `SteamID` , `Level` , `XP` , `Max_XP`) VALUES ('%s', '%d', '%d', '%d');", szSteamId, g_iLevel[id], g_iXP[id], g_iMaxXP[id])

        SQL_ThreadQuery(g_hTuple, "QuerySetData2", szQuery)

        return

    }

 

    g_iLevel[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Level"))

    g_iXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "XP"))

    g_iMaxXP[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Max_XP"))

}

 

public native_ze_get_user_xp(id)

{

    if(!is_user_connected(id))

    {

        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)

        return false;

    }

   

    return g_iXP[id]

}

 

public native_ze_set_user_xp(id, amount)

{

    if(!is_user_connected(id))

    {

        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)

        return false;

    }

   

    DoubleHours()

   

    new iAddedAmount = amount - g_iXP[id]

   

    if (g_bIsDoubleHours)

    {

        g_iXP[id] = g_iXP[id] + (iAddedAmount * 2)

    }

    else

    {

        g_iXP[id] = amount

    }

 

    Check_User_Level(id)

    SaveData(id)

    return true;

}

 

public native_ze_get_user_level(id)

{

    if(!is_user_connected(id))

    {

        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)

        return false;

    }

   

    return g_iLevel[id]

}

 

public native_ze_set_user_level(id, amount)

{

    if(!is_user_connected(id))

    {

        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)

        return false;

    }

   

    g_iLevel[id] = amount

   

    if (get_pcvar_num(g_pCvarStartFromZero) == 1)

    {

        g_iXP[id] = 0

    }

   

    return true;

}

 

public native_ze_get_user_max_xp(id)

{

    if(!is_user_connected(id))

    {

        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)

        return false;

    }

   

    return g_iMaxXP[id]

}

 

public native_ze_set_user_max_xp(id, amount)

{

    if(!is_user_connected(id))

    {

        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)

        return false;

    }

   

    g_iMaxXP[id] = amount

    return true;

}

 

stock DoubleHours()

{

    new szTime[3], szDoubleHours[32], szDoubleHours_Start[32], szDoubleHours_End[32]

    get_time("%H", szTime, charsmax(szTime))

   

    get_pcvar_string(g_pCvarDoubleXP, szDoubleHours, charsmax(szDoubleHours))

   

    for (new ch = 0; ch <= charsmax(szDoubleHours); ch++)

    {

        if (szDoubleHours[ch] == '-')

            szDoubleHours[ch] = ' '

    }

   

    parse(szDoubleHours, szDoubleHours_Start, charsmax(szDoubleHours_Start), szDoubleHours_End, charsmax(szDoubleHours_End))

   

    new iTime, iDoubleHourStart, iDoubleHourEnd

   

    iTime = str_to_num(szTime)

    iDoubleHourStart = str_to_num(szDoubleHours_Start)

    iDoubleHourEnd = str_to_num(szDoubleHours_End)

   

    if(iDoubleHourEnd > iTime >= iDoubleHourStart)

    {

        g_bIsDoubleHours = true

    }

    else

    {

        g_bIsDoubleHours = false

    }

}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE

*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1036\\ f0\\ fs16 \n\\ par }

*/

and on my deimos class for vips not working correctly, normal players who don't have any flag can choose and play with it.

Deimos Zombie Class:

Code: Select all

#include <zombie_escape>
#include <ze_zombie_classes>
#include <ze_vip>
#include <fakemeta>
#include <engine>

#define TASK_WAIT 11111
#define TASK_ATTACK 22222
#define TASK_COOLDOWN 33333
#define VIP_DEIMOS ADMIN_LEVEL_A

/*================= START CONFIGS =====================*/
new const DEIMOS_NAME[] = "Deimos Zombie" // name
new const DEIMOS_INFO[] = "\yPress \w[\rG\w]  \d|" // description
const DEIMOS_HEALTH = 50000 // health
const DEIMOS_SPEED = 350 // speed
const DEIMOS_GRAVITY = 650 // gravity
/*================= END CONFIGS =====================*/

new g_iClassID, bool:g_bCanUseSkill[33]

new g_iTrail_Spr, g_iEXP_Spr

new const g_szLight_ClassName[] = "deimos_skill"
new const g_szSkill_Start[] = "Premuim_ZE/deimos_skill_start.wav"
new const g_szSkill_Hit[] = "Premuim_ZE/deimos_skill_hit.wav"

const WPN_NOT_DROP = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))

new g_pCvarCoolDown

public plugin_init()
{
	register_plugin("[Ze] Zombie Class: Deimos", "1.1", "Spi")
	
	g_pCvarCoolDown = register_cvar("ze_deimos_cooldown", "30")
	
	register_forward(FM_Touch, "Fw_Touch")
	register_clcmd("drop", "Use_Skill")
}

public plugin_precache()
{
	g_iTrail_Spr = precache_model("sprites/Premuim_ZE/trail.spr")
	g_iEXP_Spr = precache_model("sprites/Premuim_ZE/deimosexp.spr")
	
	precache_sound(g_szSkill_Start)
	precache_sound(g_szSkill_Hit)
	
	g_iClassID = ze_register_zombie_class(DEIMOS_NAME, DEIMOS_INFO, DEIMOS_HEALTH, DEIMOS_SPEED, DEIMOS_GRAVITY)	
}

public ze_user_infected(id)
{
	if (ze_is_user_zombie(id) && ze_get_current_zombie_class(id) == g_iClassID)
	{
		g_bCanUseSkill[id] = true
		ze_colored_print(id, "!gPress !y[!tg!y] !gand aim at the survivor to drop his weapon!y.")
	}
}

public ze_user_humanized(id)
{
	if (!is_user_connected(id))
		return

	if (!get_user_flags(id) & VIP_DEIMOS)
	{
		g_bCanUseSkill[id] = true
	}
	else
	{
		ze_colored_print(id, "!tYou are not !gVIP!y!")
	}
}

public Use_Skill(id)
{
	if (is_user_alive(id) && ze_is_user_zombie(id) && ze_get_current_zombie_class(id) == g_iClassID)
	{
		if (g_bCanUseSkill[id])
		{
			Do_Skill(id)
			g_bCanUseSkill[id] = false
		}
		else
		{
			ze_colored_print(id, "!gYou can't use your skill now!y.")
		}
	}
}

public Do_Skill(id)
{
	emit_sound(id, CHAN_WEAPON, g_szSkill_Start, 1.0, ATTN_NORM, 0, PITCH_NORM)
	entity_set_int(id, EV_INT_sequence, 10)

	set_task(0.5, "Launch_Light", id+TASK_ATTACK)
}

public Launch_Light(taskid)
{
	new id = taskid - TASK_ATTACK

	if (task_exists(id+TASK_ATTACK))
		remove_task(id+TASK_ATTACK)
	
	if (!is_user_alive(id))
			return
	
	// check
	new Float:flOrigin[3], Float:flAngle[3], Float:flVelocity[3]
	pev(id, pev_origin, flOrigin)
	pev(id, pev_view_ofs, flAngle)
	fm_velocity_by_aim(id, 2.0, flVelocity, flAngle)
	flAngle[0] *= -1.0
	
	// create ent
	new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
	set_pev(iEnt, pev_classname, g_szLight_ClassName)
	engfunc(EngFunc_SetModel, iEnt, "models/w_hegrenade.mdl")
	set_pev(iEnt, pev_mins, Float:{-1.0, -1.0, -1.0})
	set_pev(iEnt, pev_maxs, Float:{1.0, 1.0, 1.0})
	set_pev(iEnt, pev_origin, flOrigin)
	flOrigin[0] += flVelocity[0]
	flOrigin[1] += flVelocity[1]
	flOrigin[2] += flVelocity[2]
	set_pev(iEnt, pev_movetype, MOVETYPE_BOUNCE)
	set_pev(iEnt, pev_gravity, 0.01)
	flVelocity[0] *= 1000
	flVelocity[1] *= 1000
	flVelocity[2] *= 1000
	set_pev(iEnt, pev_velocity, flVelocity)
	set_pev(iEnt, pev_owner, id)
	set_pev(iEnt, pev_angles, flAngle)
	set_pev(iEnt, pev_solid, SOLID_BBOX)						//store the enitty id
	
	// invisible ent
	Set_Rendering(iEnt, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0)
		
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(TE_BEAMFOLLOW)
	write_short(iEnt)		//entity
	write_short(g_iTrail_Spr)	//model
	write_byte(5)		//10)//life
	write_byte(3)		//5)//width
	write_byte(209)		// Red
	write_byte(120)		// Green
	write_byte(9)		// Blue
	write_byte(200)		//brightness
	message_end()
	
	ze_colored_print(id, "!gYou have to wait !y[!t%i!y] !gsec to re!y-!guse your skill!y.", get_pcvar_num(g_pCvarCoolDown))
	set_task(get_pcvar_float(g_pCvarCoolDown), "Reset_CoolDown", id+TASK_COOLDOWN)
}

public Reset_CoolDown(taskid)
{
	new id = taskid - TASK_COOLDOWN
	
	if (ze_is_user_zombie(id) && ze_get_current_zombie_class(id) == g_iClassID)
	{
		g_bCanUseSkill[id] = true
		ze_colored_print(id, "!gYou can re!y-!guse your skill now!y!")
	}
}

public Fw_Touch(ent, victim)
{
	if (!pev_valid(ent))
		return FMRES_IGNORED
	
	new szEntClassName[32]
	entity_get_string(ent, EV_SZ_classname, szEntClassName, charsmax(szEntClassName))
	
	if (equal(szEntClassName, g_szLight_ClassName)) 
	{
		Light_Exp(ent, victim)
		remove_entity(ent)
		return FMRES_IGNORED
	}
	
	return FMRES_IGNORED
}

Light_Exp(ent, victim)
{
	if (!pev_valid(ent))
		return
	
	if (is_user_alive(victim) && !ze_is_user_zombie(victim))
	{
		new wpn, wpnname[32]
		wpn = get_user_weapon(victim)
		if (!(WPN_NOT_DROP & (1<<wpn)) && get_weaponname(wpn, wpnname, charsmax(wpnname)) )
		{
			engclient_cmd(victim, "drop", wpnname)
		}
	}
	
	// create effect
	static Float:flOrigin[3]
	pev(ent, pev_origin, flOrigin)
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(TE_EXPLOSION)	// TE_EXPLOSION
	write_coord(floatround(flOrigin[0]))	// origin x
	write_coord(floatround(flOrigin[1]))	// origin y
	write_coord(floatround(flOrigin[2]))	// origin z
	write_short(g_iEXP_Spr)	// sprites
	write_byte(40)	// scale in 0.1's
	write_byte(30)	// framerate
	write_byte(14)	// flags 
	message_end()
	
	// play sound exp
	emit_sound(ent, CHAN_WEAPON, g_szSkill_Hit, 1.0, ATTN_NORM, 0, PITCH_NORM)
}

fm_velocity_by_aim(iIndex, Float:flDistance, Float:flVelocity[3], Float:flViewAngles[3])
{
	pev(iIndex, pev_v_angle, flViewAngles)
	flVelocity[0] = floatcos(flViewAngles[1], degrees) * flDistance
	flVelocity[1] = floatsin(flViewAngles[1], degrees) * flDistance
	flVelocity[2] = floatcos(flViewAngles[0]+90.0, degrees) * flDistance
	return 1
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1036\\ f0\\ fs16 \n\\ par }
*/
and please finally i juste need to find a bigger flashlight plugin, cuz the one i have is so small and players can't see all the way in the darkness.
if someone can give me a code or just edit the custom flash light code that exists in this ze mod.
I trynna make money, not friends.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 211
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#2

Post by sPe3doN » 3 Months Ago

For level system try change this #define MAX_XP 500000 to #define MAX_XP 9000000

For zombie class i think i already convert it check here
viewtopic.php?f=17&t=3623

[ Post made via Android ]

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 633
Joined: 2 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

#3

Post by Spir0x » 3 Months Ago

thanks, what about the watergun reloading bug ?
I trynna make money, not friends.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 211
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#4

Post by sPe3doN » 3 Months Ago

Spir0x wrote:
3 Months Ago
thanks, what about the watergun reloading bug ?
My PC is broke right now i'm using phone so i can't fix watergun ask raheem or jack

[ Post made via Android ]

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest