Raised This Month: $ Target: $400
 0% 

error 033: array must be indexed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
moosewanted
Member
Join Date: May 2009
Old 05-25-2009 , 19:39   error 033: array must be indexed
Reply With Quote #1

An extract from a plugin I'm making.
I guess what the error means is that the array used in teleother_confirm_menu = menu_create(teleother_confirm_menu_name[id],"teleother_confirm_menu_handle") must be constant but im using a variable

I tried to fix it by formatting a string with the id already in it but it doesn't work.

PHP Code:
new teleother_confirm_menu[33]
new 
teleother_confirm_menu_name[33][58]


public 
teleother(idtargetid)
{
    new 
Arg1[32]
    
read_argv(1Arg131)
    new 
targetplayer cmd_target(idArg14)
    
    if(!
targetplayer)
    {
        
client_print(idprint_chat"%s Sorry, player %s could not be found or targetted!"PLUGIN_SNAMEArg1)
        return 
PLUGIN_HANDLED
    
}
    else
    {
        new 
username[32]
        
get_user_name(targetplayerusername31)

        
format(teleother_confirm_menu_name[id], 57"%s would like you to join them"username)
        new 
menu_name[32]
        
format(menu_name31"teleother_confirm_menu_name[%i]"id)
        new 
menu_id[27]
        
format(menu_id26"teleother_confirm_menu[%i]"id)
        
teleother_confirm_menu menu_create(menu_name,"teleother_confirm_menu_handle")
        
menu_additem(menu_id"yes"id)
        
menu_additem(menu_id"no"id)

        
menu_display(targetplayermenu_id0)
    }

I can't really think at the moment, perhaps I am to tired but I would appreciate some help.
Thanks.

EDIT:

Other problem. The reason I have used arrays for a menu is because I couldn't think of any other way.
What I thought:
The menu is specific to a single player, so it can't be global/constant because then it wouldn't be specific as each player would see the same menu?

Solution, have many different menu's?

EDIT2: This code is so baad >.<

Last edited by moosewanted; 05-25-2009 at 19:45.
moosewanted is offline
Starsailor
horrible hahah
Join Date: Aug 2008
Location: Buenos Aires
Old 05-25-2009 , 20:26   Re: error 033: array must be indexed
Reply With Quote #2

That code is so bad
__________________
Find my plugins here..

Ex - Spanish Moderator.
Starsailor is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-25-2009 , 21:08   Re: error 033: array must be indexed
Reply With Quote #3

Try this chief:

PHP Code:
teleother_confirm_menu menu_create(menu_name,"teleother_confirm_menu_handle"
should be

PHP Code:
teleother_confirm_menu[id] = menu_create(menu_name,"teleother_confirm_menu_handle"
__________________
Bugsy is offline
moosewanted
Member
Join Date: May 2009
Old 05-25-2009 , 21:19   Re: error 033: array must be indexed
Reply With Quote #4

Yeh, I should have worked that out from the compiler error. Thanks. Also, how would I pass a variable in:

menu_additem(menu_id, "no", id)

as id errors to:
error 035: argument type mismatch (argument 3)

Last edited by moosewanted; 05-25-2009 at 21:22.
moosewanted is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-25-2009 , 23:30   Re: error 033: array must be indexed
Reply With Quote #5

Quote:
Originally Posted by moosewanted View Post
Yeh, I should have worked that out from the compiler error. Thanks. Also, how would I pass a variable in:

menu_additem(menu_id, "no", id)

as id errors to:
error 035: argument type mismatch (argument 3)
The third argument must be a string (link).

You can parse multiple data into the third argument and then extract it later. That is only one suggestion, there might be better ways.
__________________
fysiks is offline
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 01:35.


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