[SOLUCIONADO] Log Run time error 25: parameter error
#1
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:
[Imagen: nzuQUybqRD6n2mT-xncE-A.png]

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_ToUse33 ];

enum _:SHOPENUM
{
    
I_NAME50 ],
    
Float:I_TIMETOUSE
};

new const 
szConstShop[ ][ SHOPENUM ] =
{
    { 
"ITEM 1"20.0 },
    { 
"ITEM 2"20.0 },
    { 
"ITEM 3"20.0 }
};

/* ============================================================ */

public plugin_init( )
{
    
register_pluginszPlugin], szPlugin], szPlugin] );
    
    
register_clcmd"say /shop""open_MenuShop" );
}

public 
client_putinserverid g_ToUseid ] = 0.0;

/* ============================================================ */

public open_MenuShopid )
{
    static 
iFormatex999 ];
    new 
Float:flCurrentTime get_gametime();
    
    
formatexiFormatexcharsmaxiFormatex ), "%s Menú de Shop"szPrefix] );
    new 
iMenu menu_createiFormatex"hand_MenuShop" );
    
    for( new 
0sizeofszConstShop ); i++ )
    {
        if( 
g_ToUse] < flCurrentTime )
            
formatexiFormatexcharsmaxiFormatex ), "\w%s"szConstShop][ I_NAME ] );
        else
            
formatexiFormatexcharsmaxiFormatex ), "\d%s [ SEGUNDOS: %.2f ]"szConstShop][ I_NAME ], ( g_ToUse] - flCurrentTime ) );
        
menu_additemiMenuiFormatex );
    }
    
    
menu_setpropiMenuMPROP_EXITNAME"Salir" );
    
menu_setpropiMenuMPROP_NEXTNAME"Siguiente" );
    
menu_setpropiMenuMPROP_BACKNAME"Atras" );
    
menu_displayidiMenu);
}
public 
hand_MenuShopidmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
Float:flCurrentTime get_gametime();
    
    if( 
g_ToUseid ] < flCurrentTime )
    {
        
client_printidprint_chat"%s Compraste: %s."szPrefix], szConstShopitem ][ I_NAME ] );
        
g_ToUseid ] = flCurrentTime szConstShopitem ][ I_TIMETOUSE ];
    }
    else
        
client_printidprint_chat"%s Te faltan %.2f segundos para comprar este item."szPrefix], ( g_ToUseitem ] - flCurrentTime ) );
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;


Responder
#2
No tienen sentido las condiciones if-else donde pasas tu variable ToUse, revisa eso. Además la usas mal, cada 0.5 segundos le descuentas 1 a una variable float. Es preferibles que uses get_gametime en su lugar. Remueve ese task, no lo necesitas.
Believe, be yourself and don't hold on to just one dream ❤

https://github.com/FEDERICOMB96
Responder
#3
(09/10/2017, 05:34 PM)Federicomb escribió: No tienen sentido las condiciones if-else donde pasas tu variable ToUse, revisa eso. Además la usas mal, cada 0.5 segundos le descuentas 1 a una variable float. Es preferibles que uses get_gametime en su lugar. Remueve ese task, no lo necesitas.

Actualicé el post recién, acomodé la mayoría pero no funciona el conteo.
Me darías un ejemplo de como usar get_gametime en un plugin así?

Responder
#4
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_ToUse33 ];

enum _:SHOPENUM
{
    
I_NAME50 ],
    
Float:I_TIMETOUSE
};

new const 
szConstShop[ ][ SHOPENUM ] =
{
    { 
"ITEM 1"9.0 },
    { 
"ITEM 2"6.0 },
    { 
"ITEM 3"3.0 }
};

/* ============================================================ */

public plugin_init( )
{
    
register_pluginszPlugin], szPlugin], szPlugin] );
    
    
register_clcmd"say /shop""open_MenuShop" );
}

public 
client_putinserverid )
{
    
g_ToUseid ] = 0.0;
}

/* ============================================================ */

public open_MenuShopid )
{
    static 
iFormatex200 ]; // 512 es el limite
    
    
formatexiFormatexcharsmaxiFormatex ), "%s Menú de Shop"szPrefix] );
    new 
iMenu menu_createiFormatex"hand_MenuShop" );

    new 
Float:fCurrentTime get_gametime();
    
    for( new 
0sizeofszConstShop ); i++ )
    {
        if( 
fCurrentTime >= g_ToUseid ] )
            
formatexiFormatexcharsmaxiFormatex ), "\w%s"szConstShop][ I_NAME ] );
        else
            
