05.03.2012, 23:38
Hello.
I'm currently making a cookie system, and It's going well so far. Here's what I currently have.
Alright, so say I wanted to make a /buyvip command. And the person needs 5 cookies to buy it. How could I take away 5 cookies, without deleting them all?
Also... When I /give the player a cookie, it doesn't save in the scriptfiles until he logs out. How could I save it instantly?
Thanks for your help.
I'm currently making a cookie system, and It's going well so far. Here's what I currently have.
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);
PlayerInfo[pid][pCookies] ++;
}
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;
}
Also... When I /give the player a cookie, it doesn't save in the scriptfiles until he logs out. How could I save it instantly?
Thanks for your help.