18.08.2013, 13:31
I was wondering how to build a menu popup box with 4 options for the player - the player can press one from the list and click 'OK'. I've seen this done and tried it myself but never quite got the hang of the code required.
For example,
When the player enters the checkpoint at the SF Airport (-1410.3000488281, -299.10000610352, 14.10000038147) a command can be done (e.g. /fly) and the player is presented with a menu and able to pick one of the choices (LS,AA,SF,LV) to 'fly' to.
I found this helpful but wasn't able to adapt it to suit my needs or get it working.
Here's what I've got so far:
At the top
OnGameModeInit():
OnPlayerCommandText
For example,
When the player enters the checkpoint at the SF Airport (-1410.3000488281, -299.10000610352, 14.10000038147) a command can be done (e.g. /fly) and the player is presented with a menu and able to pick one of the choices (LS,AA,SF,LV) to 'fly' to.
I found this helpful but wasn't able to adapt it to suit my needs or get it working.
Here's what I've got so far:
At the top
Код:
new Menu:airportmenu; new Menu:CurrentMenu = GetPlayerMenu(playerid);
Код:
airportmenu = CreateMenu("Airportmenu", 2, 200.0, 100.0, 150.0, 150.0); AddMenuItem(airportmenu, 0, "LS"); AddMenuItem(airportmenu, 0, "LV"); AddMenuItem(airportmenu, 0, "SF"); AddMenuItem(airportmenu, 0, "AA"); AddMenuItem(airportmenu, 1, "$2500"); AddMenuItem(airportmenu, 1, "$3000"); AddMenuItem(airportmenu, 1, "$3500"); AddMenuItem(airportmenu, 1, "$400");
Код:
if(CurrentMenu == airportmenu) { switch(row) { case 0: //Los Santos { SetPlayerPos(playerid, 1685.8000488281, -2240, 13.5); SetPlayerInterior(playerid, 0); TakePlayerMoney(playerid, 2500); SendClientMessage(playerid, COLOR_RED, "You have boarded a flight to Los Santos International Airport."); } case 1: //Las Venturas { SetPlayerPos(playerid, 1687.8000488281, 1448, 10.800000190735); SetPlayerInterior(playerid, 0); TakePlayerMoney(playerid, 3000); SendClientMessage(playerid, COLOR_RED, "You have boarded a flight to Las Venturas Airport."); } case 2: //San Fierro { SetPlayerPos(playerid, -1410.3000488281, -299.10000610352, 14.10000038147); SetPlayerInterior(playerid, 0); TakePlayerMoney(playerid, 3500); SendClientMessage(playerid, COLOR_RED, "You have boarded a flight to San Fierro Airport."); } case 3: //Abandoned Airport { SetPlayerPos(playerid, 421, 2531.3000488281, 16.60000038147); SetPlayerInterior(playerid, 0); TakePlayerMoney(playerid, 400); SendClientMessage(playerid, COLOR_RED, "You have boarded a flight to Bone County Abandoned Airport."); } } }
Код:
if(strcmp(cmdtext, "/fly", true) == 0) { ShowMenuForPlayer(airportmenu,playerid); return 1; }