SA-MP Forums Archive
GetPlayerVehicleID(playerid); not working. - 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: GetPlayerVehicleID(playerid); not working. (/showthread.php?tid=86846)



GetPlayerVehicleID(playerid); not working. - Anwix - 16.07.2009

I'm creating a menu, so when people get in certain cars, a menu pops up saying the car is avalible to buy.
Thing is when it enter the car, no menu pops up.
Heres my code:

THIS IS MY CAR // VEHICLE ID 45.
Код:
AddStaticVehicle(562,1979.7543,2059.4924,10.4803,180.4118,92,1); // ELEGY_CARSHOP   45
THIS IS MY MENU // new Menu:Elegy; is at the top of my script, yes.
Код:
Elegy = CreateMenu("Elegy", 2, 200.0, 100.0, 300.0, 300.0);
AddMenuItem(Elegy, 0, "Buy Car");
AddMenuItem(Elegy, 1, "$85000");
AddMenuItem(Elegy, 0, "Exit");
THIS IS 'OnPlayerEnterVehicle'
Код:
if (GetPlayerVehicleID(playerid) == 45)
{
TogglePlayerControllable(playerid, 0);
ShowMenuForPlayer(Elegy, playerid);
SetCameraBehindPlayer(playerid);
}
This doesn't seem to work, and i am out of idea's why this isnt working.
Hopefully someone could point me in the correct place where i must be going wrong.


Re: GetPlayerVehicleID(playerid); not working. - saiberfun - 16.07.2009

shoow the whole function that its in


Re: GetPlayerVehicleID(playerid); not working. - Anwix - 16.07.2009

if you mean the OnPlayerEnterVehicle here it is :

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if (!ispassenger)
	{
		if (GetPlayerVehicleID(playerid) == 45)
		{
		  TogglePlayerControllable(playerid, 0);
		  ShowMenuForPlayer(Elegy, playerid);
		  SetCameraBehindPlayer(playerid);
		}
	}
	return 0;
}



Re: GetPlayerVehicleID(playerid); not working. - saiberfun - 16.07.2009

well put
new menu:Elegy;
at the top of the script cuz if there none menu nutin can be opened
but i guess u added new Elegy;
then just add the menu: to it


Re: GetPlayerVehicleID(playerid); not working. - Anwix - 16.07.2009

Quote:
Originally Posted by Anwix
THIS IS MY MENU // new Menu:Elegy; is at the top of my script, yes.
This was my first post.


Re: GetPlayerVehicleID(playerid); not working. - saiberfun - 16.07.2009

hmm sry didn't see cuz u didn't post it in the pawncode
but i can't seem why it's not workin...


Re: GetPlayerVehicleID(playerid); not working. - Anwix - 16.07.2009

i'll also add its not just the menu whats not working, its not freezing the player, or setting the camera behind him.
im really confused,


Re: GetPlayerVehicleID(playerid); not working. - abhinavdabral - 16.07.2009

Try this
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if (!ispassenger)
    {
        if (vehicleid==45){
          TogglePlayerControllable(playerid, 0);
          ShowMenuForPlayer(Elegy, playerid);
          SetCameraBehindPlayer(playerid);
          return 1;
        }
    }
    return 0;
}



Re: GetPlayerVehicleID(playerid); not working. - Anwix - 16.07.2009

Quote:
Originally Posted by ۞●•λвнiиаv•●۞
Try this
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if (!ispassenger)
    {
        if (vehicleid==45){
          TogglePlayerControllable(playerid, 0);
          ShowMenuForPlayer(Elegy, playerid);
          SetCameraBehindPlayer(playerid);
          return 1;
        }
    }
    return 0;
}
thanks, but that didn't work unfortunatly.


Re: GetPlayerVehicleID(playerid); not working. - abhinavdabral - 16.07.2009

Now try this
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
if (vehicleid==45){
  TogglePlayerControllable(playerid, 0);
  ShowMenuForPlayer(Elegy, playerid);
  SetCameraBehindPlayer(playerid);
  return 1;
}
}
return 0;
}