Command crash's server? SSCANF
#1

Ok guys, so i've tried both, changing from "d" to "ds" or "uds" or just "ud"

but none of them worked, when I try to use the cmd IG, it crashes my server.


Код HTML:
CMD:warn(playerid, params[])
{
if(PInfo[playerid][Level] >= 1) {
   {
                new name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],string[128],id,reason[64];
                if(sscanf(params,"us[125]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /warn [playerid] [reason]");
                GetPlayerName(id,name, sizeof(name));
                GetPlayerName(playerid,name2, sizeof(name2));
                if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "SERVER: User is not connected.");
                format(string, sizeof(string), "%s has been warned by %s %s [Reason: %s]",name2, aLevel(playerid), name, reason);
                SendClientMessageToAll(COLOR_RED,string);
                SendClientMessage(id, COLOR_RED, "SERVER: You warned by %s, please avoid to rulebreak again.", name);
   }

   }
           else
           {
                   SendClientMessage(playerid, COLOR_RED, "You are not admin level 1.");
       }
return 1;
}
Reply
#2

pawn Код:
CMD:warn(playerid, params[])
{
 if(PInfo[playerid][Level] >= 1)
 {
  new name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],string[128],id,reason[64];
  if(sscanf(params,"us[125]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /warn [playerid] [reason]");
  GetPlayerName(id,name, sizeof(name));
  GetPlayerName(playerid,name2, sizeof(name2));
  if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "SERVER: User is not connected.");
  format(string, sizeof(string), "%s has been warned by %s %s [Reason: %s]",name2, aLevel(playerid), name, reason);
  SendClientMessageToAll(COLOR_RED,string);
  SendClientMessage(id, COLOR_RED, "SERVER: You warned by %s, please avoid to rulebreak again.", name);
 }
 else SendClientMessage(playerid, COLOR_RED, "You are not admin level 1.");
 return 1;
}
Reply
#3

Why did u open 2 brackets after PInfo[playerid][Level]?
Check this:
Код:
CMD:warn(playerid, params[])
{
    if(PInfo[playerid][Level] >= 1) {
                new name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],string[128],id,reason[64];
                if(sscanf(params,"ui[125]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /warn [playerid] [reason]");
                GetPlayerName(id,name, sizeof(name));
                GetPlayerName(playerid,name2, sizeof(name2));
                if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "SERVER: User is not connected.");
                format(string, sizeof(string), "%s has been warned by %s %s [Reason: %s]",name2, aLevel(playerid), name, reason);
                SendClientMessageToAll(COLOR_RED,string);
                SendClientMessage(id, COLOR_RED, "SERVER: You warned by %s, please avoid to rulebreak again.", name);
   }
   else return SendClientMessage(playerid, COLOR_RED, "You are not admin level 1.");
   return 1;
}
Reply
#4

Nice Scripting (At All )
pawn Код:
CMD:warn(playerid, params[])
{
    if(PInfo[playerid][Level] >= 1)
    {
        new name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],string[128],id,reason[64];
        if(sscanf(params,"us[125]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /warn [playerid] [reason]");
        GetPlayerName(id,name, sizeof(name));
        GetPlayerName(playerid,name2, sizeof(name2));
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "SERVER: User is not connected.");
        format(string, sizeof(string), "%s has been warned by %s %s [Reason: %s]",name2, aLevel(playerid), name, reason);
        SendClientMessageToAll(COLOR_RED,string);
        format(string, sizeof(string),  "SERVER: You warned by %s, please avoid to rulebreak again.", name2);
        SendClientMessage(id, COLOR_RED, string);
   }
   else return SendClientMessage(playerid, COLOR_RED, "You are not admin level 1.");
   return 1;
}
Reply
#5

None of them worked.
Reply
#6

Server crash? Load crashdetect plugin.

By the way, since reason's size is 64, the size after the specifier must also be 64 and not 125:

pawn Код:
new id,reason[64];
if(sscanf(params,"rs[64]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /warn [playerid] [reason]");
Reply
#7

pawn Код:
CMD:warn(playerid, params[])
{
        if(PInfo[playerid][Level] < 1) SendClientMessage(playerid, COLOR_RED, "You are not Admin level 1.");
        new name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],string[128],id,reason[128];
        if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /warn [playerid] [reason]");
        GetPlayerName(id,name, sizeof(name));
        GetPlayerName(playerid,name2, sizeof(name2));
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "SERVER: User is not connected.");
        format(string, sizeof(string), "%s has been warned by %s %s [Reason: %s]",name2, PInfo[playerid][Level], name, reason);
        SendClientMessageToAll(COLOR_RED,string);
        format(string, sizeof(string),  "SERVER: You warned by %s, please avoid to rulebreak again.", name2);
        SendClientMessage(id, COLOR_RED, string);
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)