PDA

View Full Version : exit command


vassilis
19/03/2014, 09:36 AM
Hello lads so here is my exit command which as i realised its not pretty efficient..
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??

MP2
19/03/2014, 09:50 AM
Your if() structure is completely wrong.


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:


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.

azzerking
19/03/2014, 09:50 AM
1st make sure the cordinates are correct, 2nd try increasing the radius from 2.0 to 5.0 and try again

vassilis
19/03/2014, 09:57 AM
Your if() structure is completely wrong.


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:


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