- like in original, if this cheat is executed while player is dead, player spawn next with all weapons.
PHP Code:
enum
{
AR2 = 1,
AR2AltFire,
Pistol,
SMG1,
_357,
XBowBolt,
Buckshot,
RPG_Round,
SMG1_Grenade,
Grenade,
slam
}
int pMaxCarry[] = {
0,
60,
3,
150,
225,
12,
10,
30,
3,
3,
5,
5
}
#include <sdktools>
StringMap lateweapons;
public void OnPluginStart()
{
lateweapons = new StringMap();
RegAdminCmd("sm_impulse", impulse, ADMFLAG_CHEATS);
HookEvent("player_spawn", player_spawn);
}
public void player_spawn(Event event, const char[] name, bool dontBroadcast)
{
CreateTimer(0.5, spawn_delay, event.GetInt("userid"), TIMER_FLAG_NO_MAPCHANGE);
}
public Action spawn_delay(Handle timer, int userid)
{
int client = GetClientOfUserId(userid);
if(!client || !IsClientInGame(client) || !IsPlayerAlive(client))
return Plugin_Handled;
char key[30];
Format(key, sizeof(key), "%i", GetClientUserId(client));
bool value = false;
if(lateweapons.GetValue(key, value) && value)
{
lateweapons.Remove(key);
GiveAllItems(client);
}
return Plugin_Handled;
}
public Action impulse(int client, int args)
{
//if(!client || !IsClientInGame(client) || !IsPlayerAlive(client))
// return Plugin_Handled;
char buffer[5];
GetCmdArgString(buffer, sizeof(buffer));
int num = StringToInt(buffer);
switch(num)
{
case 101:
{
char key[30];
for(int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
if(!IsPlayerAlive(i))
{
Format(key, sizeof(key), "%i", GetClientUserId(i));
lateweapons.SetValue(key, true, true);
continue;
}
GiveAllItems(i);
}
}
}
return Plugin_Handled;
}
void GiveAllItems(int i)
{
if(HasEntProp(i, Prop_Send, "m_bWearingSuit"))
SetEntProp(i, Prop_Send, "m_bWearingSuit", true);
GiveAmmo(i, 255, Pistol);
GiveAmmo(i, 255, AR2);
GiveAmmo(i, 005, AR2AltFire);
GiveAmmo(i, 255, SMG1);
GiveAmmo(i, 255, Buckshot);
GiveAmmo(i, 001, SMG1_Grenade);
GiveAmmo(i, 003, RPG_Round);
GiveAmmo(i, 005, Grenade);
GiveAmmo(i, 032, _357);
GiveAmmo(i, 002, slam);
GivePlayerItem(i, "weapon_crowbar" );
GivePlayerItem(i, "weapon_stunstick" );
GivePlayerItem(i, "weapon_pistol" );
GivePlayerItem(i, "weapon_357" );
GivePlayerItem(i, "weapon_smg1" );
GivePlayerItem(i, "weapon_ar2" );
GivePlayerItem(i, "weapon_shotgun" );
GivePlayerItem(i, "weapon_frag" );
GivePlayerItem(i, "weapon_crossbow" );
GivePlayerItem(i, "weapon_rpg" );
GivePlayerItem(i, "weapon_slam" );
GivePlayerItem(i, "weapon_physcannon" );
}
void GiveAmmo(int client, int ammo, int ammotype)
{
// skip cvars, max ammo
int ammoalready = GetEntProp(client, Prop_Send, "m_iAmmo", _, ammotype);
if(ammoalready + ammo > pMaxCarry[ammotype])
{
SetEntProp(client, Prop_Send, "m_iAmmo", pMaxCarry[ammotype], _, ammotype);
return;
}
SetEntProp(client, Prop_Send, "m_iAmmo", ammoalready + ammo, _, ammotype);
}