Quote:
Originally Posted by DJ Tsunami
This system with files is going to be a mess, you should use Client Preferences to store client information across connections.
|
Thank you very much dude!! I didn't think about using cookies... So, again, I changed my code to this and it's working:
PHP Code:
Handle g_hPointCookie;
int messagePoints;
public void OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
g_hPointCookie = RegClientCookie("give_points", "Give Points", CookieAccess_Protected);
}
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) {
int victim = GetClientOfUserId(event.GetInt("userid"));
int attacker = GetClientOfUserId(event.GetInt("attacker"));
int assist = GetClientOfUserId(event.GetInt("assister"));
char victimName[40], attackerName[40], assistName[40];
GetClientName(victim, victimName, sizeof(victimName));
GetClientName(attacker, attackerName, sizeof(attackerName));
GetClientName(assist, assistName, sizeof(assistName));
if(victim == attacker || attacker == 0){
return;
}
GivePoints(attacker, 10);
PrintToChatAll("%s killed %s | Points: %i", attackerName, victimName, messagePoints);
if(assist){
GivePoints(assist, 2);
PrintToChatAll("%s helped killing %s | Points: %i", assistName, victimName, messagePoints);
}
}
public void GivePoints(int targetID, int points) {
if (AreClientCookiesCached(targetID))
{
char sCookieValue[12];
GetClientCookie(targetID, g_hPointCookie, sCookieValue, sizeof(sCookieValue));
int Points = StringToInt(sCookieValue);
Points += points;
messagePoints = Points;
IntToString(Points, sCookieValue, sizeof(sCookieValue));
SetClientCookie(targetID, g_hPointCookie, sCookieValue);
}
}
Love you guys ;)