Not working properly - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Not working properly (
/showthread.php?tid=407452)
Not working properly -
Fernado Samuel - 13.01.2013
Hello
I have a problem with my /givecookies command.
If i give cookie to any players then it is giving only to ID 0.
Here is the code
pawn Код:
CMD:givecookies(playerid,params[]) {
if(PInfo[playerid][Level] >= 4) {
new tmp[128], tmp2[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(sscanf(params,"ds",tmp,tmp2)) return SendClientMessage(playerid, -1, "USAGE: /givecookies [playerid] [amount]");
new player1 = strval(tmp), cookie = strval(tmp2), string[128];
if(PInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
format(string, sizeof(string), "You have given %d Cookie(s) to %s", cookie, pName(player1)); SendClientMessage(playerid,yellow,string);
format(string,sizeof(string),"Administrator %s has given %d Cookie(s) to %s. %s have %d Cookies in total.", pName(playerid), cookie, pName(player1), pName(player1), PInfo[player1][Cookies]);
SendClientMessageToAll(nicegreen, string);
return PInfo[player1][Cookies] += cookie;
} else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
} else return SendClientMessage(playerid,-1,"ERROR.You are not a high enough level to use this command");}
Please help to fix it.
Re: Not working properly -
Jay_Dixon - 14.01.2013
Try this instead of what you got going there. Although it looks like you'll have to convert the code there o.O
I didn't see that, i just gave you the /cookie commad outta my script XD
Код:
CMD:cookie(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new playa,amount;
if(!sscanf(params, "ui", playa, amount))
{
if(IsPlayerConnected(playa))
{
if(playa == playerid && PlayerInfo[playerid][pAdmin] < 9999)
{
SendClientMessage(playerid, COLOR_LIGHTRED, " You can't award cookies to yourself!");
return 1;
}
PlayerInfo[playa][pCookies] += amount;
new string[128];
format(string, sizeof(string), "* Admin %s awared you with %d cookies.", PlayerNameEx(playerid), amount);
SendClientMessage(playa, COLOR_ORANGE, string);
format(string, sizeof(string), "* You awarded %s with %d cookies.", PlayerNameEx(playa), amount);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
format(string, sizeof(string), "AdmCmd: %s awarded %d cookie(s) to %s!", PlayerNameEx(playerid), amount, PlayerNameEx(playa));
BroadCast(COLOR_GREENISHGOLD, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, " Invalid player!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Cookie [playerid/PartOfName] [Amount]");
SendClientMessage(playerid, COLOR_LIGHTBLUE, "Gives the player an RP cookie.(Negative amounts possible)");
}
}
return 1;
}