SA-MP Forums Archive
Why dose this do nothing? - 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: Why dose this do nothing? (/showthread.php?tid=96426)



Why dose this do nothing? - [mad]MLK - 08.09.2009

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(IsPlayerInVehicle(playerid, 520))
	{
	RemovePlayerFromVehicle(playerid);
	SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
	}
	return 1;
}
compiles fine just dosnt send that message or eject the player when they enter the vehicle 520 (hydra)


Re: Why dose this do nothing? - bubka3 - 08.09.2009

Here ya go
Quote:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == 520)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
}
return 1;
}




Re: Why dose this do nothing? - [mad]MLK - 08.09.2009

hmm thanks works but, hmmmm it dosnt eject the player from the vehicle :/


Re: Why dose this do nothing? - farse - 08.09.2009

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetVehicleModel(vehicleid) == 520)
  {
  new Float:poss[3];
  GetPlayerPos(playerid,poss[0],poss[1],poss[2];
  SetPlayerPos(playerid,poss[0],poss[1],poss[2]);
  SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
  }
  return 1;
}
for as still is not in the car.


Re: Why dose this do nothing? - Gappy - 08.09.2009

You could do this

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new Float:px, Float:py, Float:pz;
  if(GetVehicleModel(vehicleid) == 520)
  {
    GetPlayerPos(playerid, px, py, pz);
    SetPlayerPos(playerid, px, py, pz+3);
    SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
  }
  return 1;
}



Re: Why dose this do nothing? - Abernethy - 08.09.2009

Do what Gappy said.
See, OnPlayerEnterVehicle is called when you press enter, or f to enter the vehicle.
If you want to eject them so they enter, then leave use OnPlayerStateChange.


Re: Why dose this do nothing? - Gappy - 08.09.2009

Or do it this way.

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
  if(newstate == PLAYER_STATE_DRIVER)
  {
    if(IsPlayerInVehicle(playerid, 520))
    {
       RemovePlayerFromVehicle(playerid);
      SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
    }
  }
  return 1;
}



Re: Why dose this do nothing? - Mowgli - 08.09.2009

What i use to do is TogglePlayerControllability to False then True, this works the same as getPlayerPos and Setplayerpos but probaly not as effective, lol


Re: Why dose this do nothing? - MenaceX^ - 08.09.2009

Quote:
Originally Posted by Gappy
Or do it this way.

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
  if(newstate == PLAYER_STATE_DRIVER)
  {
    if(IsPlayerInVehicle(playerid, 520))
    {
       RemovePlayerFromVehicle(playerid);
      SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
    }
  }
  return 1;
}
That's a stupid code.
IsPlayerInVehicle checks the VEHICLE ID and not the MODEL ID. So who uses vehicle id 520 will just be kicked from the vehicle with the reason "Sorry but flying a hydra bla bla" while it might be not a hydra!


Re: Why dose this do nothing? - Gappy - 08.09.2009

Oops, my bad.

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
  new vehicleid = GetPlayerVehicleID(playerid);
  if(newstate == PLAYER_STATE_DRIVER)
  {
    if(GetVehicleModel(vehicleid) == 520)
    {
      RemovePlayerFromVehicle(playerid);
      SendClientMessage(playerid, 0xFFFFFFFF, "Sorry but flying a hydra is currently unavalible!");
    }
  }
  return 1;
}