Raised This Month: $51 Target: $400
 12% 

[Ayuda] Dynamic Shop


  
 
 
Thread Tools Display Modes
Author Message
monster321
Member
Join Date: Apr 2012
Old 03-25-2013 , 08:34   [Ayuda] Dynamic Shop
#1

Buenas, mi problema es que coji el Dynamic menu By Exolent[jNr] y quisiera poner los items que se aņaden, segun el equipo. Es decir pondriamos " shop_item_add( "+HP", 1500, CS_TEAM_CT ) " o con el equipo de Terrorista y no tengo muy claro como hacerlo, si me pueden hechar una mano.

Gracias de antemano.

Code:
#include < amxmodx > #include < cstrike > #include < hamsandwich > enum _:ItemData {     ItemName[ 32 ],     ItemCost }; new Array:g_aItems; new g_iTotalItems; new g_hSelectItemForward; public plugin_init( ) {     register_plugin("Shop Dynamic", "1.0", "Exolent[jNr]")     register_clcmd("shop_menu", "shop_menu")     g_aItems = ArrayCreate( ItemData );     g_hSelectItemForward = CreateMultiForward( "shop_item_selected", ET_IGNORE, FP_CELL, FP_CELL ); } public plugin_natives( ) {     register_library( "shop" );     register_native( "shop_item_add", "_item_add" ); } public _item_add( iPlugin, iParams ) {     new eItemData[ ItemData ];     get_string( 1, eItemData[ ItemName ], charsmax( eItemData[ ItemName ] ) );     eItemData[ ItemCost ] = get_param( 2 );         ArrayPushArray( g_aItems, eItemData );     g_iTotalItems++;     return ( g_iTotalItems - 1 ); } public shop_menu( id, page ) {     if( !g_iTotalItems )         return;     page = clamp( page, 0, ( g_iTotalItems - 1 ) / 7 );     new menu = menu_create( "Shop Menu", "shop_handler" );     new eItemData[ ItemData ];     new szItem[ 64 ];     new szNum[ 3 ];         for( new i = 0; i < g_iTotalItems; i++ )     {         ArrayGetArray( g_aItems, i, eItemData );         formatex( szItem, charsmax( szItem ), "%s \r[ \y%i\r ]", eItemData[ ItemName ], eItemData[ ItemCost ] );         num_to_str( i, szNum, charsmax( szNum ) );         menu_additem( menu, szItem, szNum );     }     menu_display( id, menu, page ); } public shop_handler( id, menu, item ) {     if( item == MENU_EXIT )     {         menu_destroy( menu );         return;     }         new iAccess, szNum[ 3 ], hCallback;     menu_item_getinfo( menu, item, iAccess, szNum, charsmax( szNum ), _, _, hCallback );     menu_destroy( menu );         new itemIndex = str_to_num( szNum );     new eItemData[ ItemData ];     ArrayGetArray( g_aItems, itemIndex, eItemData );     new money = cs_get_user_money( id ) - eItemData[ ItemCost ];     if( money < 0 )     {         client_print( id, print_chat, "[ ShopMenu ] No tienes suficiente dinero." );     }     else     {         cs_set_user_money( id, money );         new iReturn;         ExecuteForward( g_hSelectItemForward, iReturn, id, itemIndex );     } }

Last edited by monster321; 03-25-2013 at 08:46.
monster321 is offline
Send a message via MSN to monster321 Send a message via Skype™ to monster321
Especialista
BANNED
Join Date: Mar 2013
Old 03-25-2013 , 18:17   Re: [Ayuda] Dynamic Shop
#2

PHP Code:

#include < amxmodx >
#include < cstrike >
#include < hamsandwich >

new g_tt[33], g_ct[33]

enum _:ItemData
{
    
ItemName32 ],
    
ItemCost
};

new Array:
g_aItems;
new 
g_iTotalItems;
new 
g_hSelectItemForward;

public 
plugin_init( )
{
    
register_plugin("Shop Dynamic""1.0""Exolent[jNr]")
    
register_clcmd("shop_menu""shop_menu")

    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
    
g_aItems ArrayCreateItemData );
    
g_hSelectItemForward CreateMultiForward"shop_item_selected"ET_IGNOREFP_CELLFP_CELL );
}
public 
plugin_natives( )
{
    
register_library"shop" );
    
register_native"shop_item_add""_item_add" );
}
public 
fw_PlayerSpawn_Post(id)
{
    if(!
is_user_connected(id))  
        return 
HAM_IGNORED;  

    if (
get_user_team(id) == 1)
    {
        
g_tt[id] = 1
        g_ct
[id] = 0
    
}
    else if (
get_user_team(id) == 2)
    {
        
g_tt[id] = 0
        g_ct
[id] = 1
    
}
    
    return 
HAM_IGNORED;
}
public 
_item_addiPluginiParams )
{
    new 
eItemDataItemData ];
    
get_string1eItemDataItemName ], charsmaxeItemDataItemName ] ) );
    
eItemDataItemCost ] = get_param);
    
    
ArrayPushArrayg_aItemseItemData );
    
