Raised This Month: $ Target: $400
 0% 

Dynamic items


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 07-24-2016 , 05:48   Re: Dynamic items
Reply With Quote #3

Try this:
PHP Code:
enum _:ItemData
{
    
ItemName32 ],
    
ItemCost
}; 
>
PHP Code:
enum _:ItemData
{
    
ItemName32 ],
    
ItemCost,
    
ItemTeam
}; 
------------------------------
PHP Code:
public _item_addiPluginiParams )
{
    
// create an array to hold our item data
    
new eItemDataItemData ];
    
    
// get item name from function
    
get_string1eItemDataItemName ], charsmaxeItemDataItemName ] ) );
    
    
// get item cost from function
    
eItemDataItemCost ] = get_param);
    
    
// add item to array and increase size
    
ArrayPushArrayg_aItemseItemData );
    
g_iTotalItems++;
    
    
// return the index of this item in the array
    // this creates the unique item index
    
return ( g_iTotalItems );

>
PHP Code:
public _item_addiPluginiParams )
{
    
// create an array to hold our item data
    
new eItemDataItemData ];
    
    
// get item name from function
    
get_string1eItemDataItemName ], charsmaxeItemDataItemName ] ) );
    
    
// get item cost from function
    
eItemDataItemCost ] = get_param);

    
// get item team from function
    
eItemDataItemTeam ] = clampget_param), 0);
    
    
// add item to array and increase size
    
ArrayPushArrayg_aItemseItemData );
    
g_iTotalItems++;
    
    
// return the index of this item in the array
    // this creates the unique item index
    
return ( g_iTotalItems );

------------------------------
PHP Code:
  for( new 0g_iTotalItemsi++ )
    {
        
// get item data from array
        
ArrayGetArrayg_aItemsieItemData );
        
        
// format item for menu
        
formatexszItemcharsmaxszItem ), "%s\R\y%i"eItemDataItemName ], eItemDataItemCost ] );
        
        
// pass array index to menu to find information about it later
        
num_to_striszNumcharsmaxszNum ) );
        
        
// add item to menu
        
menu_additemhMenuszItemszNum );
    } 
>
PHP Code:
  for( new 0g_iTotalItemsi++ )
    {
        
// get item data from array
        
ArrayGetArrayg_aItemsieItemData );
       
        if(
eItemDataItemTeam ] && (eItemDataItemTeam ] != cs_get_user_team(iPlayer)))
            continue;

        
// format item for menu
        
formatexszItemcharsmaxszItem ), "%s\R\y%i"eItemDataItemName ], eItemDataItemCost ] );
        
        
// pass array index to menu to find information about it later
        
num_to_striszNumcharsmaxszNum ) );
        
        
// add item to menu
        
menu_additemhMenuszItemszNum );
    } 
In .inc file:
PHP Code:
shop_item_add( const szName[ ], const iCost ); 
>
PHP Code:
shop_item_add( const szName[ ], const iCost, const iTeam ); // 0 = Both teams, 1 = Terrorist, 2 = Counter-Terrorist 

Last edited by KiLLeR.; 07-24-2016 at 06:38.
KiLLeR. 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 18:33.


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