CMD:giveallscore(playerid, params[])
{
if(PInfo[playerid][Level] < 4) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
for(new i=0; i<MAX_PLAYERS; i++)
{
new ammount;
if(sscanf(params,"i", ammount))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /giveallscore [score]");
else
{
new score = GetPlayerScore(i);
SetPlayerScore(i, score + ammount);
new pname[24],dstring[124];
GetPlayerName(playerid,pname,sizeof(pname));
format(dstring, sizeof(dstring), "Administrator %s has given everybody %d score.", pname, ammount);
SendClientMessageToAll(blue, dstring);
}
return 0;
}
return 1;
}
Administrator Max has given everybody (amount) score
SERVER: That command does not exist, use /cmds for all our commands
CMD:giveallscore(playerid, params[])
{
if(PInfo[playerid][Level] < 4) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
new ammount;
if(sscanf(params,"i", ammount))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /giveallscore [score]");
for(new i=0; i<MAX_PLAYERS; i++)
SetPlayerScore(i, GetPlayerScore(i) + ammount);
new pname[24],dstring[124];
GetPlayerName(playerid,pname,sizeof(pname));
format(dstring, sizeof(dstring), "Administrator %s has given everybody %d score.", pname, ammount);
SendClientMessageToAll(blue, dstring);
return 1;
}
NEVER return inside a loop unless you explicitly want to break out of it. But actually your whole command is flawed. Removing the return will just spam the server with SendClientMessageToAll, which is probably the reason why you put it there in the first place.
pawn Код:
|
CMD:giveallmoney(playerid, params[])
{
if(PInfo[playerid][Level] < 4) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");//Checking if the player has admin level 3, if not it sends him a message.
for(new i=0; i<MAX_PLAYERS; i++)
{
new ammount;
if(sscanf(params,"i", ammount))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /giveallmoney [ammount]");
else
{
new pname[24],dstring[124];
GetPlayerName(playerid,pname,sizeof(pname));
PlayerPlaySound(i,1057,0.0,0.0,0.0);
format(dstring,sizeof(dstring),"Administrator %s has given everybody %d money!",pname, ammount );
SendClientMessageToAll(blue,dstring);
}
return 0;
}
return 1;
}
Only use functions in the loop for which you need the loop variable (in this case i). Move all the rest outside the loop.
|
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success == 0)
SendClientMessage(playerid, red, "SERVER: That command does not exist, use /cmds for all our commands!");
return 1;
}
So can you fix my other command to? and show with // what you changed ?
|
He told you what you need to do, then do it yourself he is not going to fix all of your commands.
|