SA-MP Forums Archive
[Include] [Function]IsPlayerInRange - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] [Function]IsPlayerInRange (/showthread.php?tid=260405)



[Function]IsPlayerInRange - CoaPsyFactor - 08.06.2011

Hello,

So this is nothing like IsPlayerInRangeOfPoint, well it is, but this function is looking X and Y Coordinates. There is nothing like Float:range. Here is the code.

pawn Код:
stock IsPlayerInRange(Float:Start_X, Float:Start_Y, Float:End_X, Float:End_Y, playerid){
    new Float:Current_X, Float:Current_Y, Float:Current_Z;
    GetPlayerPos(playerid, Current_X, Current_Y, Current_Z);
    if(Start_X >= Current_X && End_X <= Current_X && Start_Y <= Current_Y && End_Y >= Current_Y){
        return 1;
    }else{
        return 0;
    }
}

Start_X must always be higher value than End_X, and Start_Y smaller than End_Y...



Re: [Function]IsPlayerInRange - MicroD - 08.06.2011

Useful Functions


Re: [Function]IsPlayerInRange - Gamer_Z - 08.06.2011

Wow you have just made IsPlayerInArea which has been made several years ago!
https://sampwiki.blast.hk/wiki/Useful_Fu...IsPlayerInArea


Re: [Function]IsPlayerInRange - CoaPsyFactor - 08.06.2011

lol, I didn't know that function exists , I made this one for my rp script, cuz i need it for /call function to check does player have signal


Re: [Function]IsPlayerInRange - Gamer_Z - 08.06.2011

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
lol, I didn't know that function exists , I made this one for my rp script, cuz i need it for /call function to check does player have signal
Hmm I think you are not that good at english because if you needed it without writing on yourself you would find it , but no problem :P At least you can script


Re: [Function]IsPlayerInRange - CoaPsyFactor - 08.06.2011

But as I see there is no code for that function, and Notepad++ can't compile it cuz it says rp.pwn(4512) : error 017: undefined symbol "IsPlayerInArea"


Re: [Function]IsPlayerInRange - CoaPsyFactor - 08.06.2011

Quote:
Originally Posted by gamer_Z
Посмотреть сообщение
Hmm I think you are not that good at english because if you needed it without writing on yourself you would find it , but no problem :P At least you can script
I am good at English but I wasn't looking for it, it was easier to write one , and you can bet I can script, right now I am working on my roleplay script, it is fu****g huge, but i have to work on it lot more


Re: [Function]IsPlayerInRange - Mike Garber - 08.06.2011

IsPlayerInArea is the correct name for this function, NOT IsPlayerInRange.
This function checks if you're within the specified Square-area, not if you're simply <= X meters away from something.


Re: [Function]IsPlayerInRange - CoaPsyFactor - 09.06.2011

i know that, but when i tried that function yesterday it said rp.pwn(4512) : error 017: undefined symbol "IsPlayerInArea" , and i scripted my function and i called it IsPlayerInRange, if you don't like name of the functon you can change it