formatexiFormatexcharsmaxiFormatex ), "\d%s [ SEGUNDOS: %.2f ]"szConstShop][ I_NAME ], g_ToUseid ] - fCurrentTime );
        
        
menu_additemiMenuiFormatex );
    }
    
    
menu_setpropiMenuMPROP_EXITNAME"Salir" );
    
menu_setpropiMenuMPROP_NEXTNAME"Siguiente" );
    
menu_setpropiMenuMPROP_BACKNAME"Atras" );
    
menu_displayidiMenu);
}
public 
hand_MenuShopidmenuitem )
{
    if( !
is_user_connected(id) || item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
Float:fCurrentTime get_gametime();
    
    if( 
fCurrentTime >= g_ToUseid ] )
    {
        
client_printidprint_chat"%s Compraste: %s."szPrefix], szConstShopitem ][ I_NAME ] );
        
g_ToUseid ] = fCurrentTime szConstShopitem ][ I_TIMETOUSE ];
    }
    else
        
client_printidprint_chat"%s Te faltan %.2f segundos para comprar este item."szPrefix], g_ToUseid ] - fCurrentTime );
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;


Te lo corregí un poco, revisa con el anterior y verás como pasabas mal el ID a la variable ToUse, además el límite establecido por el motor para mostrar un menú es de 512 y tu le asignabas 999 celdas a la variable de formato en el menú, eso es desperdiciar memoria. Ten en cuenta esos detalles siempre, es importante que lo sepas.
Believe, be yourself and don't hold on to just one dream ❤

https://github.com/FEDERICOMB96
Responder
#5
(09/10/2017, 06:10 PM)Federicomb escribió:
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_ToUse33 ];

enum _:SHOPENUM
{
    
I_NAME50 ],
    
Float:I_TIMETOUSE
};

new const 
szConstShop[ ][ SHOPENUM ] =
{
    { 
"ITEM 1"9.0 },
    { 
"ITEM 2"6.0 },
    { 
"ITEM 3"3.0 }
};

/* ============================================================ */

public plugin_init( )
{
    
register_pluginszPlugin], szPlugin], szPlugin] );
    
    
register_clcmd"say /shop""open_MenuShop" );
}

public 
client_putinserverid )
{
    
g_ToUseid ] = 0.0;
}

/* ============================================================ */

public open_MenuShopid )
{
    static 
iFormatex200 ]; // 512 es el limite
    
    
formatexiFormatexcharsmaxiFormatex ), "%s Menú de Shop"szPrefix] );
    new 
iMenu menu_createiFormatex"hand_MenuShop" );

    new 
Float:fCurrentTime get_gametime();
    
    for( new 
0sizeofszConstShop ); i++ )
    {
        if( 
fCurrentTime >= g_ToUseid ] )
            
formatexiFormatexcharsmaxiFormatex ), "\w%s"szConstShop][ I_NAME ] );
        else
            
formatexiFormatexcharsmaxiFormatex ), "\d%s [ SEGUNDOS: %.2f ]"szConstShop][ I_NAME ], g_ToUseid ] - fCurrentTime );
        
        
menu_additemiMenuiFormatex );
    }
    
    
menu_setpropiMenuMPROP_EXITNAME"Salir" );
    
menu_setpropiMenuMPROP_NEXTNAME"Siguiente" );
    
menu_setpropiMenuMPROP_BACKNAME"Atras" );
    
menu_displayidiMenu);
}
public 
hand_MenuShopidmenuitem )
{
    if( !
is_user_connected(id) || item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }

    new 
Float:fCurrentTime get_gametime();
    
    if( 
fCurrentTime >= g_ToUseid ] )
    {
        
client_printidprint_chat"%s Compraste: %s."szPrefix], szConstShopitem ][ I_NAME ] );
        
g_ToUseid ] = fCurrentTime szConstShopitem ][ I_TIMETOUSE ];
    }
    else
        
client_printidprint_chat"%s Te faltan %.2f segundos para comprar este item."szPrefix], g_ToUseid ] - fCurrentTime );
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;


Te lo corregí un poco, revisa con el anterior y verás como pasabas mal el ID a la variable ToUse, además el límite establecido por el motor para mostrar un menú es de 512 y tu le asignabas 999 celdas a la variable de formato en el menú, eso es desperdiciar memoria. Ten en cuenta esos detalles siempre, es importante que lo sepas.

Gracias, voy a tener en cuenta esos detalles!

Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)