if(strcmp(cmd, "/giveallmoney", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] >= 8)
{
tmp = strtok(cmdtext, idx);
new amount = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /giveallmoney [amount]");
return 1;
}
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
GivePlayerMoney(i, amount);
format(string, sizeof(string), "~y~+$~w~%d",amount);
GameTextForAll(string, 5000, 1);
format(string, sizeof(string), "• %s Has given $%d to all players •",sendername,amount);
SendClientMessageToAll(YELLOW,string);
}
}
}
return 1;
}
CMD:giveallmoney(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 8)
{
new ammount;
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /giveallmoney [amount]");
foreach(new i : Player)
{
GivePlayerMoney(i, amount);
format(string, sizeof(string), "~y~+$~w~%d",amount);
GameTextForAll(string, 5000, 1);
format(string, sizeof(string), "• %s Has given $%d to all players •",sendername,amount);
SendClientMessageToAll(YELLOW,string);
}
}
return 1;
}
|
Here take this as an example, i have replaced the for loop with a foreach loop (https://github.com/karimcambridge/SAMP-foreach - standalone version download, but it is also included in YSI) the command parameter stuff using sscanf (https://github.com/maddinat0r/sscanf/releases) and the command itself using a command processor, since most comman processor have the same syntax, you can use most likely every command processor you want, just search for one, as for me i am using this one: https://sampforum.blast.hk/showthread.php?tid=608474
PHP код:
|
CMD:giveallmoney(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 8)
{
new amount;
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, 0xF8F8F8FFF, "Usage:/giveallmoney [amount]");
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new str[128];
new AdminName[MAX_PLAYER_NAME];
GetPlayerName(playerid, AdminName, sizeof(AdminName));
format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has give $%d to all player .", AdminName, amount);
SendClientMessageToAll(0xf0f0f0f0, str);
GivePlayerMoney(i,amount);
}
}
}
}
else return SendClientMessage(playerid, 0xf8f8f8fff, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command.");
return 1;
}
CMD:giveallmoney(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 8)
{
new ammount;
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /giveallmoney [amount]");
foreach(new i : Player)
{
GivePlayerMoney(i, amount);
}
new string[37];
format(string, sizeof(string), "~y~+$~w~%d", amount);
GameTextForAll(string, 5000, 1);
format(string, sizeof(string), "• %s Has given $%d to all players •", sendername, amount);
SendClientMessageToAll(YELLOW, string);
}
return 1;
}