How to detect if player's in range of House/Business or Vehicle - 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: How to detect if player's in range of House/Business or Vehicle (
/showthread.php?tid=567478)
How to detect if player's in range of House/Business or Vehicle -
WhoIsYourDaddy - 14.03.2015
Hello guys, I'm trying to do a roleplay gamemode from strach, but I've been struggling with to detect if player's in range of a house, business or a vehicle. I have to get every house's, business's and vehicle's ID from database.
How do you want me to move on?
Re: How to detect if player's in range of House/Business or Vehicle -
Smileys - 14.03.2015
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint
https://sampwiki.blast.hk/wiki/GetPlayerPos
Re: How to detect if player's in range of House/Business or Vehicle -
WhoIsYourDaddy - 14.03.2015
Quote:
Originally Posted by Smileys
|
Yeah, say I used the 1st one. How can I get a h/b/v ID from database based on player's position?
Re: How to detect if player's in range of House/Business or Vehicle -
biker122 - 14.03.2015
You have to loop through the houses/business/vehicles, and get their positions and then compare the player's position with it (using the above mentioned functions)
Re: How to detect if player's in range of House/Business or Vehicle -
WhoIsYourDaddy - 14.03.2015
Quote:
Originally Posted by biker122
You have to loop through the houses/business/vehicles, and get their positions and then compare the player's position with it (using the above mentioned functions)
|
Can you give me an example please?
Re: How to detect if player's in range of House/Business or Vehicle -
CalvinC - 14.03.2015
You have to change it depending on your script, but just made this as an example:
pawn Code:
for(new i = 1; i < sizeof(HouseInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][PosX], HouseInfo[i][PosY], HouseInfo[i][PosZ]))
{
SendClientMessage(playerid, -1, "You are close to a house!");
}
}