SA-MP Forums Archive
Problem! - 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: Problem! (/showthread.php?tid=344939)



Problem! - Face9000 - 23.05.2012

Hello,i've this IsPlayerInRangeOfPoint check in my command.

pawn Код:
if(!IsPlayerInRangeOfPoint( playerid, 7.0, -1955.7682, 306.0241, 41.0471 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -2051.8413, 86.1440, 28.3977 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -2141.5591, -256.7738, 40.7195 )&& !IsPlayerInRangeOfPoint( playerid, 7.0, 379.6270,-8.7878,1001.8516 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 216.6623,-100.1878,1005.2578 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 379.7124,-59.6829,1001.5078 ) ))
    if(!IsPlayerInRangeOfPoint( playerid, 7.0, -2031.0654,-117.4350,1035.1719 && !IsPlayerInRangeOfPoint( playerid, 7.0, 365.1240,-6.7055,1001.8516 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -201.7283,-7.8537,1002.2734 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 296.7915,-35.3443,1001.5156 )))
But seems not work when i compile:

3349 : error 029: invalid expression, assumed zero
3349 -- 3350 : warning 215: expression has no effect
3350 : error 001: expected token: ";", but found "if"
3350 : warning 213: tag mismatch

What's wrong?


Re: Problem! - Faisal_khan - 23.05.2012

You had an extra bracket:
pawn Код:
if(!IsPlayerInRangeOfPoint( playerid, 7.0, -1955.7682, 306.0241, 41.0471 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -2051.8413, 86.1440, 28.3977 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -2141.5591, -256.7738, 40.7195 )&& !IsPlayerInRangeOfPoint( playerid, 7.0, 379.6270,-8.7878,1001.8516 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 216.6623,-100.1878,1005.2578 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 379.7124,-59.6829,1001.5078 ) )
    if(!IsPlayerInRangeOfPoint( playerid, 7.0, -2031.0654,-117.4350,1035.1719 && !IsPlayerInRangeOfPoint( playerid, 7.0, 365.1240,-6.7055,1001.8516 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -201.7283,-7.8537,1002.2734 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 296.7915,-35.3443,1001.5156 )))



Re: Problem! - Face9000 - 23.05.2012

Thansk,but now i get tag mismatch here:

pawn Код:
if(!IsPlayerInRangeOfPoint( playerid, 7.0, -2031.0654,-117.4350,1035.1719 && !IsPlayerInRangeOfPoint( playerid, 7.0, 365.1240,-6.7055,1001.8516 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -201.7283,-7.8537,1002.2734 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 296.7915,-35.3443,1001.5156 )))return SendClientMessage( playerid, red, "You are not at a robbery location." );



Re: Problem! - leonardo1434 - 23.05.2012

pawn Код:
if(!IsPlayerInRangeOfPoint( playerid, 7.0, -2031.0654,-117.4350,1035.1719) && (!IsPlayerInRangeOfPoint( playerid, 7.0, 365.1240,-6.7055,1001.8516 ) && (!IsPlayerInRangeOfPoint( playerid, 7.0, -201.7283,-7.8537,1002.2734 ) && (!IsPlayerInRangeOfPoint( playerid, 7.0, 296.7915,-35.3443,1001.5156 ))))return SendClientMessage( playerid, red, "You are not at a robbery location." );



Re: Problem! - Faisal_khan - 23.05.2012

Here you are missing a bracket and you had an extra bracket too:
pawn Код:
if(!IsPlayerInRangeOfPoint( playerid, 7.0, -2031.0654,-117.4350,1035.1719) && !IsPlayerInRangeOfPoint( playerid, 7.0, 365.1240,-6.7055,1001.8516 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, -201.7283,-7.8537,1002.2734 ) && !IsPlayerInRangeOfPoint( playerid, 7.0, 296.7915,-35.3443,1001.5156 ))return SendClientMessage( playerid, red, "You are not at a robbery location." );



Re: Problem! - Vince - 23.05.2012

Consider using a constant array and a loop. Will be much easier to maintain.


Re: Problem! - Face9000 - 23.05.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Consider using a constant array and a loop. Will be much easier to maintain.
Can you give me an example?The IsPlayerInRangeOfPoint is called when a player executes the /rob command.

@Faisal_khan,thanks,i fixed.


Re: Problem! - Vince - 23.05.2012

pawn Код:
new const stock Float:robberyPlaces[][3] = {
    {-2031.0654, -117.4350, 1035.1719},
    {365.1240, -6.7055, 1001.8516},
    // you get the point
    {-201.7283,-7.8537,1002.2734} // < no comma on the last one
};
pawn Код:
for(new i; i < sizeof(robberyPlaces); i++)
{
    if(IsPlayerInRangeOfPoint(playerid, 7.0, robberyPlaces[i][0], robberyPlaces[i][1], robberyPlaces[i][2])
    {
        // Do whatever you need to do
       
        break; // exit the loop and continue with code outside of loop
        // or you can put return instead if you want to end the function
    }
}



Re: Problem! - Face9000 - 23.05.2012

Thanks.


Re: Problem! - milanosie - 23.05.2012

offtopic: Please use a better title?

PROBLEM, isn't going to give us any indication of what you need help with