View Single Post
TryNoob
BANNED
Join Date: Aug 2011
Old 08-24-2012 , 07:14   Re: CS:S Update (8/22/12)
Reply With Quote #164

Tell me, what is wrong in this code, after the upgrade the server crash when trying to purchase:
Code:
public Action:CS_OnBuyCommand(client, const String:weapon[])
{
	if(StrEqual(weapon, "vesthelm"))
		return Plugin_Handled;
	
	if(IsValidPlayer(client))
		FakeClientCommand(client, "buy vest");
	
	return Plugin_Continue;
}

stock bool:IsValidPlayer(client, bool:alive = false)
{
	if(client>0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
	{
		if(alive && !IsPlayerAlive(client))
			return false;
		
		return true;
	}
	return false;
}
And with it all ok:
Code:
public Action:CS_OnBuyCommand(client, const String:weapon[])
{
	if(StrEqual(weapon, "vesthelm"))
	{
		if(IsValidPlayer(client))
			FakeClientCommand(client, "buy vest");
		return Plugin_Handled;
	}
	
	return Plugin_Continue;
}

Last edited by TryNoob; 08-24-2012 at 07:20.
TryNoob is offline