Vehicle spawner + Menu - Not working!
#1

Hi there,

I got a problem with my menu for buying vehicles.
It's being run perfectly fine by Pawno, without any sort of errors etc.
But, there's two problems though.

1). When I pick one of the ten options in the menu, nothing happens. (It should spawn a vehicle infront of the player)

2). When I move down in the menu, it will move on both rows simentaniously. So instead of picking one car, you would be picking two cars.

My variables:
Code:
new Menu:carmenu;
new SpawnedVehicle[MAX_PLAYERS];
OnGameModeInit:
Code:
public OnGameModeInit()
{
	carmenu = CreateMenu("CarMenu", 2, 200.0, 100.0, 150.0, 150.0);
	AddMenuItem(carmenu, 0, "Sultan");
	AddMenuItem(carmenu, 0, "Savanna");
	AddMenuItem(carmenu, 0, "Buffalo");
	AddMenuItem(carmenu, 0, "Sentinel");
	AddMenuItem(carmenu, 0, "Infernus");

	AddMenuItem(carmenu, 1, "Cheetah");
 	AddMenuItem(carmenu, 1, "Ambulance");
  	AddMenuItem(carmenu, 1, "Leviathan");
 	AddMenuItem(carmenu, 1, "Esperanto");
 	AddMenuItem(carmenu, 1, "Banshee");
	return 1;
}
OnPlayerSelectedMenuRow:
Code:
public OnPlayerSelectedMenuRow(playerid, row)
{
	new Menu:CurrentMenu = GetPlayerMenu(playerid);
	if (CurrentMenu == carmenu)
	{
	    switch(row)
	    {
	        case 0: // Sultan
			{
			    new Float:X, Float:Y, Float:Z, Float:Angle;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
				GetPlayerFacingAngle(playerid, Float:Angle);
				SpawnedVehicle[playerid] = CreateVehicle(560, X, Y + 5, Z + 2.0, Angle + 90.0, -1, -1, 600);
				SetVehicleVirtualWorld(SpawnedVehicle[playerid], GetPlayerVirtualWorld(playerid));
				LinkVehicleToInterior(SpawnedVehicle[playerid], GetPlayerInterior(playerid));
			}
			case 1:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 2:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 3:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 4:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 5:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 6:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 7:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 8:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
			case 9:
			{
			    new Float:X, Float:Y, Float:Z;
			    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
			    CreateVehicle(560, X, Y + 5, Z + 2.0, 0, -1, -1, 1);
			}
		}
	}
	return 1;
}
The command for the menu:
Code:
CMD:buycar(playerid, params[])
{
	ShowMenuForPlayer(carmenu,playerid);
	return 1;
}
As you can see at OnPlayerSelectedMenuRow, I tried a couple of things to make it work. None of it really had any effect.. By the way, it's on purpose that they're all going to spawn Sultans as I wasn't going to waste my time finding all the vehicle id's if it didn't even work anyway.

But yeah, please help me find out what the problem is.

/Andreas1331
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)