I have an error with the vip code, namely when it activates everyone gets privileges
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
char tag[64] = "VIP";
int offsetHe;
int offsetFlash;
int offsetSmoke;
int offsetInc;
int offsetMol;
public void OnPluginStart()
{
HookEvent("bomb_planted", EventBombPlanted);
HookEvent("bomb_defused", EventBombDefused);
HookEvent("player_spawn", PlayerSpawn);
HookEvent("player_death", PlayerDeath);
}
public void OnMapStart()
{
int entindex;
entindex = CreateEntityByName("weapon_hegrenade");
DispatchSpawn(entindex);
offsetHe = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
AcceptEntityInput(entindex, "Kill");
entindex = CreateEntityByName("weapon_flashbang");
DispatchSpawn(entindex);
offsetFlash = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
AcceptEntityInput(entindex, "Kill");
entindex = CreateEntityByName("weapon_smokegrenade");
DispatchSpawn(entindex);
offsetSmoke = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
AcceptEntityInput(entindex, "Kill");
entindex = CreateEntityByName("weapon_incgrenade");
DispatchSpawn(entindex);
offsetInc = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
AcceptEntityInput(entindex, "Kill");
entindex = CreateEntityByName("weapon_molotov");
DispatchSpawn(entindex);
offsetMol = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
AcceptEntityInput(entindex, "Kill");
}
public Action PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(!IsPlayerVIP(client)) return;
if(GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 0)
SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
if(GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 0)
SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
int money = GetEntProp(client, Prop_Send, "m_iAccount");
SetEntProp(client, Prop_Send, "m_iAccount", money+200);
if(GetClientTeam(client) == CS_TEAM_CT)
if(GetEntProp(client, Prop_Send, "m_bHasDefuser") == 0) GivePlayerItem(client, "item_defuser");
for(int x = 0; x < 1; x++)
if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetHe) < 1) GivePlayerItem(client, "weapon_hegrenade");
for(int x = 0; x < 1; x++)
if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetFlash) < 1) GivePlayerItem(client, "weapon_flashbang");
for(int x = 0; x < 1; x++)
if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetSmoke) < 1) GivePlayerItem(client, "weapon_smokegrenade");
if(GetClientTeam(client) == CS_TEAM_CT)
{
for(int x = 0; x < 1; x++) // ilosc inc
if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetInc) < 1) GivePlayerItem(client, "weapon_incgrenade");
}
else if(GetClientTeam(client) == CS_TEAM_T)
{
for(int x = 0; x < 1; x++)
if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetMol) < 1) GivePlayerItem(client, "weapon_molotov");
}
}
public Action PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if(!IsValidPlayer(attacker) || !IsPlayerVIP(attacker)) return;
int health = GetClientHealth(attacker);
SetEntityHealth(attacker, health+5);
int money = GetEntProp(attacker, Prop_Send, "m_iAccount");
SetEntProp(attacker, Prop_Send, "m_iAccount", money+100);
bool headshot = GetEventBool(event, "headshot", false);
if(headshot)
{
health = GetClientHealth(attacker);
SetEntityHealth(attacker, health+10);
money = GetEntProp(attacker, Prop_Send, "m_iAccount");
SetEntProp(attacker, Prop_Send, "m_iAccount", money+150);
}
if(GetClientHealth(attacker) > 100)
SetEntityHealth(attacker, 100);
}
public Action EventBombPlanted(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int money = GetEntProp(client, Prop_Send, "m_iAccount");
if(IsPlayerVIP(client))
SetEntProp(client, Prop_Send, "m_iAccount", money+150);
}
public Action EventBombDefused(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
int money = GetEntProp(client, Prop_Send, "m_iAccount");
if(IsPlayerVIP(client))
SetEntProp(client, Prop_Send, "m_iAccount", money+150);
}
public void OnClientPostAdminCheck(int client)
{
if(IsPlayerVIP(client))
{
PrintToChatAll(" %s \x03%N\x01 \x01", tag, client);
}
}
stock bool IsValidPlayer(int client)
{
if(client >= 1 && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client) && !IsClientSourceTV(client))
return true;
return false;
}
stock bool IsPlayerVIP(int client)
{
if(GetUserFlagBits(client) & ADMFLAG_CUSTOM6))
return true;
return false;
}