SA-MP Forums Archive
command crashes server - 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: command crashes server (/showthread.php?tid=159457)



command crashes server - Kar - 13.07.2010

help>?

pawn Код:
CMD:cuff(playerid, params[])
{
    new id, Float:x, Float:y, Float:z,Float:angle, idname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF00AAFF, "*USAGE: /cuff [playerid / part of name]");
    else if(gTeam[playerid] != TEAM_COPS) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You are not a Police Officer!");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: Player is not connected,Invalid playerid Or Is Yourself!");
    else if(IsPlayerInRangeOfPoint(id, 10, x, y, z)) return SendClientMessage(playerid, COLOR_GREY, "Player is not close enough!");
    else
    {
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(id, idname, sizeof(idname));
        GetPlayerPos(id,x,y,z);
        GetPlayerFacingAngle(id, angle);

        TogglePlayerControllable(id,false);
        SendClientMessage(playerid, COLOR_GREY, "You Have Cuffed Citizen %s(%d)!");
        SendClientMessage(id, COLOR_GREY, "You've Been Cuffed By Officer %s(%d)!");
        SetPlayerPos(playerid,x+0.5,y,z);
        SetPlayerFacingAngle(playerid, angle);
        OnePlayAnim(playerid, "PYTHON", "python_crouchreload", 2.0, 0, 0, 0, 0, 0);
        IsAnim[playerid] = 1;
    }
    return 1;
}

CMD:uncuff(playerid, params[])
{
    new id, Float:x, Float:y, Float:z, idname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF00AAFF, "*USAGE: /uncuff [playerid / part of name]");
    else if(gTeam[playerid] != TEAM_COPS) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You are not a Police Officer!");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: Player is not connected,Invalid playerid Or Is Yourself!");
    else if(IsPlayerInRangeOfPoint(id, 100, x, y, z)) return SendClientMessage(playerid, COLOR_GREY, "Player is not close enough!");
    else
    {
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(id, idname, sizeof(idname));

        TogglePlayerControllable(id,true);
        SendClientMessage(playerid, COLOR_GREY, "You Have Cuffed Citizen %s(%d)!");
        SendClientMessage(id, COLOR_GREY, "You've Been Cuffed By Officer %s(%d)!");
        IsAnim[playerid] = 0;
    }
    return 1;
}



Re: command crashes server - Hiddos - 13.07.2010

Which of those 2 commands crash the server?


Re: command crashes server - Kar - 13.07.2010

well i cant test the uncuff but the cuff crashes idk about the uncuff


Re: command crashes server - Mauzen - 13.07.2010

Dont know if it can cause a crash, but those lines wont work as you want them to:

pawn Код:
SendClientMessage(playerid, COLOR_GREY, "You Have Cuffed Citizen %s(%d)!");
        SendClientMessage(id, COLOR_GREY, "You've Been Cuffed By Officer %s(%d)!");
the %s and %d have to be replaced first, using format, maybe samp cant handle them in an unformated message.

pawn Код:
new text[64];
format(text, 64, "You Have Cuffed Citizen %s(%d)!", idname, id);
SendClientMessage(playerid, COLOR_GREY, text);
format(text, 64, "You've Been Cuffed By Officer %s(%d)!", name, playerid);
SendClientMessage(id, COLOR_GREY, text);