SourceMod Developer
|
04-17-2008
, 18:02
Re: TF2: Capper Regeneration
|
#10
|
PHP Code:
stock bool:RegeneratePlayer(client) { if (!IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client)) return false;
new TFClassType:class = TF2_GetPlayerClass(client); switch (class) { case 0: { return false; } case 1: { SetEntProp(client, Prop_Send, "m_iHealth", 125); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 32); SetEntData(GetPlayerWeaponSlot(client, 0), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 6); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 36); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 12); } case 2: { SetEntProp(client, Prop_Send, "m_iHealth", 125); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 25); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 75); SetEntData(GetPlayerWeaponSlot(client, 0), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 25); } case 3: { SetEntProp(client, Prop_Send, "m_iHealth", 200); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 16); SetEntData(GetPlayerWeaponSlot(client, 0), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 4); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 32); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 6); } case 4: { SetEntProp(client, Prop_Send, "m_iHealth", 175); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 16); SetEntData(GetPlayerWeaponSlot(client, 0), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 4); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 24); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 8); } case 5: { SetEntProp(client, Prop_Send, "m_iHealth", 150); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 150); SetEntData(GetPlayerWeaponSlot(client, 0), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 30); } case 6: { SetEntProp(client, Prop_Send, "m_iHealth", 300); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 200); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 32); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 6); } case 7: { SetEntProp(client, Prop_Send, "m_iHealth", 175); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 200); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 32); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 6); } case 8: { SetEntProp(client, Prop_Send, "m_iHealth", 125); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 24); SetEntData(GetPlayerWeaponSlot(client, 0), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 6); } case 9: { SetEntProp(client, Prop_Send, "m_iHealth", 125); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 4, 32); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 6); SetEntData(client, FindSendPropInfo("CTFPlayer", "m_iAmmo") + 8, 200); SetEntData(GetPlayerWeaponSlot(client, 1), FindSendPropInfo("CTFWeaponBase", "m_iClip1"), 12); } }
return true; }
I tried it out, and it seems to work fine for me. I didn't notice any bugs with it. It returns true if successful, false if the client isn't connected/in-game/alive or if they do not currently have a class (not sure where this would apply, but it's just a safety precaution).
It uses functions from the snapshots, so you'll need to use those instead of the 1.0 base.
|
|