AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Question about modular plugins (https://forums.alliedmods.net/showthread.php?t=121644)

Doc-Holiday 03-18-2010 03:58

Question about modular plugins
 
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);



Exolent[jNr] 03-18-2010 19:50

Re: Question about modular plugins
 
PHP Code:

#include <amxmodx>
#include <bfm>

new g_iClassIndex;

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

public 
bf_class_selectedidiClassIndex )
{
    if( 
g_iClassIndex == iClassIndex )
    {
        
// id chose medic class
    
}


PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <bfm>


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

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

public 
plugin_init()
{
    
g_aItems ArrayCreateItemsDatas );
    
g_forward CreateMultiForward"bf_class_selected"ET_IGNOREFP_CELLFP_CELL );
    
    
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;    
    
    
ExecuteForwardg_forwardg_returnidiSelectedClass );
    
    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);
    
g_iTotalItems++;
    
    return ( 
g_iTotalItems ); // you can't: return g_iTotalItems++; because it causes errors.


PHP Code:

#include <amxmodx>

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

forward bf_class_selectedidiClassIndex );

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);




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

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