[NEED HELP] menus -
Drift_King786 - 13.05.2009
ok i got a small food script
but the effect when selcting something doesnt work properly
need help
ok the menu stuff, filterscripinit
pawn Код:
pizzamenu = CreateMenu("Pizza", 2, 200.0, 100.0, 150.0);
AddMenuItem(pizzamenu, 0, "Magherita");
AddMenuItem(pizzamenu, 0, "Pepperoni");
AddMenuItem(pizzamenu, 0, "Meat Feast");
AddMenuItem(pizzamenu, 0, "Seafood Lovers");
AddMenuItem(pizzamenu, 0, "Vegetarian Hot One");
AddMenuItem(pizzamenu, 0, "Next");
AddMenuItem(pizzamenu, 1, "$5");
AddMenuItem(pizzamenu, 1, "$6");
AddMenuItem(pizzamenu, 1, "$8");
AddMenuItem(pizzamenu, 1, "$15");
AddMenuItem(pizzamenu, 1, "$7");
AddMenuItem(pizzamenu, 1, "Page");
OnCommand
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/foodmenu", cmdtext, true, 10) == 0)
{
ShowMenuForPlayer(pizzamenu,playerid);
TogglePlayerControllable(playerid,0);
return 1;
}
return 0;
}
OnPlayerSelectedMenuRow
pawn Код:
new Menu:Current2Menu = GetPlayerMenu(playerid);
if(Current2Menu == pizzamenu)
{
switch(row)
{
case 0:
{
new float:health;
health = GetPlayerHealth(playerid, health);
if(health > 95 && health <= 100)
{
SetPlayerHealth(playerid, 100.0);
}
else if(health > 90 && health <= 95)
{
SetPlayerHealth(playerid, 100.0);
}
else if(health > 85 && health <= 90)
{
SetPlayerHealth(playerid, 95.0);
}
else if(health > 80 && health <= 85)
{
SetPlayerHealth(playerid, 90.0);
}
else if(health > 75 && health <= 80)
{
SetPlayerHealth(playerid, 85.0);
}
else if(health > 70 && health <= 75)
{
SetPlayerHealth(playerid, 80.0);
}
else if(health > 65 && health <= 70)
{
SetPlayerHealth(playerid, 75.0);
}
else if(health > 60 && health <= 65)
{
SetPlayerHealth(playerid, 70.0);
}
else if(health > 55 && health <= 60)
{
SetPlayerHealth(playerid, 65.0);
}
else if(health > 50 && health <= 55)
{
SetPlayerHealth(playerid, 60.0);
}
else if(health > 45 && health <= 50)
{
SetPlayerHealth(playerid, 55.0);
}
else if(health > 40 && health <= 45)
{
SetPlayerHealth(playerid, 50.0);
}
else if(health > 35 && health <= 40)
{
SetPlayerHealth(playerid, 45.0);
}
else if(health > 30 && health <= 35)
{
SetPlayerHealth(playerid, 40.0);
}
else if(health > 25 && health <= 30)
{
SetPlayerHealth(playerid, 35.0);
}
else if(health > 20 && health <= 25)
{
SetPlayerHealth(playerid, 30.0);
}
else if(health > 15 && health <= 20)
{
SetPlayerHealth(playerid, 25.0);
}
else if(health > 10 && health <= 15)
{
SetPlayerHealth(playerid, 20.0);
}
else if(health > 5 && health <= 10)
{
SetPlayerHealth(playerid, 15.0);
}
else if(health > 0 && health <= 5)
{
SetPlayerHealth(playerid, 10.0);
}
GivePlayerMoney(playerid, -5);
TogglePlayerControllable(playerid,1);
the script should actually be healing the player by 5 HP, since i do not know how to do that i done this
if you can heal the player by 5 can you show that and also comment on the line
when player types in the command, the player is froze and when the player buys soemthing or cancels the player is the unfroze
and when the player buys something it will cost the $5 aswell
any help?
when i do this, the script sets the player health to around 5-10 for some reason, but it does the last 2 functions(cash and toggle player control)
Re: [NEED HELP] menus -
Backwardsman97 - 14.05.2009
You know you can just do this.
pawn Код:
new Menu:Current2Menu = GetPlayerMenu(playerid);
if(Current2Menu == pizzamenu)
{
switch(row)
{
case 0:
{
new float:health;
health = GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid,health-5);
GivePlayerMoney(playerid, -5);
TogglePlayerControllable(playerid,1);
}
}
}
Re: [NEED HELP] menus -
MX_Master - 14.05.2009
may be author wants to make something like that ?
[code=pawn]#include <a_samp>
stock Menu
izzamenu;
main() {}
public OnGameModeInit()
{
// other code
pizzamenu = CreateMenu( "Pizza", 2, 200.0, 100.0, 150.0, 150.0 );
AddMenuItem(pizzamenu, 0, "Magherita");
AddMenuItem(pizzamenu, 0, "Pepperoni");
AddMenuItem(pizzamenu, 0, "Meat Feast");
AddMenuItem(pizzamenu, 0, "Seafood Lovers");
AddMenuItem(pizzamenu, 0, "Vegetarian Hot One");
AddMenuItem(pizzamenu, 1, "$5");
AddMenuItem(pizzamenu, 1, "$6");
AddMenuItem(pizzamenu, 1, "$8");
AddMenuItem(pizzamenu, 1, "$15");
AddMenuItem(pizzamenu, 1, "$7");
// other code
return 1;
}
public OnPlayerCommandText( playerid, cmdtext[] )
{
// other code
if ( strcmp( "/foodmenu", cmdtext, true, 9 ) == 0 )
{
TogglePlayerControllable( playerid, 0 ); // freezing player
ShowMenuForPlayer( pizzamenu, playerid ); // show food menu for player
return 1;
}
// other code
return 0;
}
public OnPlayerSelectedMenuRow ( playerid, row )
{
// getting current player's menu ID
new Menu:menu = GetPlayerMenu(playerid);
// if current player's menu is food menu
if ( menu == pizzamenu )
{
// getting current player's health
new Float:currentHealth;
GetPlayerHealth( playerid, currentHealth );
// if player really need heal
if ( currentHealth < 100.0 )
{
switch ( row )
{
case 0: // Magherita
{
// giving to player some health
SetPlayerHealth( playerid, currentHealth + 5.0 );
// this action wiil take player's money even when he have no money or
// his money value is negative
GivePlayerMoney( playerid, -5 );
}
case 1: // Pepperoni
{
SetPlayerHealth( playerid, currentHealth + 6.0 );
GivePlayerMoney( playerid, -6 );
}
case 2: // Meat Feast
{
SetPlayerHealth( playerid, currentHealth + 8.0 );
GivePlayerMoney( playerid, -8 );
}
case 3: // Seafood Lovers
{
SetPlayerHealth( playerid, currentHealth + 15.0 );
GivePlayerMoney( playerid, -15 );
}
case 4: // Vegetarian Hot One
{
SetPlayerHealth( playerid, currentHealth + 7.0 );
GivePlayerMoney( playerid, -7 );
}
}
// if player have more than 100% health after eating
if ( currentHealth > 100.0 ) SetPlayerHealth( playerid, 100.0 );
}
// show menu to player again if he need more food
ShowMenuForPlayer( pizzamenu, playerid );
return 1;
}
// other code
return 1;
}
public OnPlayerExitedMenu( playerid )
{
// other code
TogglePlayerControllable( playerid, 1 ); // unfreezing player
HideMenuForPlayer( pizzamenu, playerid ); // hide any menu (and food menu too)
// other code
return 1;
}[/code]