AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] making menu to buy godmode stuff (https://forums.alliedmods.net/showthread.php?t=65278)

eewokney 01-05-2008 04:12

[help] making menu to buy godmode stuff
 
hi everybody, im making a menu where people can buy things like godmode im stuck ad the part where people choose something out of my buymenu which does work but im using "case" to check what people have choosen but i want to add more then one line behind it, when i try to make it a amxx it says " only a single statement (or expression) can follow each "case", so i need to think of something else,

part of my script:
[small] switch( key )
{
case 0:client_print(0,print_chat, "[AMX] <Dice Dealer> %s has contracted the deadly slap disease!", User)
HasPrize[id][0] = PRIZE_SLAP
HasPrize[id][1] = random(SLAP_TIME) + 5
user_slap(id,5)
set_user_rendering(id,kRenderFxGlowShell, Red,Green,Blue, kRenderNormal,16)
case 1: client_print( id, print_chat, "Menu Option #2" )
case 2: client_print( id, print_chat, "Menu Option #3" )
case 3: client_print( id, print_chat, "Menu Option #4" )
case 4: client_print( id, print_chat, "Menu Option #5" )
case 5: client_print( id, print_chat, "Menu Option #6" )
case 6: client_print( id, print_chat, "Menu Option #7" )
case 7: client_print( id, print_chat, "Menu Option #8" )
case 8: client_print( id, print_chat, "Menu Option #9" )
case 9: client_print( id, print_chat, "Menu Option EXIT" )
}[small]

johnjg75 01-05-2008 04:58

Re: [help] making menu to buy godmode stuff
 
did you put these: { }?

Code:
 switch( key ) { case 0: {      client_print(0,print_chat, "[AMX] <Dice Dealer> %s has contracted the deadly slap disease!", User)      HasPrize[id][0] = PRIZE_SLAP      HasPrize[id][1] = random(SLAP_TIME) + 5      user_slap(id,5)      set_user_rendering(id,kRenderFxGlowShell, Red,Green,Blue, kRenderNormal,16) } case 1: client_print( id, print_chat, "Menu Option #2" ) case 2: client_print( id, print_chat, "Menu Option #3" ) case 3: client_print( id, print_chat, "Menu Option #4" ) case 4: client_print( id, print_chat, "Menu Option #5" ) case 5: client_print( id, print_chat, "Menu Option #6" ) case 6: client_print( id, print_chat, "Menu Option #7" ) case 7: client_print( id, print_chat, "Menu Option #8" ) case 8: client_print( id, print_chat, "Menu Option #9" ) case 9: client_print( id, print_chat, "Menu Option EXIT" ) }

eewokney 01-05-2008 07:44

Re: [help] making menu to buy godmode stuff
 
ty that works ! now i have the problam that the powers work bad, zeus mode doesnt stop, slap disease only slaps once and some things dont even work,

this is the sma:
http://creativeatmosphere.clanserver...x_ejl_dice.sma

eewokney 01-05-2008 07:44

Re: [help] making menu to buy godmode stuff
 
question: how do you do that after the player choose a option out of the menu the player says like /help?

case 0:"say_help" ?

eewokney 01-08-2008 12:42

Re: [help] making menu to buy godmode stuff
 
is it client_cmd(id, "say help")

????

Exolent[jNr] 01-08-2008 16:50

Re: [help] making menu to buy godmode stuff
 
Code:

client_cmd(index, "say /help");

eewokney 01-12-2008 03:03

Re: [help] making menu to buy godmode stuff
 
this is what i now have, it doesnt work, what is it?:
Code:
#include <amxmodx> #include <cstrike> #include <fun> public plugin_init() {    register_clcmd( "say /commands","ShowMenu", -1, "Shows The menu" )    register_clcmd( "say commands","ShowMenu", -1, "Shows The menu" )    register_clcmd( "commands","ShowMenu", -1, "Shows The menu" )    register_menucmd(register_menuid("\yFirst Menu:"), 1023, "MenuCommand" )    return PLUGIN_CONTINUE } public ShowMenu( id ) {    new szMenuBody[256]    new keys    new nLen = format( szMenuBody, 255, "\yFirst Menu:^n" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. /buyxp" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. /sellxp" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w3. /buyhp" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w4. /clearpowers" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w5. /help" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w6. /myheroes" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w7. /playerskills" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w8. /voteknifesonly" )    nLen += format( szMenuBody[nLen], 255-nLen, "^n\w9. /roll the dice " )    nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" )    keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)    show_menu( id, keys, szMenuBody, -1 )    return PLUGIN_CONTINUE } public MenuCommand( id, key ) {     new authid[33]      get_user_authid(id,authid,32)    switch( key )    {        case 0:client_cmd(index, "say /buyxp" )        case 1:client_cmd(index, "say /sellxp" )        case 2:client_cmd(index, "say /buyhp" )        case 3:client_cmd(index, "say /clearpowers" )        case 4:client_cmd(index, "say /help" )        case 5:client_cmd(index, "say /myheroes" )        case 6:client_cmd(index, "say /playerskills" )        case 7:client_cmd(index, "say /voteknifesonly" )        case 8:client_cmd(index, "say /roll the dice" )        case 9: client_print( id, print_chat, "Menu Option EXIT" )    }    return PLUGIN_HANDLED }

slypanther 01-12-2008 05:40

Re: [help] making menu to buy godmode stuff
 
Try this
You had index and its id is short for index
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

public plugin_init()
{
   
register_clcmd"say /commands","ShowMenu", -1"Shows The menu" )
   
register_clcmd"say commands","ShowMenu", -1"Shows The menu" )
   
register_clcmd"commands","ShowMenu", -1"Shows The menu" )

   
register_menucmd(register_menuid("\yFirst Menu:"), 1023"MenuCommand" )

   return 
PLUGIN_CONTINUE
}

public 
ShowMenuid )
{
   new 
szMenuBody[256]
   new 
keys

   
new nLen formatszMenuBody255"\yFirst Menu:^n" )

   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w1. /buyxp" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w2. /sellxp" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w3. /buyhp" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w4. /clearpowers" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w5. /help" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w6. /myheroes" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w7. /playerskills" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w8. /voteknifesonly" )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n\w9. /roll the dice " )
   
nLen += formatszMenuBody[nLen], 255-nLen"^n^n\w0. Exit" )

   
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)

   
show_menuidkeysszMenuBody, -)

   return 
PLUGIN_CONTINUE
}

public 
MenuCommandidkey )
{
   new 
authid[33]  
   
get_user_authid(id,authid,32)


   switch( 
key )
   {
       case 
0:client_cmd(id"say /buyxp" )
       case 
1:client_cmd(id"say /sellxp" )
       case 
2:client_cmd(id"say /buyhp" )
       case 
3:client_cmd(id"say /clearpowers" )
       case 
4:client_cmd(id"say /help" )
       case 
5:client_cmd(id"say /myheroes" )
       case 
6:client_cmd(id"say /playerskills" )
       case 
7:client_cmd(id"say /voteknifesonly" )
       case 
8:client_cmd(id"say /roll the dice" )
       case 
9client_printidprint_chat"Menu Option EXIT" )
   } 

   return 
PLUGIN_HANDLED




All times are GMT -4. The time now is 11:03.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.