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
#2

Bump!

I'm still in need of help on this subject.
Reply
#3

Just going to bump this another time, as I'm still in need of assistance!
Reply
#4

Bump again.
Reply
#5

bump again.
Reply
#6

pawn Code:
new CurrentMenu = GetPlayerMenu(playerid);
Reply
#7

Quote:
Originally Posted by Macronix
View Post
pawn Code:
new CurrentMenu = GetPlayerMenu(playerid);
It gives me two warnings when I remove Menu: from the new CurrentMenu = GetPlayerMenu(playerid);

Code:
C:\Users\Andreas\Desktop\SAMP SERVER\DM Mode\gamemodes\Test.pwn(277) : warning 213: tag mismatch
C:\Users\Andreas\Desktop\SAMP SERVER\DM Mode\gamemodes\Test.pwn(278) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Reply
#8

Mh, okay, then try it without CurrentMenu, only
pawn Code:
if(GetPlayerMenu(playerid) == ...)
It could also be a problem with the rows, so maybe try it without a second row, only row 0 at AddMenuItem
Reply
#9

It compiles fine now, but it still doesn't spawn any vehicle when you pick on in the menu.
Also it still moves on both rows simentaniously.
Reply
#10

Quote:
Originally Posted by Macronix
View Post
Mh, okay, then try it without CurrentMenu, only
pawn Code:
if(GetPlayerMenu(playerid) == ...)
It could also be a problem with the rows, so maybe try it without a second row, only row 0 at AddMenuItem
By changing them to row 0 if fixes the problem about moving on both rows. But it still doesn't spawn any vehicle.. hmm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)