Raised This Month: $ Target: $400
 0% 

Trouble with setting godmode through a menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 02-13-2005 , 12:41   Trouble with setting godmode through a menu
Reply With Quote #1

Hi, I've been working on this menu for a week or so now and I'm stumped. I've read the tutorial by xeroblood and checked the documentation many times but I still can't figure out how to get this plugin to work. Could someone look over the code for me?

Code:
#include <amxmod> #include <amxmisc> #include <fun> #include <cstrike> #define MAX_MENU 24 #define MAX_DISPLAY 8 #define MAX_PAGES 3 #define MENU_SIZE    256 #define MENU_PLAYERS 8 new g_nIndexMenuPosition[33] new g_nMenuPosition2[33] new g_nCOMenuPosition[33] new g_nTGOMenuPosition[33] new szIndexMenuBody[256] new szMenuBody3[256] new g_menuPlayers[33][32] new g_menuPlayersNum[33] new g_menuOption[33] new g_menuSettings[33] new g_coloredMenus public plugin_init() {     register_menucmd( register_menuid("\yIndex Menu:"), 1023, "IndexMenuCommand" )     register_menucmd( register_menuid("\yOptions Menu2:"), 1023, "MenuCommand2" )     register_menucmd( register_menuid("\yCheat Other:"), 1023, "COMenuCommand" )     register_menucmd( register_menuid("\yToggle God On Player:"), 1023, "TGOMenuCommand" )     register_clcmd( "say /index","DoShowIndexMenu", ADMIN_MENU, "Shows The Index Menu" )     register_clcmd( "say /menu2","DoShowMenu2", ADMIN_MENU, "Shows The menu2" )     register_clcmd( "say /CheatO","DoShowCOMenu", ADMIN_MENU, "Shows The Cheat Other Menu" )     register_clcmd( "say /TGOMenu","DoShowTGOMenu", ADMIN_MENU, "Shows The Toggle God On Other Menu" )     g_coloredMenus = colored_menus()     return PLUGIN_CONTINUE } public ShowIndexMenu( id, pos ) {     if( pos < 0 ) return         pos = g_nIndexMenuPosition[id] = 0         format( szIndexMenuBody, 255, "\yIndex Menu:^n" )         add( szIndexMenuBody, 255, "^n\w1. First Option"  )         add( szIndexMenuBody, 255, "^n\w2. Second Option" )         add( szIndexMenuBody, 255, "^n\w3. Third Option" )         add( szIndexMenuBody, 255, "^n\w4. Fourth Option" )         add( szIndexMenuBody, 255, "^n\w5. Fifth Option" )         add( szIndexMenuBody, 255, "^n\w6. Sixth Option" )         add( szIndexMenuBody, 255, "^n\w7. Seventh Option" )         add( szIndexMenuBody, 255, "^n\w8. Cheat Other" )         add( szIndexMenuBody, 255, "^n\w9. Ninth Option" )         add( szIndexMenuBody, 255, "^n^n\w0. Exit" )     show_menu( id, 1023, szIndexMenuBody, -1 ) } public IndexMenuCommand( id, key ) { switch( key ) {     case 7: ShowCOMenu( id, g_nCOMenuPosition[id] )     case 9: client_print( id, print_chat, "Menu Option EXIT" ) } return PLUGIN_HANDLED } public DoShowIndexMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 1 ) )         ShowIndexMenu( id, g_nIndexMenuPosition[id] = 0 )     return PLUGIN_HANDLED } new g_szOptions2[ MAX_MENU ][ ] = { "PG 1: Option 1b", "PG 1: Option 2b", "PG 1: Option 3b", "PG 1: Option 4b", "PG 1: Option 5b", "PG 1: Option 6b", "PG 1: Option 7b", "PG 1: CO Menu", "PG 2: Option 1b", "PG 2: Option 2b", "PG 2: Option 3b", "PG 2: Option 4b", "PG 2: Option 5b", "PG 2: Option 6b", "PG 2: Option 7b", "PG 2: CO Menu", "PG 3: Option 1b", "PG 3: Option 2b", "PG 3: Option 3b", "PG 3: Option 4b", "PG 3: Option 5b", "PG 3: Option 6b", "PG 3: Option 7b", "PG 3: CO Menu" } public MenuCommand2( id, key ) {     switch( key )     {         case 8: ShowMenu2( id, ++g_nMenuPosition2[id] )         case 9: ShowMenu2( id, --g_nMenuPosition2[id] )           default: client_print( id, print_chat, "%s", g_szOptions2[g_nMenuPosition2[id] * MAX_DISPLAY + key] )       }       return PLUGIN_HANDLED } public ShowMenu2( id, pos ) {     if( pos < 0 ) return     new i, j = 0     new nKeys, nStart, nEnd, nLen     new szMenuBody2[512]     nStart = pos * MAX_DISPLAY     if( nStart >= MAX_MENU )         nStart = pos = g_nMenuPosition2[id] = 0     nLen = format( szMenuBody2, 511, "\yOptions Menu2:\R%d/%d^n\w^n", pos + 1, MAX_PAGES )     nEnd = nStart + MAX_DISPLAY     nKeys = (1<<9)     if( nEnd > MAX_MENU ) nEnd = MAX_MENU     for( i = nStart; i < nEnd; i++ )     {         nKeys |= (1<<j++)         nLen += format( szMenuBody2[nLen], (511-nLen), "\d%d. %s^n\w", j, g_szOptions2[i] )     }     if( nEnd != MAX_MENU )       {         format( szMenuBody2[nLen], (511-nLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )         nKeys |= (1<<8)     }       else format( szMenuBody2[nLen], (511-nLen), "^n0. %s", pos ? "Back" : "Exit" )     show_menu( id, nKeys, szMenuBody2, -1 ) } public DoShowMenu2( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 1 ) )         ShowMenu2( id, g_nMenuPosition2[id] = 0 )     return PLUGIN_HANDLED } public ShowCOMenu( id, pos ) {     if( pos < 0 ) return         pos = g_nCOMenuPosition[id] = 0         format( szMenuBody3, 255, "\yCheat Other:^n" )         add( szMenuBody3, 255, "^n\w1. God Mode"  )         add( szMenuBody3, 255, "^n\w2. Noclip" )         add( szMenuBody3, 255, "^n\w9. Index Menu" )         add( szMenuBody3, 255, "^n^n\w0. Exit Menus" )     show_menu( id, 1023, szMenuBody3, -1 ) } public COMenuCommand( id, key ) { switch( key ) {     case 0: ShowTGOMenu( id, g_nTGOMenuPosition[id])     case 8: ShowIndexMenu( id, g_nIndexMenuPosition[id])     case 9: client_print( id, print_chat, "Menu Option EXIT" ) } return PLUGIN_HANDLED } public DoShowCOMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 1 ) )         ShowCOMenu( id, g_nCOMenuPosition[id] = 0 )     return PLUGIN_HANDLED } public TGOMenuCommand(id,key) {     new player = g_menuPlayers[id][g_nTGOMenuPosition[id] * 7 + key]     new name[32], name2[32], authid[32],authid2[32]     get_user_name(player,name2,31)     get_user_authid(id,authid,31)     get_user_authid(player,authid2,31)     get_user_name(id,name,31)     new userid2 = get_user_userid(player)         switch (key) {         case 7: {         ++g_menuOption[id]         g_menuOption[id] %= 3       switch(g_menuOption[id]){       case 0: g_menuSettings[id] = 0       case 1: g_menuSettings[id] = 5       case 2: g_menuSettings[id] = 60       }       ShowTGOMenu(id,g_nTGOMenuPosition[id])     }     case 8: ShowTGOMenu(id,++g_nTGOMenuPosition[id])     case 9: ShowTGOMenu(id,--g_nTGOMenuPosition[id])     default: {       log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")",         name,get_user_userid(id),authid, name2,userid2,authid2, g_menuSettings[id] )       switch (get_cvar_num("amx_show_activity")) {         case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_BAN_2",name,name2)         case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_BAN_1",name2)     }         if(get_user_godmode(g_menuPlayers[id][g_nTGOMenuPosition[id] * 7 + key]) == 0) {         set_user_godmode(g_menuPlayers[id][g_nTGOMenuPosition[id] * 7 + key], 1); // turn on     }         else { // if already on         set_user_godmode(player, 0); // turn off     }     server_exec()       ShowTGOMenu(id,g_nTGOMenuPosition[id])     }   }   return PLUGIN_HANDLED } ShowTGOMenu(id,pos) {   if (pos < 0)  return   get_players(g_menuPlayers[id],g_menuPlayersNum[id])   new szMenuBody4[512]   new b = 0   new i   new name[32]   new start = pos * 7   if (start >= g_menuPlayersNum[id])     start = pos = g_nTGOMenuPosition[id] = 0   new len = format(szMenuBody4,511, g_coloredMenus ?     "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n",     id,"TGO_MENU",pos+1,(  g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0 )) )   new end = start + 7   new keys = MENU_KEY_0|MENU_KEY_8   if (end > g_menuPlayersNum[id])     end = g_menuPlayersNum[id]   for (new a = start; a < end; ++a) {     i = g_menuPlayers[id][a]     get_user_name(i,name,31)     if ( is_user_bot(i) || access(i,ADMIN_IMMUNITY) ) {       ++b       if ( g_coloredMenus )         len += format(szMenuBody4[len],511-len,"\d%d. %s^n\w",b,name)       else         len += format(szMenuBody4[len],511-len,"#. %s^n",name)     }     else {       keys |= (1<<b)       len += format(szMenuBody4[len],511-len,"%d. %s^n",++b,name)     }   }   if ( g_menuSettings[id] )     len += format(szMenuBody4[len],511-len,"^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id] )   else     len += format(szMenuBody4[len],511-len,"^n8. %L^n", id, "BAN_PERM" )   if (end != g_menuPlayersNum[id]) {     format(szMenuBody4[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")     keys |= MENU_KEY_9   }   else format(szMenuBody4[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")   show_menu(id,keys,szMenuBody4,-1,"\yToggle God On Player") } public DoShowTGOMenu(id,level,cid) {   if (!cmd_access(id,level,cid,1))     return PLUGIN_HANDLED   g_menuOption[id] = 1   g_menuSettings[id] = 5   ShowTGOMenu(id,g_nTGOMenuPosition[id] = 0)   return PLUGIN_HANDLED }
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 02-13-2005 , 17:29  
Reply With Quote #2

