exit command
#1

Hello lads so here is my exit command which as i realised its not pretty efficient..
pawn Код:
CMD:exit(playerid,params[])
{
    #pragma unused params
    if(!IsPlayerInRangeOfPoint(playerid, 2.0, 1456.424682, -987.705749, 996.105041)) return SendClientMessage(playerid,-1,""COL_RED"ERROR"COL_WHITE":You have to be near the exit point to exit LS BANK!");
    {
    SetPlayerPos(playerid,1791.145019 +2, -1777.106567 +2, 13.544099 +1);
    }
    if(!IsPlayerInRangeOfPoint(playerid, 2.0, 1474.0437, -1751.1372, 3285.2859)) return SendClientMessage(playerid,-1,""COL_RED"ERROR"COL_WHITE":You have to be near the exit point to exit LSPD!");
    {
    SetPlayerPos(playerid,1554.307495 -2, -1675.323852 -1, 15.770359);
    }
    return 1;
}
But anyway the problem is that when i try to exit LSPD it says you are not near the exit point of LS BANK
So how i could make it for each position certainly??
Reply
#2

Your if() structure is completely wrong.

pawn Код:
CMD:exit(playerid, params[])
{
    #pragma unused params
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 1456.424682, -987.705749, 996.105041)) // LS Bank
    {
        SetPlayerPos(playerid, 1791.145019 +2, -1777.106567 +2, 13.544099 +1);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 2.0, 1474.0437, -1751.1372, 3285.2859)) // LSPD
    {
        SetPlayerPos(playerid, 1554.307495 -2, -1675.323852 -1, 15.770359);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR"COL_WHITE": You are not near an exit point.");
    }
    return 1;
}
Also, always put a space after commas, it helps make your code clearer to read.
Also, this line:

pawn Код:
SendClientMessage(playerid,-1,""COL_RED"ERROR"COL_WHITE":You have to be near the exit point to exit LSPD!");
You're wasting character space by using colour embedding at the start. Remove that and just set the colour message to red.
Reply
#3

1st make sure the cordinates are correct, 2nd try increasing the radius from 2.0 to 5.0 and try again
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
Your if() structure is completely wrong.

pawn Код:
CMD:exit(playerid, params[])
{
    #pragma unused params
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 1456.424682, -987.705749, 996.105041)) // LS Bank
    {
        SetPlayerPos(playerid, 1791.145019 +2, -1777.106567 +2, 13.544099 +1);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 2.0, 1474.0437, -1751.1372, 3285.2859)) // LSPD
    {
        SetPlayerPos(playerid, 1554.307495 -2, -1675.323852 -1, 15.770359);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR"COL_WHITE": You are not near an exit point.");
    }
    return 1;
}
Also, always put a space after commas, it helps make your code clearer to read.
Also, this line:

pawn Код:
SendClientMessage(playerid,-1,""COL_RED"ERROR"COL_WHITE":You have to be near the exit point to exit LSPD!");
You're wasting character space by using colour embedding at the start. Remove that and just set the colour message to red.
Ye indeed i changed it to isplayerinrange of point and i will set an else at the bottom thats what i thought 2 minutes before implemented and worked just forgot to edit the post to [solved] thanks anyway mp2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)