06.03.2012, 23:58
Alright, I'm still in need of help. When I do /givecookie to a player, it gives a cookie to everyone on the server. And I only want the selected player to get a cookie. Also, /resetcookies resets every ones cookies, not just the selected person. Here's my current code for the commands.
What else is wrong?... I really need to get this thing working.
pawn Код:
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
new pid;
new reason[128];
new str[128];
if(sscanf(params, "us[128]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "PlayerID is not connected.");
if(PlayerInfo[playerid][pAdmin]>=2)
{
format(str, sizeof(str), "%s has been granted a cookie by Administrator %s. Reason: (%s)", GetName(pid), GetName(playerid), reason);
SendClientMessageToAll(COLOR_ORANGE, str);
format(str, sizeof(str), "You just gave a cookie to %s.", GetName(pid));
SendClientMessage(playerid, COLOR_GREEN, str);
new INI:File = INI_Open(UserPath(playerid));
PlayerInfo[pid][pCookies] ++;
INI_WriteInt(File,"Cookies",PlayerInfo[pid][pCookies]);
INI_Close(File);
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
pawn Код:
CMD:resetcookies(playerid, params[])
{
new pid;
new reason[128];
new str[128];
if(sscanf(params, "us[128]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /resetcookies [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: Player is not connected");
if(PlayerInfo[playerid][pAdmin]>=2)
{
format(str, sizeof(str), "Administrator %s has reset %s's Cookies. Reason: (%s)", GetName(playerid), GetName(pid), reason);
SendClientMessageToAll(COLOR_ORANGE, str);
format(str, sizeof(str), "You just reset %s's Cookies.", GetName(pid));
SendClientMessage(playerid, COLOR_GREEN, str);
PlayerInfo[pid][pCookies] = 0;
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
pawn Код:
CMD:cookies(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin]>=1)
{
new id, str[64];
if(sscanf(params, "r", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cookies [Player ID]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "This player is not connected!");
format(str, sizeof(str), "%s(%d) has (%d) Cookies.", GetName(id), id,PlayerInfo[playerid][pCookies]);
SendClientMessage(playerid, 0x0, str);
}
else SendClientMessage(playerid, 0x0, "You're not authorized to use this command.");
return 1;
}