get vehicleid before enter?
#1

im trying to make it so when player try to enter a car, if its a specific car it doesnt let him enter, but my problem is i dont know how to get the vehicleid of the car hes trying to enter. any idea?

somethink like

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
  if(newstate == PLAYER_STATE_ENTER_VEHICLE_DRIVER)
  {
    new vehicleid = GetPlayerVehicleID(playerid); //but of course not known yet since not in it
    if(vehicleid == testcar1)
    {
      SendClientMessage(playerid,COLOR_BRIGHTRED,"LOCKED..");
      //....
    }
  }
  return 1;
}
seems like it should be an easy solution but im stuck. just need help with getting the vehicle part, any help much appreciated thanks.
Reply
#2

There is an entire callback dedicated to this purpose.

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

new Floatx,Floaty,Floatz;
GetPlayerPos(playerid,px,py,pz);
SetPlayerPos(playerid,px,py,pz);
Reply
#4

Quote:
Originally Posted by ledzep
There is an entire callback dedicated to this purpose.

https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle
thx for fast reply, but my intention to keep him from even being able to enter the car if you know what i mean, so when he is at state 5, trying to enter, it keep him from enter, so i dont think i can use that callback fro this correct?
Reply
#5

new Floatx,Floaty,Floatz;
GetPlayerPos(playerid,px,py,pz);
SetPlayerPos(playerid,px,py,pz);
Reply
#6

Quote:
Originally Posted by yezizhu
new Floatx,Floaty,Floatz;
GetPlayerPos(playerid,px,py,pz);
SetPlayerPos(playerid,px,py,pz);
this have nothing to do with the question?
Reply
#7

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == ledzepCar){
        SendClientMessage(playerid, COLOR_RED, "NOT TODAY MOTHERFUCKER!");
        SetVehicleParamsForPlayer(vehicleid, playerid, 0, 1); // Lock the car, thereby pwning playerid
    }
}
Or you could 'slap' them.
Reply
#8

Quote:
Originally Posted by happyface
Quote:
Originally Posted by yezizhu
new Floatx,Floaty,Floatz;
GetPlayerPos(playerid,px,py,pz);
SetPlayerPos(playerid,px,py,pz);
this have nothing to do with the question?
NO, it will keep the player from entering the vehicle.
Reply
#9

Quote:
Originally Posted by ledzep
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == ledzepCar){
        SendClientMessage(playerid, COLOR_RED, "NOT TODAY MOTHERFUCKER!");
        SetVehicleParamsForPlayer(vehicleid, playerid, 0, 1); // Lock the car, thereby pwning playerid
    }
}
Or you could 'slap' them.
hey thanks! SetVehicleParamsForPlayer works perfect for what i needed, had never used this before.
Reply
#10

Quote:
Originally Posted by happyface
Quote:
Originally Posted by yezizhu
new Floatx,Floaty,Floatz;
GetPlayerPos(playerid,px,py,pz);
SetPlayerPos(playerid,px,py,pz);
this have nothing to do with the question?
This will set the player pos to where he was just when he pressed enter, disabling the 'enter vehicle' animation.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)