It is a good idea to use new syntax, if you wish to use new add this directive
PHP Code:
#pragma newdecls required
will bust your ass and not compile as it forces you to use new syntax.
Below i thought i would show you a better way of writing it removing what you don't need from how i understand your code, this could just break your whole thing.
PHP Code:
public void tongue_grab(Event event, const char[] name, bool dontBroadcast)// don't need action since you are not changing the event
{
int victim = GetClientOfUserId(GetEventInt(event, "victim"));
if(!IS_VALID_SURVIVOR(victim))
return;
int id = GetClientOfUserId(GetEventInt(event, "userid"));
if (IS_INFECTED_ALIVE(id))
{
for (int i = 1; i <= MaxClients; i++)
{
if (IS_VALID_SURVIVOR(i) && i != victim)// ignore the survivor getting smoked
{
if(!IsPlayerAlive(i))
{
continue;
}
if (l4dver == 1)
{
if (IsClientIncapacitatedl4d1(i) == false)
{
return;
}
}
else
{
if (IsClientIncapacitatedl4d2(i) == false)
{
return;// no need to do anything if a survivor is up and about and no need to continue looping
}
}
}
}
switch(GetConVarInt(cvar_killorslap))// just get the val when you need
{
case 1:
PerformKill(id, GetConVarInt(cvar_displaykillmessage));
case 2:
PerformSlap(id, GetConVarInt(cvar_displaykillmessage));
}
}
return;
}
void PerformKill(int id, int displaykillmessage)// 1 less param and does the same thing
{
ForcePlayerSuicide(id);
switch (displaykillmessage)
{
case 1:
PrintCenterTextAll("[SM] %N was socked for smoking last.", id);// don't need to pass clientname %N does it for you when formatting Prints
case 2:
PrintHintTextToAll("[SM] %N was socked for smoking last.", id);
case 3:
PrintToChatAll("\x01\x04[SM] \x03%N \x01was socked for smoking last.", id);
}
}
void PerformSlap(int id, int displaykillmessage)
{
float vpos[3];
GetEntPropVector(id, Prop_Data, "m_vecOrigin", vpos);
vpos[2] += 30.0; // just use the same array you created do what you wish no need for creating 2
TeleportEntity(id, vpos, NULL_VECTOR, NULL_VECTOR);
switch (displaykillmessage)
{
case 1:
PrintCenterTextAll("[SM] %N was slapped for smoking last.", id);
case 2:
PrintHintTextToAll("[SM] %N was slapped for smoking last.", id);
case 3:
PrintToChatAll("\x01\x04[SM] \x03%N \x01was slapped for smoking last.", id);
}
}
Since you are using a switch for your different cvar options it's a good idea to clamp the cvar if someone were to set killorslap = 3 nothing would happen.
PHP Code:
cvar_killorslap = CreateConVar("killorslap", "1", "1 kill smoker or 2 slap smoker", CVAR_FLAGS, true, 1.0, true, 2.0);
With the new syntax you have classes or methods
whichever you call them this is nothing to think about now but you can write code faster with them here a small example instead of nesting functions.
PHP Code:
int id = GetClientOfUserId(GetEventInt(event, "userid"));
int id = event.GetInt("userid"));
Does require you to use the event tag thingy
e.g "Event event"
PHP Code:
public void tongue_grab(Event event, const char[] name, bool dontBroadcast)
__________________