Raised This Month: $ Target: $400
 0% 

Menuitems from ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silent9681
Member
Join Date: Jan 2012
Location: Hungary
Old 07-07-2012 , 15:03   Menuitems from ini
Reply With Quote #1

Hi. I want a plugin, that makes a menu with items from an ini file. So I have an ini file like this:

PHP Code:
MenuItem1
MenuItem2
MenuItem3
andsoon 
And the menuitems will be MenuItem1, MenuItem2 and MenuItem3.

I've tried to make it, but i've an error:

PHP Code:
argument type mismatch (argument 3
My piece of code:

PHP Code:
        if (file_exists(usercfg))
        {
                while ((
line read_file(usercfglinelinetext256linetextlength)))
                {
                        if(
linetext[0] == ';')
                        {
                                continue
                        }
                        
menu_additem(menulinetextlineADMIN_KICK); //this is the error
                
}
        } 

Than i have another error:

PHP Code:
must be a constant expressionassumed zero 
And this is another piece of code:

PHP Code:
    switch(key)
    {
        case 
line//this is the error
        
{
            
client_cmd(0"mp3 play sound/silent_productions/admin_musics/%s.mp3"linetext);
            
client_print(0print_chat"%s zene admin altal elinditva"linetext);
        }
    }
    return 
1
Thank you in advance, sry for my bad english.

Edit:
realised that the 3rd param needs a string, but will this solve the second error too? :/
__________________
Sorry for my bad english
Hungarian/Magyar forum:
http://amxmodx.crys.hu/site/forum/

Last edited by Silent9681; 07-07-2012 at 15:32. Reason: Wrong title :)
Silent9681 is offline
Send a message via MSN to Silent9681
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 07-07-2012 , 16:29   Re: Menuitems from ini
Reply With Quote #2

Last param is a callback , search the Emp's menu tuto.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-07-2012 , 22:38   Re: Menuitems from ini
Reply With Quote #3

Don't use read_file(). Use fopen(), fgets(), and fclose(). See a file tutorial.
You can't use a variable as a case. It must be a constant. To me, it looks like you don't even need a switch. If you just pass the sound name as the "data" parameter in the add menu item function then you can just use that for the command to play the sound.
__________________
fysiks is offline
Silent9681
Member
Join Date: Jan 2012
Location: Hungary
Old 07-08-2012 , 03:05   Re: Menuitems from ini
Reply With Quote #4

Thanks both. Fysiks can you give me a file tutorial and can you show me an example of playing music from menu by a list of menuitems from ini file?

Thank you.
__________________
Sorry for my bad english
Hungarian/Magyar forum:
http://amxmodx.crys.hu/site/forum/
Silent9681 is offline
Send a message via MSN to Silent9681
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-08-2012 , 03:21   Re: Menuitems from ini
Reply With Quote #5

Quote:
Originally Posted by Silent9681 View Post
Thanks both. Fysiks can you give me a file tutorial and can you show me an example of playing music from menu by a list of menuitems from ini file?

Thank you.
So you want me to write the plugin for you . . .

I already told you how to do the menu part but maybe it might help to know that in the documentation for menu_additem() the "command" argument is the argument to which I am refering when I say "data".

EDIT: I thought there was a tutorial for files but I see there is isn't a good one so for using the file functions you can look at plugins that use it already. A simple example is my Bot Apology plugin (in my signature).
__________________

Last edited by fysiks; 07-08-2012 at 03:29.
fysiks is offline
Silent9681
Member
Join Date: Jan 2012
Location: Hungary
Old 07-08-2012 , 03:45   Re: Menuitems from ini
Reply With Quote #6

No. I don't want to write me the whole plugin. I want to write it by myself. I just don't know wat exactly is "pass the sound name as data". If you explain it, i will be able to write it
__________________
Sorry for my bad english
Hungarian/Magyar forum:
http://amxmodx.crys.hu/site/forum/
Silent9681 is offline
Send a message via MSN to Silent9681
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 07-08-2012 , 10:08   Re: Menuitems from ini
Reply With Quote #7

Are you searching a menu that has music from an ini?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Silent9681
Member
Join Date: Jan 2012
Location: Hungary
Old 07-08-2012 , 10:29   Re: Menuitems from ini
Reply With Quote #8

yes
__________________
Sorry for my bad english
Hungarian/Magyar forum:
http://amxmodx.crys.hu/site/forum/
Silent9681 is offline
Send a message via MSN to Silent9681
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 07-08-2012 , 11:06   Re: Menuitems from ini
Reply With Quote #9

Spoiler


I do this some time ago , and the ini config :

PHP Code:
"Linkin Park - New Divide" "music/lp/newdivide.mp3"
"System Of A Down - Psycho" "music/soad/psycho.mp3"
"System Of A Down - Chop Suey!" "music/soad/chop_suey.mp3"
"Linkin Park - No More Sorrow" "music/lp/no_more_sorrow.mp3"
"Rammstein - Du Hast" "music/r/du_hast.wav" 
(Music is example)
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 07-08-2012 at 11:35.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Silent9681
Member
Join Date: Jan 2012
Location: Hungary
Old 07-08-2012 , 12:09   Re: Menuitems from ini
Reply With Quote #10

Thanks a lot
__________________
Sorry for my bad english
Hungarian/Magyar forum:
http://amxmodx.crys.hu/site/forum/
Silent9681 is offline
Send a message via MSN to Silent9681
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 15:15.


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