PHP Code:
public Action CheckPlayerWeapon(Handle timer)
{
char wpn[24];
for(int i = 1, weapon; i <= MaxClients; i++)
if(IsSurvivor(i) && !IsFakeClient(i) && IsPlayerAlive(i) && (weapon = GetPlayerWeaponSlot(i, 0)) != -1)
{
GetEdictClassname(weapon, wpn, sizeof(wpn));
if(!strcmp(wpn[7], "smg_mp5") || !strcmp(wpn[7], "rifle") || !strcmp(wpn[7], "sniper_military"))
PrintToChat(i, "1");
else if(!strcmp(wpn[7], "rifle_desert") || !strcmp(wpn[7], "sniper_awp") || !strcmp(wpn[7], "shotgun_spas"))
PrintToChat(i, "2");
else if(!strcmp(wpn[7], "smg") || !strcmp(wpn[7], "rifle_ak47") || !strcmp(wpn[7], "shotgun_chrome"))
PrintToChat(i, "3");
else if(!strcmp(wpn[7], "autoshotgun") || !strcmp(wpn[7], "sniper_scout") || !strcmp(wpn[7], "rifle_sg552"))
PrintToChat(i, "4");
else if(!strcmp(wpn[7], "hunting_rifle") || !strcmp(wpn[7], "smg_silenced") || !strcmp(wpn[7], "pumpshotgun"))
PrintToChat(i, "5");
else PrintToChat(i, "6");
}
return Plugin_Continue;
}
This code will send number by timer to survivors.
But maybe it's better to show the number only when the player has picked up a weapon?
PHP Code:
public void OnClientPutInServer(int client)
{
if(!IsFakeClient(client)) SDKHook(client, SDKHook_WeaponEquipPost, Hook_WeaponEvent);
}
public void Hook_WeaponEvent(int client, int weapon)
{
RequestFrame(RequestFrame_Callback, GetClientUserId(client));
}
public void RequestFrame_Callback(any client)
{
static int weapon;
if(!(client = GetClientOfUserId(client)) || !IsPlayerAlive(client) || (weapon = GetPlayerWeaponSlot(client, 0)) == -1)
return;
GetEdictClassname(weapon, wpn, sizeof(wpn));
if(!strcmp(wpn[7], "smg_mp5") || !strcmp(wpn[7], "rifle") || !strcmp(wpn[7], "sniper_military"))
PrintToChat(client, "1");
else if(!strcmp(wpn[7], "rifle_desert") || !strcmp(wpn[7], "sniper_awp") || !strcmp(wpn[7], "shotgun_spas"))
PrintToChat(client, "2");
else if(!strcmp(wpn[7], "smg") || !strcmp(wpn[7], "rifle_ak47") || !strcmp(wpn[7], "shotgun_chrome"))
PrintToChat(client, "3");
else if(!strcmp(wpn[7], "autoshotgun") || !strcmp(wpn[7], "sniper_scout") || !strcmp(wpn[7], "rifle_sg552"))
PrintToChat(client, "4");
else if(!strcmp(wpn[7], "hunting_rifle") || !strcmp(wpn[7], "smg_silenced") || !strcmp(wpn[7], "pumpshotgun"))
PrintToChat(client, "5");
else PrintToChat(client, "6");
}
__________________