Raised This Month: $ Target: $400
 0% 

Question about modular plugins


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-18-2010 , 03:58   Question about modular plugins
Reply With Quote #1

Ok so in my small il plugin family I have my main plugin which will hold all of my experience and ranks and what not as well as my cvars.. So for my question

How would i do something like this..
The below takes the Medic and shows it to both teams on a menu.

If i was to choose this how would i make it known to the child plugin that that was my selection and to every spawn give me my items and skills?

If you dont understand what i mean i can try to explain it better.

But basically like super hero.. If i add say DocHoliday to my super hero server What part of SH allows my added class to know i chose it?

Also how would i add Cvars using something like (Since each class will change those cvars) and then have a stock give those items and skills to each player at spawn (can be achieved by a multi forward i think just not sure how)

PHP Code:
enum _:CRCVAR
{
    
CVAR_PWEP,
    
CVAR_SWEP,
    
CVAR_HEALTH,
    
CVAR_ARMOR,
    
CVAR_SPEED,
    
CVAR_GRAVITY,
    
CVAR_INVIS,
    
CVAR_HEAL
}

new 
g_Cvar CRCVAR ] [ Class ] [ Rank ]; 
PHP Code:
#include <amxmodx>
#include <bfm>

public plugin_init()
{
    
reg_bf_class("Medic""b")

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <bfm>


enum _:ItemsDatas {
    
Item_Name[32],
    
Item_Team
}

new Array:
g_aItems;
new 
g_mItems[ItemsDatas];
new 
bool:AlreadyShown[33] = falsebool:ChooseNew[33];

public 
plugin_init()
{
    
g_aItems ArrayCreateItemsDatas );
    
    
RegisterHam(Ham_Spawn"player""OnMenuSelect"1);
}

public 
plugin_natives()
{
    
register_native("reg_bf_class""register_battlefield_class");
}

public 
PlayerSpawn(id)
{
    if(
is_user_alive(id))
    {
        if(
ChooseNew[id])
        {
            
MenuDisplayer(id);
        }
        if(
AlreadyShown[id])
        {
            
//Multi Forward to set skills and give items according to Rank
        
}
    }
}

public 
MenuDisplayer(id)
{
    new 
iTeam get_user_team(id)
    new 
iMenu menu_create("Battlefield" "HandleClassMenu")
    new 
i_Size ArraySizeg_aItems )
    new 
szNum[3]
    for ( new 
0i_Size; ++)
    {
        
// Use to get the data from array
        
ArrayGetArrayg_aItemsig_mItems );
        if(
g_mItems[Item_Team] & iTeam)
        {
            
num_to_str(iszNumcharsmax(szNum))
            
menu_additemiMenu g_mItems[Item_Name] , szNum );
        }
    }
    
menu_setpropiMenu MPROP_EXIT MEXIT_NEVER ); 
    
menu_displayid iMenu );
}

public 
HandleClassMenuid iMenu iItem 
{
    new 
szKey] , iSelectedClass Dummy;
    
menu_item_getinfoiMenu iItem Dummy szKey "" Dummy );
    
    
iSelectedClass str_to_numszKey );
    
AlreadyShown[id] = true;
    
ChooseNew[id] = false;    
    
    return 
PLUGIN_HANDLED;
}

public 
register_battlefield_class(iPluginiParams)
{
    new 
szTeam[2];
    
    
get_string(1g_mItems[Item_Name], charsmax(g_mItems[Item_Name]));
    
get_string(2szTeamcharsmax(szTeam)) 
    
    switch( 
szTeam[0] )
    {
        case 
't','T' :
        {
            
g_mItems[Item_Team] = 1
        
}
        case 
'c','C' :
        {
            
g_mItems[Item_Team] = 2
        
}
        case 
'b','B' :
        {
            
g_mItems[Item_Team] = 2
        
}
    }
    
    
ArrayPushArray(g_aItemsg_mItems);

PHP Code:
#include <amxmodx>

native reg_bf_class(const name[], const team[])

stock bf_precache_model(const fmt[], any:...)
{
    new 
filename[128];
    
vformat(filenamecharsmax(filename), fmt2);
    return 
precache_model(filename);
}

// Precache Sound
stock bf_precache_sound(const fmt[], any:...)
{
    new 
filename[128];
    
vformat(filenamecharsmax(filename), fmt2);
    return 
precache_sound(filename);

Doc-Holiday is offline
 



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 08:44.


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