Try this:
PHP Code:
enum _:ItemData
{
ItemName[ 32 ],
ItemCost
};
>
PHP Code:
enum _:ItemData
{
ItemName[ 32 ],
ItemCost,
ItemTeam
};
------------------------------
PHP Code:
public _item_add( iPlugin, iParams )
{
// create an array to hold our item data
new eItemData[ ItemData ];
// get item name from function
get_string( 1, eItemData[ ItemName ], charsmax( eItemData[ ItemName ] ) );
// get item cost from function
eItemData[ ItemCost ] = get_param( 2 );
// add item to array and increase size
ArrayPushArray( g_aItems, eItemData );
g_iTotalItems++;
// return the index of this item in the array
// this creates the unique item index
return ( g_iTotalItems - 1 );
}
>
PHP Code:
public _item_add( iPlugin, iParams )
{
// create an array to hold our item data
new eItemData[ ItemData ];
// get item name from function
get_string( 1, eItemData[ ItemName ], charsmax( eItemData[ ItemName ] ) );
// get item cost from function
eItemData[ ItemCost ] = get_param( 2 );
// get item team from function
eItemData[ ItemTeam ] = clamp( get_param( 3 ), 0, 2 );
// add item to array and increase size
ArrayPushArray( g_aItems, eItemData );
g_iTotalItems++;
// return the index of this item in the array
// this creates the unique item index
return ( g_iTotalItems - 1 );
}
------------------------------
PHP Code:
for( new i = 0; i < g_iTotalItems; i++ )
{
// get item data from array
ArrayGetArray( g_aItems, i, eItemData );
// format item for menu
formatex( szItem, charsmax( szItem ), "%s\R\y%i", eItemData[ ItemName ], eItemData[ ItemCost ] );
// pass array index to menu to find information about it later
num_to_str( i, szNum, charsmax( szNum ) );
// add item to menu
menu_additem( hMenu, szItem, szNum );
}
>
PHP Code:
for( new i = 0; i < g_iTotalItems; i++ )
{
// get item data from array
ArrayGetArray( g_aItems, i, eItemData );
if(eItemData[ ItemTeam ] && (eItemData[ ItemTeam ] != cs_get_user_team(iPlayer)))
continue;
// format item for menu
formatex( szItem, charsmax( szItem ), "%s\R\y%i", eItemData[ ItemName ], eItemData[ ItemCost ] );
// pass array index to menu to find information about it later
num_to_str( i, szNum, charsmax( szNum ) );
// add item to menu
menu_additem( hMenu, szItem, szNum );
}
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