Is it possible to get playerid from a vehicleid - 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: Is it possible to get playerid from a vehicleid (
/showthread.php?tid=587568)
Is it possible to get playerid from a vehicleid -
WingedFrostWolf - 31.08.2015
Hello, so my question is if it is possible to get the driver playerid from the vehicleid of the vehicle he is driving?I hope you understood what I meant to say. Thanks for reading.
Re: Is it possible to get playerid from a vehicleid -
Jefff - 31.08.2015
Yes, search GetVehicleDriver
http://forum.sa-mp.com/search.php?searchid=9984618
Re: Is it possible to get playerid from a vehicleid -
Vince - 31.08.2015
Use a player loop in conjunction with IsPlayerInVehicle. There are probably more efficient ways, if you tend to use this a lot.
Re: Is it possible to get playerid from a vehicleid -
xVIP3Rx - 31.08.2015
I would think of setting a bool to true whenever a player gets in a vehicle and false when he gets out, this way
pawn Код:
new Driver[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Driver[playerid] == false;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
Driver[playerid] == true;
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
Driver[playerid] == false;
}
return 1;
}
IsDriver(playerid)
{
return Driver[playerid];
}