SA-MP Forums Archive
OnPlayerEnter vehicle problem. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerEnter vehicle problem. (/showthread.php?tid=124955)



OnPlayerEnter vehicle problem. - bartje01 - 01.02.2010

Hey, I want that if you join a LSPD car you are getting a red name, I made something and it doesn't give any errors/warnings.
But It just doesn't work. Can someone help me? Like giving an example

This is what I have:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(playerid) == 596)
if(GetPlayerColor(playerid) == 0xFFFFFFAA)
SendClientMessage(playerid, 0x33AA33AA, "You entered a police vehicle, you are wanted now");
if(GetPlayerColor(playerid) == 0xFFFFFFAA)
if(GetVehicleModel(playerid) == 596)
SetPlayerColor(playerid,0xAA3333AA);



return 1;
}


GReets




Re: OnPlayerEnter vehicle problem. - Correlli - 01.02.2010

Use OnPlayerStateChange callback and check if the old state is on foot and new state is driver/passenger. OnPlayerEnterVehicle callback will be called even if player cancels the vehicle entry + learn some basics first.


Re: OnPlayerEnter vehicle problem. - Nakash - 01.02.2010

Try this

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetVehicleModel(vehicleid) == 596)
  if(GetPlayerColor(playerid) == 0xFFFFFFAA)
  SendClientMessage(playerid, 0x33AA33AA, "You entered a police vehicle, you are wanted now");
  if(GetPlayerColor(playerid) == 0xFFFFFFAA)
  if(GetVehicleModel(vehicleid) == 596)
  SetPlayerColor(playerid,0xAA3333AA);
  return 1;
}



Re: OnPlayerEnter vehicle problem. - bartje01 - 01.02.2010

Quote:
Originally Posted by Don Correlli
Use OnPlayerStateChange callback and check if the old state is on foot and new state is driver/passenger. OnPlayerEnterVehicle callback will be called even if player cancels the vehicle entry + learn some basics first.
Yes well, I don't really understand that :P I also can't follow tutorials. That is a bad part of me. I learn scriptnig with examples. I always look back at my scripts and remember it, so can you please make an example for me?


Re: OnPlayerEnter vehicle problem. - Correlli - 01.02.2010

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
  if(oldstate == PLAYER_STATE_ONFOOT && (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER))
  {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 596)
    {
      SendClientMessage(playerid, 0x33AA33AA, "You entered a police vehicle, you are wanted now");
      SetPlayerColor(playerid, 0xAA3333AA);
    }
  }
  return true;
}



Re: OnPlayerEnter vehicle problem. - Nakash - 01.02.2010

If you want to use OnPlayerStateChange here is an example:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER) // IF THE PLAYER'S NEW STATE IS A DRIVER
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 596)
{
SendClientMessage(playerid,0x33AA33AA,"You entered to a police vehicle!");
}
}



Re: OnPlayerEnter vehicle problem. - bartje01 - 01.02.2010

Thanks guys