How to detect if player's in range of House/Business or Vehicle
#1

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?
Reply
#2

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint

https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint

https://sampwiki.blast.hk/wiki/GetPlayerPos
Reply
#3

Yeah, say I used the 1st one. How can I get a h/b/v ID from database based on player's position?
Reply
#4

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)
Reply
#5

Quote:
Originally Posted by biker122
View Post
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?
Reply
#6

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!");
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)