Hola, como les va papus:u
El problema ahora es que al comprar cualquier item el conteo solo funciona en el item 2 y al querer comprar otro item no me deja comprarlo y me dice que faltan segundos negativos como verán en la imagen.
Imagen:
Código:
El problema ahora es que al comprar cualquier item el conteo solo funciona en el item 2 y al querer comprar otro item no me deja comprarlo y me dice que faltan segundos negativos como verán en la imagen.
Imagen:
Código:
Código PHP:
#include <amxmodx>
new const szPlugin[ ][ ] = { "Shop per time", "1.0", "Sky^^" };
new const szPrefix[ ][ ] = { "\y[\d SHOP\y ]", "^3[ SHOP ]^1" };
/* ============================================================ */
new Float:g_ToUse[ 33 ];
enum _:SHOPENUM
{
I_NAME[ 50 ],
Float:I_TIMETOUSE
};
new const szConstShop[ ][ SHOPENUM ] =
{
{ "ITEM 1", 20.0 },
{ "ITEM 2", 20.0 },
{ "ITEM 3", 20.0 }
};
/* ============================================================ */
public plugin_init( )
{
register_plugin( szPlugin[ 0 ], szPlugin[ 1 ], szPlugin[ 2 ] );
register_clcmd( "say /shop", "open_MenuShop" );
}
public client_putinserver( id ) g_ToUse[ id ] = 0.0;
/* ============================================================ */
public open_MenuShop( id )
{
static iFormatex[ 999 ];
new Float:flCurrentTime = get_gametime();
formatex( iFormatex, charsmax( iFormatex ), "%s Menú de Shop", szPrefix[ 0 ] );
new iMenu = menu_create( iFormatex, "hand_MenuShop" );
for( new i = 0; i < sizeof( szConstShop ); i++ )
{
if( g_ToUse[ i ] < flCurrentTime )
formatex( iFormatex, charsmax( iFormatex ), "\w%s", szConstShop[ i ][ I_NAME ] );
else
formatex( iFormatex, charsmax( iFormatex ), "\d%s [ SEGUNDOS: %.2f ]", szConstShop[ i ][ I_NAME ], ( g_ToUse[ i ] - flCurrentTime ) );
menu_additem( iMenu, iFormatex );
}
menu_setprop( iMenu, MPROP_EXITNAME, "Salir" );
menu_setprop( iMenu, MPROP_NEXTNAME, "Siguiente" );
menu_setprop( iMenu, MPROP_BACKNAME, "Atras" );
menu_display( id, iMenu, 0 );
}
public hand_MenuShop( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new Float:flCurrentTime = get_gametime();
if( g_ToUse[ id ] < flCurrentTime )
{
client_print( id, print_chat, "%s Compraste: %s.", szPrefix[ 1 ], szConstShop[ item ][ I_NAME ] );
g_ToUse[ id ] = flCurrentTime + szConstShop[ item ][ I_TIMETOUSE ];
}
else
client_print( id, print_chat, "%s Te faltan %.2f segundos para comprar este item.", szPrefix[ 1 ], ( g_ToUse[ item ] - flCurrentTime ) );
menu_destroy( menu );
return PLUGIN_HANDLED;
}