AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help]Menu edit (https://forums.alliedmods.net/showthread.php?t=143197)

EDUTz 11-15-2010 22:31

[Help]Menu edit
 
1 Attachment(s)
Hi guys, i'm new on this forum (althoug i am a common guest for almost 2 years) and i have a little request if you might help me.

i have this plugin (attachment)


originaly it had 19 items to purchase, i did removed what i didn't need, but i have 2 little problems.

1) the menu it is like this:
1.item 1
2.item 2
...
7.item 7
8.back
9.next
0.exit

i tryed to remove some functions in shophandler but with no succes. when i removed the items i didn't need, i have only 9 .. so i don't realy need back si next. And i can't delete them from code.

2) in public give_respawn i did something like this

Code:

if (kills >= cost && !is_user_alive(id))
        {
                if(!(get_user_flags(id) & ADMIN_BAN))
                {
                if(cs_get_user_team(id) == CS_TEAM_T)
                {
                        cs_user_spawn(id)
                        cs_set_user_team(id, 1)
                }
               
                else if(cs_get_user_team(id) == CS_TEAM_CT)
                {
                        cs_user_spawn(id)
                        cs_set_user_team(id, 2)
                }
                }
                ColorChat(id, GREEN, "^x01[AMXX] ^x04%L", id, "GIVERESPAWN")
        }

i don't want admins to can buy this item when they are dead because when they are dead, they won't respawn corectly (they can see both teams so they are actualy a sort of spectators)

sorry for my bad english, please help if you can.
Cheers

edit: sorry fysiks, i edited my post, hope this is better

fysiks 11-15-2010 23:11

Re: [Help]Menu edit
 
For 1), you would need to switch to back to the basic menu method.



Quote:

Originally Posted by EDUTz (Post 1350367)
Hi guys, i'm new on this forum

Ok, so this is your warning, post a plugin as an attachment if it's more than a few hundred lines long (for the sake of my sanity).

EDUTz 11-16-2010 01:16

Re: [Help]Menu edit
 
Quote:

Originally Posted by fysiks (Post 1350371)
For 1), you would need to switch to back to the basic menu method.

easy to said than done, i am so noob in scripting. Although i learnead "pascal" language in school, c++ is a little different than what i do know. so i actualy don't realy know how to rebuild the menu. i just tried to remove some of the functions with no success ... i realize that i have to learn more, but for the moment this is my level. sorry :( for me it's 100 time harder to rebuild the menu than you guys. if you can help, please do so, else don't punish me 'cause i don't know scripting. i just want your help.

ps: i edited my first post, as fysiks said, i hope that's ok now

Emp` 11-16-2010 16:39

Re: [Help]Menu edit
 
To remove pagination, use the following code:
Code:

menu_setprop(menu, MPROP_PERPAGE, 0);
Also, you should note that the plugin is really poorly coded.

A small edit of the give_respawn function, and I came up with this for you:
Code:

public give_respawn(id)
{
        if(is_user_alive(id))
        {
                ColorChat(id, GREEN, "^x01[AMXX] ^x04%L", id, "ALIVE")
                return;
        }

        new cost = get_pcvar_num(respawncost)
       
        if ( (get_user_flags(id) & ADMIN_BAN) && (kills >= cost || randomn[id] == true) )
        {
                if(cs_get_user_team(id) == CS_TEAM_T)
                {
                        cs_user_spawn(id)
                        cs_set_user_team(id, 1)
                }
               
                else if(cs_get_user_team(id) == CS_TEAM_CT)
                {
                        cs_user_spawn(id)
                        cs_set_user_team(id, 2)
                }
                ColorChat(id, GREEN, "^x01[AMXX] ^x04%L", id, "GIVERESPAWN")

        }
       
        else
        {
                ColorChat(id, RED, "^x01[AMXX] ^x03%L", id, "NOBUY")
        }
}


fysiks 11-16-2010 20:28

Re: [Help]Menu edit
 
Quote:

Originally Posted by Emp` (Post 1350840)
To remove pagination, use the following code:
Code:

menu_setprop(menu, MPROP_PERPAGE, 0);

Wow, totally didn't think that worked for some reason. I guess that makes life easier :).

EDUTz 11-17-2010 04:53

Re: [Help]Menu edit
 
thank you fo helping me.
It seem that does the trick, altough the exit menu doesn't show up.

Quote:

Also, you should note that the plugin is really poorly coded.
yes, i know. I noticed that when i'm dead and in free look, it respawns me but i'm still in free look and it says something like you're stuck ... :cry:

Emp` 11-17-2010 13:37

Re: [Help]Menu edit
 
Quote:

Originally Posted by EDUTz (Post 1351106)
It seem that does the trick, altough the exit menu doesn't show up.

A simple way you can add an exit item back would be to do:
Code:

menu_additem(hnsmenu, "Exit", "0", ADMIN_ALL)
And you wouldn't need to edit any of the menu handler function.

abdul-rehman 11-18-2010 01:51

Re: [Help]Menu edit
 
Quote:

Originally Posted by Emp` (Post 1351368)
A simple way you can add an exit item back would be to do:
Code:

menu_additem(hnsmenu, "Exit", "0", ADMIN_ALL)
And you wouldn't need to edit any of the menu handler function.

But wont it require an edition in the menu handler function
Code:
public menu_handler ( .... ) // ... Lots of code     case 0: menu_destroy( menu_id )

Exolent[jNr] 11-18-2010 02:28

Re: [Help]Menu edit
 
Quote:

Originally Posted by abdul-rehman (Post 1351708)
But wont it require an edition in the menu handler function
Code:
public menu_handler ( .... ) // ... Lots of code     case 0: menu_destroy( menu_id )

No. If you looked at the code you would know that the menu is destroyed at the bottom of the handler.

EDUTz 11-18-2010 03:34

Re: [Help]Menu edit
 
thank you for the help. i couldn't do it without you.
Thanks a lot again , you are my hero :*


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

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