Detect if player is in a vehicle -
Ananisiki - 28.02.2014
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..
Re: Detect if player is in a vehicle -
DeStunter - 28.02.2014
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.
Re: Detect if player is in a vehicle -
Ananisiki - 28.02.2014
For example,
pawn Код:
if(!IsPlayerInAnyVehicle(playerid))
{
//my rape code here
}
Re: Detect if player is in a vehicle -
DeStunter - 28.02.2014
yes, exactly like that.
Re: Detect if player is in a vehicle -
Ananisiki - 28.02.2014
Same..
Re: Detect if player is in a vehicle -
DeStunter - 28.02.2014
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.
Re: Detect if player is in a vehicle -
Stinged - 28.02.2014
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");
}
Re: Detect if player is in a vehicle -
Knekt - 28.02.2014
You want to prevent this?
Rapist : OnFoot
Target: InVehicle
Change
playerid to
targetid or whatever you named it.
Re: Detect if player is in a vehicle -
Ananisiki - 28.02.2014
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
Re: Detect if player is in a vehicle -
Stinged - 28.02.2014
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");
}