Raised This Month: $ Target: $400
 0% 

DOD FF MANAGER: maybe a nice plugin if you can help me :)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Colt
Junior Member
Join Date: Sep 2004
Old 10-02-2004 , 11:57   news!
Reply With Quote #8

The end is close, but I have a new problem

I want to make a menu as the "Ban Menu", so that an admin can give credits to a player. The menu is displayed when the admin writes the command. To simplify, I have just pasted the code of the menu:

Code:
new g_menuPosition[33] new g_menuPlayers[33][32] new g_menuPlayersNum[33] new g_menuOption[33] new g_menuCredits[33] public plugin_init() {     register_menucmd(register_menuid("Credits Menu"),1023,"credits_menu")     return PLUGIN_CONTINUE } displayCreditsMenu(id,pos) {   if (pos < 0)  return       get_players(g_menuPlayers[id],g_menuPlayersNum[id])       new menuBody[512]   new b = 0   new i   new name[32]   new start = pos * 7     if (start >= g_menuPlayersNum[id])     start = pos = g_menuPosition[id] = 0       new len = format(menuBody,511,"\yPage %d/%d^nKey Credits Player\w^n^n" ,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]     keys |= (1<<b)     get_user_name(i,name,31)     if ( g_credits[i]<5 ) // set credits in red if <5, if not in blue       len += format(menuBody[len],511-len,"%d. \r%d \w%s^n",++b,g_credits[i],name)     else       len += format(menuBody[len],511-len,"%d. \b%d \w%s^n",++b,g_credits[i],name)   }   if ( !g_menuCredits[id] ) // set  by default the credits to 10 to give     g_menuCredits[id]=10   len += format(menuBody[len],511-len,"^n\y8. Give %d credits^n", g_menuCredits[id] )   if (end != g_menuPlayersNum[id]) {     keys |= MENU_KEY_9       format(menuBody[len],511-len,"^n\y9. Next...^n0. ...Back\w")   }   else format(menuBody[len],511-len,"^n\y0. ...Back\w")   show_menu(id,keys,menuBody,-1,"Credits Menu") } public credits_menu(id,key) {   switch (key) {     case 7: { // change the value of credits to give       ++g_menuOption[id]       g_menuOption[id] %= 3             switch(g_menuOption[id]){       case 0: g_menuCredits[id] = 10       case 1: g_menuCredits[id] = 20       case 2: g_menuCredits[id] = 5       }           displayCreditsMenu(id,g_menuPosition[id])     }     case 8: displayCreditsMenu(id,++g_menuPosition[id]) // go to the next page     case 9: displayCreditsMenu(id,--g_menuPosition[id]) // go to the previous page     default: {       new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]       new nameplayer[32]       new nameadmin[32]       get_user_name(player,nameplayer,31)       get_user_name(id,nameadmin,31)       set_hudmessage(255, 0, 0, 0.05, 0.6, 0, 8.0, 10.0, 0.1, 0.5, 8)       g_credits[player]+=g_menuCredits[player]       show_hudmessage(0,"The ADMIN %s^nhas given %d credits to %s", nameadmin, g_menuCredits[player], nameplayer)             displayCreditsMenu(id,g_menuPosition[id])     }   }     return PLUGIN_HANDLED }

So what is the problem? The first time, the menu works fine, I can change the credits value and give credits to players.

But the second time (when the menu has been closed and opened back), whatever the key I press, the menu closes and nothing happens! And with debug mod, AMXX says:
Code:
[AMXX] Run time error 4 (index out of bounds) on line 751 (plugin "dod_ff_manager.amxx").
Line 751 is the line
Code:
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]

And sometimes, the server's console says too:
Code:
"Can't set * keys"
I've spent 4 hours with changing definitions of keys (MENU_KEY_X or 1<<X) but it does the same thing.

Please help me , 1 month on this plugin...
Colt is offline
 



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 17:27.


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