Raised This Month: $ Target: $400
 0% 

API Thing for menu items


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
NiQu
Veteran Member
Join Date: Nov 2009
Old 12-21-2011 , 19:39   API Thing for menu items
Reply With Quote #1

Hi, I'm making an API to make it easier to create new menu based/xp based mods. One of the features of the API is a way to change how the menu looks and operates, for example, you can choose to have a T Menu and a CT Menu(menustyle1) or to have just one menu for both teams(menustyle0).

I have a cvar to do this and it seems to work just fine but it requires the item plugin to be changed.

I want to know if i should use only one plugin per item and just code both menustyle0(default) and menustyle1 in the same plugin, or if i should make maybe three plugins for each item(1 for menustyle0 and 2 for menustyle1), or two plugins for each item(1 for menustyle0 and 1 for menustyle1).

I dont know what the best option is, that's why I'm asking.
Also, i don't know if this thread is in the correct section.

Example for menustyle0 and menustyle1 in the same plugin:
PHP Code:
#include <amxmodx>
#include <fun>
#include <modapi>

#define PLUGIN "MAPI: Health"
#define VERSION "0.0.1"
#define AUTHOR "ReCon & TandborsteN"

new DESCRIPTION[128] = "You get x HP every time you spawn.";
new 
SAVENAME[33];
new 
SAVENAME_T[33];
new 
SAVENAME_CT[33];
new 
ALLCOST[33];
new 
TCOST[33];
new 
CTCOST[33];

enum _:PCVARS
{
    
NAME,
    
COST,
    
MAXLEVEL,
    
MAXAMOUNT,
    
SAVEID
};
new 
g_PC[PCVARS];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
//PCVARS
    
g_PC[NAME] =         register_cvar("mapi_hp_name",         "Health");
    
g_PC[COST] =        register_cvar("mapi_hp_cost",        "250 200");
    
g_PC[MAXLEVEL] =     register_cvar("mapi_hp_maxlevel",     "5");
    
g_PC[MAXAMOUNT] =     register_cvar("mapi_hp_maxamount",    "100");
    
g_PC[SAVEID] =        register_cvar("mapi_hp_savename",    "Health");
    
    new 
t_name[32];
    
get_pcvar_string(g_PC[NAME], t_namesizeof(t_name) - 1);
    
get_pcvar_string(g_PC[SAVEID], SAVENAMEcharsmax(SAVENAME));
    
get_pcvar_string(g_PC[COST], ALLCOSTcharsmax(ALLCOST));
    
    
strtok(ALLCOSTTCOSTcharsmax(TCOST), CTCOSTcharsmax(CTCOST), ' ');
    
    
formatex(SAVENAME_Tcharsmax(SAVENAME_T), "%s_T"SAVENAME);
    
formatex(SAVENAME_CTcharsmax(SAVENAME_T), "%s_CT"SAVENAME);
    
    if(
mapi_get_menustyle() == 1) {
        
mapi_register_item(t_nameDESCRIPTIONstr_to_num(TCOST), 1,\
        
get_pcvar_num(g_PC[MAXLEVEL]), get_pcvar_num(g_PC[MAXAMOUNT]), 1"OnSpawn"SAVENAME_T"T""T");
        
        
mapi_register_item(t_nameDESCRIPTIONstr_to_num(CTCOST), 1,\
        
get_pcvar_num(g_PC[MAXLEVEL]), get_pcvar_num(g_PC[MAXAMOUNT]), 1"OnSpawn"SAVENAME_CT"CT""CT");
    } else {
        
mapi_register_item(t_nameDESCRIPTIONstr_to_num(TCOST), 1,\
        
get_pcvar_num(g_PC[MAXLEVEL]), get_pcvar_num(g_PC[MAXAMOUNT]), 1"OnSpawn"SAVENAME"NONE");
    }
}

public 
_OnSpawn(id) {
    
Set_Health(id);
}

public 
Set_Health(id) {
    if(
mapi_get_item_level(idSAVENAME) >= 1) {
        
set_user_health(idget_pcvar_num(g_PC[MAXAMOUNT]) / get_pcvar_num(g_PC[MAXLEVEL]) * mapi_get_item_level(idSAVENAME) + 100);
    }

As you can see, the item has to be registered three times in total and this has me a bit worried on the larger items such as weapon chance where there are multiple items registered in the same plugin.

I just want to know what the best option would be.
__________________
My Projects
  • RoTAPI V0.0.1 ------- Private
    • Progress - [||||||||||]
  • CashMod V0.0.6 ----- Public
    • Progress - [||||||||||]
  • CashMod V0.0.7 ----- Public
    • Progress - [||||||||||]

Last edited by NiQu; 12-21-2011 at 19:50.
NiQu is offline
 


Thread Tools
Display Modes

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 11:48.


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