SA-MP Forums Archive
/freeze command crashing my script? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /freeze command crashing my script? (/showthread.php?tid=220716)



/freeze command crashing my script? - Kyle_Olsen - 04.02.2011

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);



Re: /freeze command crashing my script? - HyperZ - 04.02.2011

Can you please show us your full /freeze command?


Re: /freeze command crashing my script? - Kyle_Olsen - 04.02.2011

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;
}



Re: /freeze command crashing my script? - MrDeath537 - 04.02.2011

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;
}



Re: /freeze command crashing my script? - HyperZ - 04.02.2011

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;
}



Re: /freeze command crashing my script? - Kyle_Olsen - 04.02.2011

Works thanks