CMD:cookies(playerid, params[])
{
new pCookies;
new target;
new str[128];
if(sscanf(params, "u[128]", target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cookies [Player ID]");
if!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: Player is not connected");
if(PlayerInfo[playerid][pAdmin] >=1
{
format(str, sizeof(str), "You have checked %s's Cookies.", GetName(target));
SendClientMessage(playerid, COLOR_CYAN, str);
CMD:cookies(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cookies [Player ID]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "This player is not connected!");
new str[64];
format(str, sizeof(str), "%s(%d) does have %d cookies.", GetName(id), id, /*Put here the player variable of the cookies*/);
SendClientMessage(playerid, COLOR_WHITE, str);
return 1;
}
Get the variable of the "player cookies", and in format just add the %d or %i to add numbers inside a string.
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));
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
INI_Close(File);
PlayerInfo[pid][pCookies] ++;
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}