/refund cmd - 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: /refund cmd (
/showthread.php?tid=373060)
/refund cmd -
Scott Zulkifli - 29.08.2012
pawn Код:
CMD:refund(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new giveplayerid;
if(sscanf(params, "udd", giveplayerid))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /refund [playerid]");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
{
PlayerInfo[giveplayerid][pLevel] = 5;
SetPlayerScore(giveplayerid, PlayerInfo[giveplayerid][pLevel]);
PlayerInfo[giveplayerid][pAccount] = 1000000;
PlayerInfo[giveplayerid][pMats] = 10000;
PlayerInfo[giveplayerid][pPot] = 100;
PlayerInfo[giveplayerid][pCrack] = 100;
}
SendClientMessageEx(giveplayerid, COLOR_GRAD1, "You have refunded by Admin %d ", GetPlayerName(playerid));
}
}
return 1;
}
how now?
Re : /refund cmd -
ricardo178 - 29.08.2012
How what? It'd be better if you say what fails/what you want... Just saying.
P.S. If it isn't working, replace whole thing with this..
pawn Код:
CMD:refund(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /refund [playerid]");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
PlayerInfo[giveplayerid][pLevel] = 5;
SetPlayerScore(giveplayerid, PlayerInfo[giveplayerid][pLevel]);
PlayerInfo[giveplayerid][pAccount] = 1000000;
PlayerInfo[giveplayerid][pMats] = 10000;
PlayerInfo[giveplayerid][pPot] = 100;
PlayerInfo[giveplayerid][pCrack] = 100;
SendClientMessageEx(giveplayerid, COLOR_GRAD1, "You have been refunded by Administrator %s ", name);
return 1;
}
else return SendClientMessage(playerid, COLOR_WHITE, "Player is not connected.");
}
else return SendClientMessage(playerid, COLOR_WHITE, "You're not an administrator.");
}
Now some tips...
For strings like names, use %s and not %d..
Only open new loops if have a statment, not just opening and closing brakets for no reason, and if you remove a statment, remove its brakets and returns.
When using sscanf, "u" is for ID, no need of the "dd" you had there.
To format a name as string, you should define it as for example "new name[MAX_PLAYER_NAME];", than get it, "GetPlayerName(playerid, name, sizeof(Name));", and than you can use it..