Hi everybody, I just develop a Golden Weapons which "enable" to buy fictitiously 3 Golden Weapons with higher damage.
And there is this 'Ham_TakeDamage' forward and 'CurWeapon' event, which I don't understand well the impact of it at server's performace:
PHP Code:
RegisterHam(Ham_TakeDamage, "player", "fw_takedamage", 0)
PHP Code:
/**
* Does not affect cs built-in bots. Only players and PODBots.
*/
public fw_takedamage( victim, inflictor, attacker, Float:damage )
{
if( attacker > 0 )
{
new clip
new ammo
new currentSpecialWeapon = get_user_weapon(attacker, clip, ammo)
if( g_whichSpecialWeapon[attacker] == currentSpecialWeapon )
{
SetHamParamFloat(4, damage * g_weapon_damage )
return true
}
}
return false
}
PHP Code:
register_event("CurWeapon","curWeaponEvent","be","1=1")
PHP Code:
/**
* This message updates the numerical magazine ammo count and the corresponding ammo
* type icon on the HUD.
*/
public curWeaponEvent(id)
{
weapPickupEvent(id)
return PLUGIN_HANDLED
}
PHP Code:
/**
* When a player pickup a weapon, its change the model view to the Golden Weapon.
*/
public weapPickupEvent(id)
{
new szWeapID = read_data(2)
if( g_whichSpecialWeapon[id] == szWeapID )
{
switch( szWeapID )
{
case CSW_AK47:
{
set_pev(id, pev_viewmodel2, AK47_V_MODEL)
set_pev(id, pev_weaponmodel2, AK47_P_MODEL)
}
case CSW_M4A1:
{
set_pev(id, pev_viewmodel2, M4A1_V_MODEL)
set_pev(id, pev_weaponmodel2, M4A1_P_MODEL)
}
case CSW_MP5NAVY:
{
set_pev(id, pev_viewmodel2, MP5_V_MODEL)
set_pev(id, pev_weaponmodel2, MP5_P_MODEL)
}
}
}
return PLUGIN_HANDLED
}
Is it a performance waste? How can I do better?
Such thing higher the server client's ping?
How can I measure my server 'ping' before and after active this plugin?
I was coping & rewriting from two others plugins who does the same thing, because: 1) the first one crashes my server and i could not understand why, when reading its code, which one I did not like because uses big stuff to make damage. 2) the second one is unapproved but don't uses the big stuff at the first one.
Silver Weapons (the first one)
Golden Ak (banned author)
High performance is what I am trying to archive. By now I am reading
Optimizing Plugins (AMX Mod X Scripting).
Here is attached the plugin. It's fully working, but it does not have its low priority requisites, like customizable server variables.