Commands crash server
#1

Hi!

Both of the commands below crash the server when used and I don't see any problem with them.

Код:
CMD:armor(playerid, params[])
{
   static Armor;
   if(pData[playerid][Rank] < 1) return SendErrorMessage(playerid, "You must be atleast a Recruit to do this.");
   if(sscanf(params, "i", Armor)) return SendSyntaxMessage(playerid, "/armor [value]");
   if(Armor < 0 || Armor > 125) return SendErrorMessage(playerid, "Invalid amount.");
   SetPlayerArmour(playerid, Armor);
   CommandMsg(COLOR_RED, "%s (%d) has set their armor to %d.", ReturnName(playerid, 0), playerid, Armor);
   SendClientMessageEx(playerid, -1, "You have set your armor to %d.", Armor);
   return 1;
}
Код:
CMD:hp(playerid, params[])
{
   static hp;
   if(pData[playerid][Rank] < 1) return SendErrorMessage(playerid, "You must be atleast a Recruit to do this.");
   if(sscanf(params, "i", hp)) return SendSyntaxMessage(playerid, "/hp [value]");
   if(hp < 0 || hp > 125) return SendErrorMessage(playerid, "Invalid amount.");
   SetPlayerHealth(playerid, hp);
   CommandMsg(COLOR_RED, "%s (%d) has set their health to %d.", ReturnName(playerid, 0), playerid, hp);
   SendClientMessageEx(playerid, -1, "You have set your health to %d.", hp);
   return 1;
}
Would appreciate any help.

EDIT: Commenting the 'CommandMsg' function worked, doesn't crash anymore.

I use it on other functions too and it doesn't crash though, is there anything wrong?

Код:
forward CommandMsg(color, message[]);
public CommandMsg(color, message[])
{
     new string[128];
     format(string, sizeof(string), "%s", message);
     for(new i = 0; i < MAX_PLAYERS; i++)
     {
          if(IsPlayerConnected(i))
          {
                if(pData[i][Rank] >= 6)
                {
                      SendClientMessage(i, color, string);
                }
          }
      }
}
Reply
#2

Ignoring warnings results to such things. You definitely got warning 202: number of arguments does not match definition and the cause of the crash is specifiers in client messages.

So you have three options:

1) Format and sending the message to those players whose rank is >= 6 (the standard way).
2) Use y_va (from YSI)
3) Wait for somebody with knowledge of #emit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)