SA-MP Forums Archive
Server crash after using this CMD - 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)
+--- Thread: Server crash after using this CMD (/showthread.php?tid=486560)



Server crash after using this CMD - barts - 09.01.2014

PHP код:
CMD:aduty(playeridparams[])
{
    new 
string[128];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(
PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    if(!
aDuty[playerid])
    {
        
format(stringsizeof(string), "AdmWarn: %s has went on admin duty."RPN(playerid));
        
SendAdminMessage(COLOR_YELLOW1string);
        
aDuty[playerid] = 1;
         
SetPlayerName(playeridPlayerInfo[playerid][pAdminName]);
        
SetPlayerHealth(playerid999999999);
        
format(stringsizeof(string), "%s"RPALN(playerid));
        if(
IsValidDynamic3DTextLabel(aDutyText[playerid]))  DestroyDynamic3DTextLabel(aDutyText[playerid]);
     if(
PlayerInfo[playerid][pAdmin] == 1aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_LIGHTGREEN00, -2025playerid);
     if(
PlayerInfo[playerid][pAdmin] == 2aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_LIME00, -2025playerid);
     if(
PlayerInfo[playerid][pAdmin] == 3aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_YELLOW00, -2025playerid);
     if(
PlayerInfo[playerid][pAdmin] == 4aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_ORANGE00, -2025playerid);
     if(
PlayerInfo[playerid][pAdmin] == 5aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_RED00, -2025playerid);
     if(
PlayerInfo[playerid][pAdmin] == 6aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_DARKRED00, -2025playerid);
     if(
PlayerInfo[playerid][pAdmin] == 7aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_DARKRED00, -2025playerid);
        if(
PlayerInfo[playerid][pAdmin] == 8aDutyText[playerid] = CreateDynamic3DTextLabel(stringCOLOR_LIGHTRED00, -2025playerid);
        
Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABELaDutyText[playerid] , E_STREAMER_ATTACH_OFFSET_Z0.25);
    }
    else
    {
   if(
Spec[playerid]) return SendClientMessage(playeridCOLOR_GREY"You can't go off admin duty while spectating someone.");
        
aDuty[playerid] = 0;
        
SetPlayerHealth(playerid100);
        
format(stringsizeof(string), "AdmWarn: %s has went off admin duty."RPN(playerid));
        
SendAdminMessage(COLOR_YELLOW1string);
        
DestroyDynamic3DTextLabel(aDutyText[playerid]);
    }
    return 
1;

When the player AdminName is for example:Bart the server crashes, if it is 123 the server dont crash


Re: Server crash after using this CMD - Eth - 09.01.2014

pawn Код:
CMD:aduty(playerid, params[])
{
    new string[128];
       if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!aDuty[playerid])
    {
        format(string, sizeof(string), "AdmWarn: %s has went on admin duty.", RPN(playerid));
        SendAdminMessage(COLOR_YELLOW, 1, string);
        aDuty[playerid] = 1;
         SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
        SetPlayerHealth(playerid, 999999999);
        format(string, sizeof(string), "%s", RPALN(playerid));
        if(IsValidDynamic3DTextLabel(aDutyText[playerid]))  DestroyDynamic3DTextLabel(aDutyText[playerid]);
     if(PlayerInfo[playerid][pAdmin] == 1) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_LIGHTGREEN, 0, 0, -20, 25, playerid);
     else if(PlayerInfo[playerid][pAdmin] == 2) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_LIME, 0, 0, -20, 25, playerid);
     else if(PlayerInfo[playerid][pAdmin] == 3) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, 0, 0, -20, 25, playerid);
     else if(PlayerInfo[playerid][pAdmin] == 4) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_ORANGE, 0, 0, -20, 25, playerid);
     else if(PlayerInfo[playerid][pAdmin] == 5) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_RED, 0, 0, -20, 25, playerid);
     else  if(PlayerInfo[playerid][pAdmin] == 6) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_DARKRED, 0, 0, -20, 25, playerid);
     else if(PlayerInfo[playerid][pAdmin] == 7) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_DARKRED, 0, 0, -20, 25, playerid);
      else if(PlayerInfo[playerid][pAdmin] == 8) aDutyText[playerid] = CreateDynamic3DTextLabel(string, COLOR_LIGHTRED, 0, 0, -20, 25, playerid);
        Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, aDutyText[playerid] , E_STREAMER_ATTACH_OFFSET_Z, 0.25);
    }
    else
    {
   if(Spec[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You can't go off admin duty while spectating someone.");
        aDuty[playerid] = 0;
        SetPlayerHealth(playerid, 100);
        format(string, sizeof(string), "AdmWarn: %s has went off admin duty.", RPN(playerid));
        SendAdminMessage(COLOR_YELLOW, 1, string);
        DestroyDynamic3DTextLabel(aDutyText[playerid]);
    }
    return 1;
}



Re: Server crash after using this CMD - barts - 09.01.2014

Its the same code


Re: Server crash after using this CMD - Eth - 09.01.2014

no , check the "else " try it , it may work


Re: Server crash after using this CMD - barts - 09.01.2014

dont work.


Re: Server crash after using this CMD - PowerPC603 - 09.01.2014

Can you put some printf statements between every line?
Then you can see which line is printed last and where it crashes exactly.


Re: Server crash after using this CMD - barts - 09.01.2014

I am newb scripter....


Re: Server crash after using this CMD - offon - 09.01.2014

So what?


Re: Server crash after using this CMD - Konstantinos - 09.01.2014

Load crashdetect plugin.
Compile with debug info: https://github.com/Zeex/samp-plugin-...ith-debug-info

Re-compile your scripts, run the server and execute that command. If it prints anything in the server log, then post it here.

My guess is that the native SetPlayerName crashes the server:
pawn Код:
SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
because PlayerInfo[playerid][pAdminName] is NULL but let's wait for the results of crashdetect to be sure.


Re: Server crash after using this CMD - SandKing94 - 09.01.2014

I think that the error line is
SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);