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);
PlayerInfo[pid][pCookies] ++;
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
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;
}
PlayerInfo[playerid][pCookies] = PlayerInfo[playerid][pCookies] - 5;
pawn Код:
Just read the rest of the question. To save it instantly you check how it saves in OnPlayerDisconnect and take the crucial parts to save cookies. |
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
INI_Close(File);
PlayerInfo[pid][pCookies] ++;
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
INI_Close(File);
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Frozen",PlayerInfo[playerid][pFrozen]);
INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMute]);
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
INI_Close(File);
return 1;
}
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]+=iAmount);
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]-=iAmount);
INI_Close(File);
new iPlayer;
new iAmount;
new iReason[MAX_STRINGS];
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
new iPlayer;
new iAmount;
new iReason[MAX_STRINGS];
new str[256];
if(sscanf(params, "usS[250]",iPlayer, iAmount, iReason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Amount] [Reason]");
if(!IsPlayerConnected(iPlayer)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "PlayerID is not connected.");
if(PlayerInfo[playerid][pAdmin]>=2)
{
format(str, sizeof(str), "%s has received %s Cookies by Administrator %s. Reason:%s ",GetName(iPlayer), iAmount, GetName(playerid), iReason);
SendClientMessageToAll(COLOR_ORANGE, str);
format(str, sizeof(str), "You just gave a cookie to %s.", GetName(iPlayer));
SendClientMessage(playerid, COLOR_GREEN, str);
// PlayerInfo[iPlayer][pCookies] ++;
PlayerInfo[playerid][pCookies] += iAmount;
PlayerInfo[playerid][pCookies]-= iAmount;
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]+=iAmount);
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]-=iAmount);
INI_Close(File);
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
There's no way to make it save instantly?
EDIT: I've added this, to the command. pawn Код:
pawn Код:
Here's the full command. pawn Код:
pawn Код:
|