AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menuitems from ini (https://forums.alliedmods.net/showthread.php?t=189479)

Silent9681 07-07-2012 15:03

Menuitems from ini
 
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? :/

lucas_7_94 07-07-2012 16:29

Re: Menuitems from ini
 
Last param is a callback , search the Emp's menu tuto.

fysiks 07-07-2012 22:38

Re: Menuitems from ini
 
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.

Silent9681 07-08-2012 03:05

Re: Menuitems from ini
 
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.

fysiks 07-08-2012 03:21

Re: Menuitems from ini
 
Quote:

Originally Posted by Silent9681 (Post 1745871)
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).

Silent9681 07-08-2012 03:45

Re: Menuitems from ini
 
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 :D

lucas_7_94 07-08-2012 10:08

Re: Menuitems from ini
 
Are you searching a menu that has music from an ini?

Silent9681 07-08-2012 10:29

Re: Menuitems from ini
 
yes

lucas_7_94 07-08-2012 11:06

Re: Menuitems from ini
 
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)

Silent9681 07-08-2012 12:09

Re: Menuitems from ini
 
Thanks a lot :)


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

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