could someone just help me with this part of the code at least and show me how to use the godmode function properly in a menu and how to tell it what player to target?

Code:
public TGOMenuCommand(id,key) {

    new player = g_menuPlayers[id][g_nTGOMenuPosition[id] * 7 + key]

    new name[32], name2[32], authid[32],authid2[32]
    get_user_name(player,name2,31)
    get_user_authid(id,authid,31)
    get_user_authid(player,authid2,31)
    get_user_name(id,name,31)
    new userid2 = get_user_userid(player)

        switch (key) {
        case 7: {
        ++g_menuOption[id]
        g_menuOption[id] %= 3

      switch(g_menuOption[id]){
      case 0: g_menuSettings[id] = 0
      case 1: g_menuSettings[id] = 5
      case 2: g_menuSettings[id] = 60
      }

      ShowTGOMenu(id,g_nTGOMenuPosition[id])
    }
    case 8: ShowTGOMenu(id,++g_nTGOMenuPosition[id])
    case 9: ShowTGOMenu(id,--g_nTGOMenuPosition[id])
    default: {

      log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")",
        name,get_user_userid(id),authid, name2,userid2,authid2, g_menuSettings[id] )

      switch (get_cvar_num("amx_show_activity")) {
        case 2: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_BAN_2",name,name2)
        case 1: client_print(0,print_chat,"%L",LANG_PLAYER,"ADMIN_BAN_1",name2)
    }

        if(get_user_godmode(g_menuPlayers[id][g_nTGOMenuPosition[id] * 7 + key]) == 0) {
        set_user_godmode(g_menuPlayers[id][g_nTGOMenuPosition[id] * 7 + key], 1); // turn on
    }
        else { // if already on
        set_user_godmode(player, 0); // turn off
    }

    server_exec()

      ShowTGOMenu(id,g_nTGOMenuPosition[id])
    }
  }
  return PLUGIN_HANDLED
}
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
nightscreem
Veteran Member
Join Date: Jul 2004
Location: Belgium
Old 02-13-2005 , 18:59  
Reply With Quote #3

