Raised This Month: $ Target: $400
 0% 

HELP Best way to do


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Toallin
Junior Member
Join Date: Jun 2014
Old 06-24-2014 , 15:48   HELP Best way to do
Reply With Quote #1

Good for all.
What happens is I search the best way to do this code
not what you think if you could improve or if they stay well.

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /lr""ShowMenuLR")
}

public 
ShowMenuLR(id)
{
    new 
menu menu_create("last request""CmdMenuLR")
    
    
menu_additem(menu"Duel Knife""1")
    
menu_additem(menu"Duel Scouts""2")
    
    
menu_display(idmenu)
}

public 
CmdMenuLR(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    
    switch(
item)
    {
        case 
0ShowListCT(id)
        case 
1ShowListCT(id)
    }
    return 
PLUGIN_HANDLED;
}

public 
ShowListCT(id)
{
    new 
menu menu_create("go to fight""CmdListCT")
    
    new 
iPlayers[32], pnumtempid
    
new iName[32], szTempid[10]
    
    
get_players(iPlayerspnum"aeh""CT")
    
    for(new 
0pnumi++)
    {
        
tempid iPlayers[i]
        
        
get_user_name(tempidiNamecharsmax(iName))
        
num_to_str(tempidszTempidcharsmax(szTempid))
        
menu_additem(menuiNameszTempid)
    }
    
    
menu_display(idmenu)
    return 
PLUGIN_HANDLED;
}

public 
CmdListCT(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], iName[64]; 
    new 
accesscallback
    
menu_item_getinfo(menuitemaccessdatacharsmax(data), iNamecharsmax(iName), callback)
    
    
// bla bla

The plugin is a menu of modes all have a list of players to fight with each mode is different but not if they could do any better Thank you.

Last edited by Toallin; 06-24-2014 at 15:49.
Toallin is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-24-2014 , 15:59   Re: HELP Best way to do
Reply With Quote #2

Why you switch the item, where all the results are the same?
PHP Code:
    switch(item)
    {
        case 
0ShowListCT(id)
        case 
1ShowListCT(id)
    } 
Doesn't make any sense, just call the function in the handler.
Also you have to put many checks in those functions, because if the guy, who is calling the duel is dead, the duel won't be achieved, right?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Toallin
Junior Member
Join Date: Jun 2014
Old 06-24-2014 , 19:40   Re: HELP Best way to do
Reply With Quote #3

understand then only have to call the function 1 time for all options and if the player is not live function not met.
Thanks Flick3rR.

Aprobechando the thread Might help to identify each mode? for example if you choose the knife so you open the menu of players and the player to select the knife so start on these 2 players and if you choose the same mode but scout the scout mode is enabled.

PHP Code:
enum {
    
DUEL_NONE,
    
DUEL_KNIFE,
    
DUEL_SCOUTS

Toallin is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-25-2014 , 05:13   Re: HELP Best way to do
Reply With Quote #4

You want to know which duel is currently running ? Then, do it with a simple boolean.

PHP Code:
enum _eDuels
{
    
DUEL_NONE,
    
DUEL_SCOUT,
    
DUEL_KNIFE

}

new 
boolIsDuel eDuels 
When he choose knife duel:
PHP Code:
IsDuel DUEL_NONE   ] = false
IsDuel 
DUEL_SCOUT  ] = false
IsDuel 
DUEL_KNIFE  ] = true 
When he choose a scout duel:
PHP Code:
IsDuel DUEL_NONE   ] = false
IsDuel 
DUEL_SCOUT  ] = true
IsDuel 
DUEL_KNIFE  ] = false 
When a duel ends:
PHP Code:
IsDuel DUEL_NONE   ] = true
IsDuel 
DUEL_SCOUT  ] = false
IsDuel 
DUEL_KNIFE  ] = false 
When you give weapons or sth like this, just check which bool is true.

PHP Code:
if ( ! IsDuel DUEL_NONE ] ) {

    if ( 
IsDuel DUEL_SCOUT ] ) {
        
//we have a scout duel
        
        
    
}   
    
    if ( 
IsDuel DUEL_KNIFE ] ){
       
//we have a knife duel
    
    
    
}

I don't know what you want to do with duel_none, but based on your previous example, this is how you should do it, whatever it is.

Last edited by HamletEagle; 06-25-2014 at 05:15.
HamletEagle is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 06-25-2014 , 06:00   Re: HELP Best way to do
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
You want to know which duel is currently running ? Then, do it with a simple boolean.

PHP Code:
enum _eDuels
{
    
DUEL_NONE,
    
DUEL_SCOUT,
    
DUEL_KNIFE

}

new 
boolIsDuel eDuels 
When he choose knife duel:
PHP Code:
IsDuel DUEL_NONE   ] = false
IsDuel 
DUEL_SCOUT  ] = false
IsDuel 
DUEL_KNIFE  ] = true 
When he choose a scout duel:
PHP Code:
IsDuel DUEL_NONE   ] = false
IsDuel 
DUEL_SCOUT  ] = true
IsDuel 
DUEL_KNIFE  ] = false 
When a duel ends:
PHP Code:
IsDuel DUEL_NONE   ] = true
IsDuel 
DUEL_SCOUT  ] = false
IsDuel 
DUEL_KNIFE  ] = false 
When you give weapons or sth like this, just check which bool is true.

PHP Code:
if ( ! IsDuel DUEL_NONE ] ) {

    if ( 
IsDuel DUEL_SCOUT ] ) {
        
//we have a scout duel
        
        
    
}   
    
    if ( 
IsDuel DUEL_KNIFE ] ){
       
//we have a knife duel
    
    
    
}

I don't know what you want to do with duel_none, but based on your previous example, this is how you should do it, whatever it is.
Stupid and wrong.
PHP Code:
enum _eDuels
{
    
DUEL_NONE,
    
DUEL_SCOUT,
    
DUEL_KNIFE

}

new 
IsDuel;

// when you need, set duel
IsDuel DUEL_SCOUT;

// when you need, check duel
if(IsDuel == DUEL_SCOUT
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-25-2014 , 06:41   Re: HELP Best way to do
Reply With Quote #6

Quote:
Originally Posted by GuskiS View Post
Stupid and wrong.
PHP Code:
enum _eDuels
{
    
DUEL_NONE,
    
DUEL_SCOUT,
    
DUEL_KNIFE

}

new 
IsDuel;

// when you need, set duel
IsDuel DUEL_SCOUT;

// when you need, check duel
if(IsDuel == DUEL_SCOUT
It's not stupid and it's not wrong. May not be what he wanted, cause I didn't understand his post.

Last edited by HamletEagle; 06-25-2014 at 06:42.
HamletEagle is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 06-25-2014 , 06:48   Re: HELP Best way to do
Reply With Quote #7

Just look on a approved last request code on alliedmodders.
It will show you how to do it the best way
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 06-25-2014 , 13:38   Re: HELP Best way to do
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
It's not stupid and it's not wrong. May not be what he wanted, cause I didn't understand his post.
How is that right? Allocating more memory then you need is right? Then doing those things x times?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Toallin
Junior Member
Join Date: Jun 2014
Old 06-25-2014 , 12:23   Re: HELP Best way to do
Reply With Quote #9

is that by choosing any option opens the menu to choose to play with
I was looking knife selecting mode by selecting the player to play with the knife mode is activated by selecting scout mode equals.
Toallin 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 21:07.


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