Detect if player is in a vehicle
#1

How do i detect if the nearest player is in a vehicle? I have two commands there you don't have to type in the ID, but if the nearest player is in a car, i can use it on him but i don't want to, its like:

Player1 (1) Has Raped Player2 (2)

If he isn't close enough i get this message;
"No one close enough to rape"

So if the player is in a vehicle, i want the player to get that message..
Reply
#2

IsPlayerInAnyVehicle(player)

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

you can use that function to check the player that your nearest player function returns as the player.
Reply
#3

For example,
pawn Код:
if(!IsPlayerInAnyVehicle(playerid))
    {
//my rape code here
    }
Reply
#4

yes, exactly like that.
Reply
#5

Same..
Reply
#6

post your rape command, your not using the function in the right spot, and I can't help you if I can't see what you are doing wrong.
Reply
#7

From what I read, I think you meant, if the (RAPIST) was a vehicle, he can't rape anyone.

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
{
    return SendClientMessage(playerid, COLOR, "No one is close enough to rape");
}
Reply
#8

You want to prevent this?
Rapist : OnFoot
Target: InVehicle


Change playerid to targetid or whatever you named it.
Reply
#9

I mean if the rapist is on foot, he can rape people who is in a car, i don't want it like that, if the rapist is on foot and the nearest player is in a vehicle, he'll get that error message (no one close enough to rape)

EDIT: the player who is in a vehicle, he will be count as no one is near
Reply
#10

If you're using a command, like /rape [id/name]

Do this:

pawn Код:
if(IsPlayerInAnyVehicle(playerid)) // Replace the 'playerid' with the id you want
{
    return SendClientMessage(playerid, COLOR, "No one is close enough to rape");
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)