/freeze command crashing my script?
#1

Alright, I've got a /freeze command, but each time I perform it (WITH PARAMS, WITHOUT IT JUST TELLS ME THE USAGE) the server window shuts down.

Here is the content between the else from the sscanf and the end of that.

pawn Код:
TogglePlayerControllable(id, 0);
                   new string[128];
                   format(string, sizeof(string), "AdmCmd: %s has been frozen by %s", GetPlayerName(id), GetPlayerName(playerid));
                   SendClientMessageToAll(ADMINORANGE, string);
Reply
#2

Can you please show us your full /freeze command?
Reply
#3

Sure.

pawn Код:
command(freeze, playerid, params[]){
     new id;
          if(Player[playerid][AdminLevel] >= 1){

             if(sscanf(params, "d", id)){
                   SendClientMessage(playerid, WHITE, "USAGE: /freeze [playerid]");
             }else{
                   TogglePlayerControllable(id, 0);
                   new string[128];
                   format(string, sizeof(string), "AdmCmd: %s has been frozen by %s", GetPlayerName(id), GetPlayerName(playerid));
                   SendClientMessageToAll(ADMINORANGE, string);
             }
           }else{
               SendClientMessage(playerid, RED, "You are not allowed to use this command");
           }
           return 1;
}
Reply
#4

GetPlayerName doesn't returns the player name, here's the fixed command:

pawn Код:
command(freeze, playerid, params[]){
     new id;
          if(Player[playerid][AdminLevel] >= 1){

             if(sscanf(params, "d", id)){
                   SendClientMessage(playerid, WHITE, "USAGE: /freeze [playerid]");
             }else{
                   TogglePlayerControllable(id, 0);
                   new string[128], name[2][MAX_PLAYER_NAME];
                   GetPlayerName(id, name[0], MAX_PLAYER_NAME);
                   GetPlayerName(playerid, name[1], MAX_PLAYER_NAME);
                   format(string, sizeof(string), "AdmCmd: %s has been frozen by %s", name[0], name[1]);
                   SendClientMessageToAll(ADMINORANGE, string);
             }
           }else{
               SendClientMessage(playerid, RED, "You are not allowed to use this command");
           }
           return 1;
}
Reply
#5

Or that :P
Command:
pawn Код:
command(freeze, playerid, params[])
{
    new id, string[128];
    if(Player[playerid][AdminLevel] >= 1) return SendClientMessage(playerid, RED, "You are not allowed to use this command");
    if(sscanf(params, "d", id)) return SendClientMessage(playerid, WHITE, "USAGE: /freeze [playerid]");
    TogglePlayerControllable(id, 0);
    format(string, sizeof(string), "AdmCmd: %s has been frozen by %s", pName(id), pName(playerid));
    SendClientMessageToAll(ADMINORANGE, string);
    return 1;
}
Somewhere in ur script:
pawn Код:
stock pName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Reply
#6

Works thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)