sry but i can't help you with that but
i think you need to change
Quote:
<amxmod>
into
Quote:
<amxmodx>
__________________
- Bye bye!
nightscreem is offline
Da Bishop
Senior Member
Join Date: Aug 2004
Location: Chester County PA
Old 02-13-2005 , 20:53  
Reply With Quote #4

Someone needs to delete any tutorials that show menus using the add() function. Its a very bad code if you ask me, perhaps it should be gotten rid of
__________________
Anything that is done can only be done better by urself - since life is a opinion make it the way urs feel its best

~live by it
Da Bishop is offline
Send a message via MSN to Da Bishop
knekter
Senior Member
Join Date: Mar 2004
Location: PA
Old 02-13-2005 , 22:01   Yep
Reply With Quote #5

Yes, add is very bad, you should check out the tutorials in the documentation of AMXX, there is a good tutorial on menus that use alot less code and are much better.
__________________
More updates for Matrix Mod!
knekter is offline
Send a message via AIM to knekter Send a message via MSN to knekter
Stealth Penguin
Junior Member
Join Date: Jan 2005
Old 02-13-2005 , 22:53  
Reply With Quote #6

I know about creating the menu and I will deal with that in the future but for now the menu navigation and layout is adequate for my purposes. The only thing I need help with is with why the godmode function won't work. (I tried setting the include to amxmodx and no change)

Thank you.
Stealth Penguin is offline
Send a message via ICQ to Stealth Penguin Send a message via AIM to Stealth Penguin Send a message via Yahoo to Stealth Penguin
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:09.


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