17.08.2016, 19:42
Hi!
Both of the commands below crash the server when used and I don't see any problem with them.
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?
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; }
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); } } } }