g_iTotalItems++;

    return ( 
g_iTotalItems );
}
public 
shop_menuidpage )
{
    if( !
g_iTotalItems )
        return;
    
    if(
g_ct[id] == 1// menu ct
    
{

    
page clamppage0, ( g_iTotalItems ) / );

    new 
menu menu_create"Shop Menu""shop_handler" );

    new 
eItemDataItemData ];
    new 
szItem64 ];
    new 
szNum];
    
    for( new 
0g_iTotalItemsi++ )
    {
        
ArrayGetArrayg_aItemsieItemData );
        
formatexszItemcharsmaxszItem ), "%s r[ y%ir ]"eItemDataItemName ], eItemDataItemCost ] );
        
num_to_striszNumcharsmaxszNum ) );
        
menu_additemmenuszItemszNum );
    }
    
menu_displayidmenupage );
    
    }
    
    else 
// menu tt
    
{
        
    
page clamppage0, ( g_iTotalItems ) / );

    new 
menu menu_create"Shop Menu""shop_handler" );

    new 
eItemDataItemData ];
    new 
szItem64 ];
    new 
szNum];
    
    for( new 
0g_iTotalItemsi++ )
    {
        
ArrayGetArrayg_aItemsieItemData );
        
formatexszItemcharsmaxszItem ), "%s r[ y%ir ]"eItemDataItemName ], eItemDataItemCost ] );
        
num_to_striszNumcharsmaxszNum ) );
        
menu_additemmenuszItemszNum );
    }
    
menu_displayidmenupage );
    
    }
}
public 
shop_handleridmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return;
    }
    
    new 
iAccessszNum], hCallback;
    
menu_item_getinfomenuitemiAccessszNumcharsmaxszNum ), __hCallback );
    
menu_destroymenu );
    
    new 
itemIndex str_to_numszNum );
    new 
eItemDataItemData ];
    
ArrayGetArrayg_aItemsitemIndexeItemData );

    new 
money cs_get_user_moneyid ) - eItemDataItemCost ];
    if( 
money 
    {
        
client_printidprint_chat"[ ShopMenu ] No tienes suficiente dinero." );
    }
    else
    {
        
cs_set_user_moneyidmoney );

        new 
iReturn;
        
ExecuteForwardg_hSelectItemForwardiReturniditemIndex );
    }

no se si es asi como lo quieres. pero si no lo es solo usa asi.

PHP Code:
// condicion ct:

if(g_ct[id] == 1// si es ct.
{
          
// code
}
else 
// si es tt.
{
          
// code

Especialista is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 03-25-2013 , 19:23   Re: [Ayuda] Dynamic Shop
#3

Quote:
Originally Posted by Especialista View Post
no se si es asi como lo quieres. pero si no lo es solo usa asi.
por favor; si vas a comentar q sea con conocimiento;

tenes que hacer un plugin separado con el shop...

la native "shop_item_add" te devuelve el id de dicho item que agregaste el cual cuando lo selecciona se llama la forward "shop_item_selected" en la cual chequeas el id del item que selecciono para ejecutar la funcion adecuada
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
Especialista
BANNED
Join Date: Mar 2013
Old 03-25-2013 , 19:59   Re: [Ayuda] Dynamic Shop
#4

tienes razon no lo pense... gracias

monster entonces crea 2 shop.

y usa la condicion que te dije para que cada shop sea de el equipo que quieras.


perdon otra ves . no lo pense. lo hize rapido. gracias rak por correjirme.
Especialista is offline
arslan
BANNED
Join Date: Feb 2013
Location: En mi CASA jjejejejej
Old 03-27-2013 , 13:00   Re: [Ayuda] Dynamic Shop
#5

monster321 mira:

En vez de [CODE] --> [PHP]
arslan is offline
Send a message via MSN to arslan Send a message via Yahoo to arslan Send a message via Skype™ to arslan
StrikerV2
Senior Member
Join Date: Nov 2012
Location: Chile , O Yes!
Old 03-27-2013 , 13:06   Re: [Ayuda] Dynamic Shop
#6

Quote:
Originally Posted by arslan View Post
monster321 mira:

En vez de [CODE] --> [PHP]
eso da exactamente lo mismo ;3 , mientras este ordenado .
__________________
Mi firma era tan sexy .-.
StrikerV2 is offline
Send a message via MSN to StrikerV2
DJHD!
Veteran Member
Join Date: Dec 2009
Location: Santiago, Chile
Old 03-27-2013 , 15:02   Re: [Ayuda] Dynamic Shop
#7

Quote:
Originally Posted by StrikerV2 View Post
eso da exactamente lo mismo ;3 , mientras este ordenado .
No da lo mismo, lee las reglas.
__________________
Quote:
Originally Posted by XINLEI View Post
Porque rocccos trata de ser el metalicross que nunca va a poder ser.

Last edited by DJHD!; 03-27-2013 at 15:02.
DJHD! is offline
Send a message via MSN to DJHD!
 



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 00:05.


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