Dudas de funciones
#1
Pues, viendo que algunos aqui me han avanzado en su aprendizaje de pawn pues yo me puse en lo mismo a practicar, y pues queria saber si estaban bien echas estas funciones queno se usar mucho (por eso me puse a practicarlas)

Estoy armando una tienda (Nada para publicar solo practicar)

Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
// include fakemeta;

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new max_playersg_uso[33][4];

enum {
    
nombre[40],
    
costo,
    
extra_item
}
new const 
item[][extra_item] = {
    { 
"opcion 1"500 }
    { 
"Opcion 2"400 }
    { 
"opcion 3"300 }
    { 
"opcion 4"200 }
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("Round_Start""RoundStart"2"1=RoundStart")
    
register_event("HLTV""Round_Start"2"1=RoundStart")
    
    
max_players get_maxplayers
    
    register_clcmd
("say /tienda""CmdTienda")
}
public 
Round_Start()
{
    new 
i[33];
    for( 
1max_playersi++) 
    {
        
set_task(15.0"CmdTienda"i)
        
g_uso[i][0] = false;
        
g_uso[i][1] = false;
        
g_uso[i][2] = false;
        
g_uso[i][3] = false;
    }
}
public 
CmdTienda(id)
{
    new 
len[200]
    new 
menu menu_create("Tienda simple""HandlerTienda")
    
    
formatex(lencharsmax(len), "%s $%d"item[0][nombre], item[0][costo])
    
menu_additem(menulen"1")
    
    
formatex(lencharsmax(len), "%s $%d"item[1][nombre], item[1][costo])
    
menu_additem(menulen"2")
    
    
formatex(lencharsmax(len), "%s $%d"item[2][nombre], item[2][costo])
    
menu_additem(menulen"3")
    
    
formatex(lencharsmax(len), "%s $%d"item[3][nombre], item[3][costo])
    
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED;
}
public 
Handlertienda(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"Debes estar vivo para habrir el menu")
        return 
PLUGIN_HANDLED;
    }
    switch(
item)
    {
        case 
0
        {
            if(
cs_get_user_money item[0][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][0] = false)
                {
                    
                
                    
client_print(idprint_chat"%s $%d"item[0][nombre], item[0][costo])
                    
cs_set_user_money(idcs_get_user_money(id) - item[0][costo])
                    
g_uso[id][0] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
            }
        }
        case 
1:
        {
            if(
cs_get_user_money item[1][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][1] = false)
                {
                    
                    
client_print(idprint_chat"%s $%d"item[1][nombre], item[1][costo])
                    
cs_set_user_money(idget_user_money(id) - item[1][costo])
                    
g_uso[id][1] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
        }
        case 
2:
        {
            if(
cs_get_user_money(id) < item[2][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][2] = false)
                {
                    
                    
client_print(idprint_chat"%s $%d"item[2][nombre], item[2][costo])
                    
cs_set_user_money(idcs_get_user_money(id) - item[2][costo])
                    
g_uso[id][2] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
            }
        }
        case 
3:
        {
            if(
cs_get_user_money(id) < item[3][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][3] = false)
                {
                    
                    
client_print(idprint_chat"%s $%d"item[3][nombre], item[3][costo])
                    
cs_set_user_money(idcs_get_user_money(id) - item[3][costo])
                    
g_uso[id][3] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
            }
        }
    }
    return 
PLUGIN_HANDLED;
}
public 
client_disconnect(id)
{
    
remove_task(id)


ahora quiero saber unas cosillas xD:

1.-que diferencia tiene este evento del otro
Código PHP:
register_logevent("Round_Start""RoundStart"2"1=RoundStart"//evento 1
    
register_event("HLTV""Round_Start"2"1=RoundStart"// evento 2 

2.-Esta bien seteado el task y el bucle del round star?

seteo y bucle:
Código PHP:
public Round_Start()
{
    new 
i[33];
    for( 
1max_playersi++) 
    {
        
set_task(15.0"CmdTienda"i)
        
g_uso[i][0] = false;
        
g_uso[i][1] = false;
        
g_uso[i][2] = false;
        
g_uso[i][3] = false;
    }


3.-Esta bien removido el task?:

Código PHP:
public client_disconnect(id)
{
    
remove_task(id)


y pues lo que mas dificil se me hacia el uso de una variable con array

pues es lo mas largo,

creacion de la variable:

Código PHP:
enum {
    
nombre[40],
    
costo,
    
extra_item
}
new const 
item[][extra_item] = {
    { 
"opcion 1"500 }
    { 
"Opcion 2"400 }
    { 
"opcion 3"300 }
    { 
"opcion 4"200 }


Seteo de la variable en el menu

Código PHP:
public CmdTienda(id)
{
    new 
len[200]
    new 
menu menu_create("Tienda simple""HandlerTienda")
    
    
formatex(lencharsmax(len), "%s $%d"item[0][nombre], item[0][costo])
    
menu_additem(menulen"1")
    
    
formatex(lencharsmax(len), "%s $%d"item[1][nombre], item[1][costo])
    
menu_additem(menulen"2")
    
    
formatex(lencharsmax(len), "%s $%d"item[2][nombre], item[2][costo])
    
menu_additem(menulen"3")
    
    
formatex(lencharsmax(len), "%s $%d"item[3][nombre], item[3][costo])
    
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED;


Uso de la variable en el handler, en el checkeo de dinero y en los mensajes.

Código PHP:
public Handlertienda(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"Debes estar vivo para habrir el menu")
        return 
PLUGIN_HANDLED;
    }
    switch(
item)
    {
        case 
0
        {
            if(
cs_get_user_money item[0][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][0] = false)
                {
                    
                
                    
client_print(idprint_chat"%s $%d"item[0][nombre], item[0][costo])
                    
cs_set_user_money(idcs_get_user_money(id) - item[0][costo])
                    
g_uso[id][0] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
            }
        }
        case 
1:
        {
            if(
cs_get_user_money item[1][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][1] = false)
                {
                    
                    
client_print(idprint_chat"%s $%d"item[1][nombre], item[1][costo])
                    
cs_set_user_money(idget_user_money(id) - item[1][costo])
                    
g_uso[id][1] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
        }
        case 
2:
        {
            if(
cs_get_user_money(id) < item[2][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][2] = false)
                {
                    
                    
client_print(idprint_chat"%s $%d"item[2][nombre], item[2][costo])
                    
cs_set_user_money(idcs_get_user_money(id) - item[2][costo])
                    
g_uso[id][2] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
            }
        }
        case 
3:
        {
            if(
cs_get_user_money(id) < item[3][costo])
            {
                
client_print(idprint_chat"No te alcanza")
                return 
PLUGIN_HANDLED;
            }
            else
            {
                if(
g_uso[id][3] = false)
                {
                    
                    
client_print(idprint_chat"%s $%d"item[3][nombre], item[3][costo])
                    
cs_set_user_money(idcs_get_user_money(id) - item[3][costo])
                    
g_uso[id][3] = true
                    
return PLUGIN_HANDLED;
                }
                else
                {
                    
client_print(idprint_chat"Ya haz comprado este item durante la ronda")
                    return 
PLUGIN_HANDLED;
                }
            }
        }
    }
    return 
PLUGIN_HANDLED;


Pues al saber esto ya tendría mi base (Bien formada) de scripting Guiño
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#2
si no me equivoco la parte del bucle esta mal

Código PHP:
new i[33];
    for( 
1max_playersi++) 

->

Código PHP:
new i;
    for( 
1max_playersi++) 

o mas facil
Código PHP:
for(new 1<= maxplayersi++) 

muchas veces te conviene tambien chequear si el usuario esta conectado o vivo dentro de un bucle dependiendo para que lo uses (suponiendo que le queres dar armas)

Código PHP:
for(new 1<= maxplayersx++)
    if(
is_user_alive(i))
        
give_item(i"weapon_m4a1"

esto mas que nada para que no te tire errores de que x jugador no se encontro o esta muerto

lo demas parece estar bien, no lo lei con mucha atencion y en cuanto a los eventos sirven para lo mismo asi que no se exactamente la diferencia
Responder
#3
mmm ok, estaba viendo, ya que no se usar mucho los arrays :S y estaba practicando pero veo que esta bien, Whatever gracias espero que se pase otro usuario y comente (seriedad en el comentario :V)
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#4
(19/07/2018, 01:02 AM)Saber escribió: ahora quiero saber unas cosillas xD:

1.-que diferencia tiene este evento del otro
Código PHP:
register_logevent "Round_Start""RoundStart"2"1=RoundStart" //evento 1
    
register_event("HLTV""Round_Start"2"1=RoundStart"// evento 2 

Uno es cuando la ronda empezó y el otro es en el freezetime, besitos. Crab

Código PHP:
public plugin_init ( ) { 

          
register_event "HLTV""Event_HLTV_New_Round""a""1=0""2=0" );

          
register_logevent "LogEvent_Round_Start"2"1=Round_Start" );

          
register_logevent "Logevent_Round_End"2"1=Round_End" );


public 
Event_HLTV_New_Round ( ) {

          
server_print "Freezetime started" ); 


public 
LogEvent_Round_Start ( ) {
 
          
server_print "Round started" ); 


public 
Logevent_Round_End ( ) {

          
server_print "Round ended" );

Responder
#5
No lo diría así, si no como un evento que define el comienzo real de una ronda, y otro el comienzo jugable de la ronda (término de freezetime)
Responder
#6
(19/07/2018, 05:11 PM)meTaLiCroSS escribió: No lo diría así, si no como un evento que define el comienzo real de una ronda, y otro el comienzo jugable de la ronda (término de freezetime)

Pienso que se entendió pacman
Responder
#7
Gracias queria saber eso. Ando asiendo algo para ver si lo publico pacman una pregunta, como hago para ponerle tiempo a algo, ejemplo un item de velocidad o godmode? Tengo una idea sobre ello, pero no me cuadra.
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#8
con tasks y variables quiza

un ejemplo

Código PHP:
public godmode(id)
{
    
set_user_godmode(id1)
    
set_task(10.0"godoff"id)


Código PHP:
public godoff(id)
{
    
set_user_godmode(id0)


vas a tener que leer un tuto de uso de tasks, para saber como remover task y crear task con diferentes id
Responder
#9
Gracias. Nothingdohere

EDIT: Pues estaba creando un plugins xD, pero me tira unos errores & warnings que no se porque xD)

el codigo:

Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new max_playersg_item[33][4], g_level[33], g_frags[33], g_points[33], g_godmodeuse[33];
new 
cvar_status;

const 
MAX_FRAGS 121
new const FRAGS_REQUIRED[] = { 081625323648566674788495100120MAX_FRAGS }
const 
MAX_LEVEL 15

enum 
{
    
nombre[40],
    
costo,
    
level,
    
extra_item
}
new const 
item[][extra_item] = {
    { 
"+30 HP"4004  },
    { 
"+50 ARMOR",800},
    { 
"+gravedad & velocidad"120012 },
    { 
"Godmode (15 segundos)"150015 }
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /tienda""CmdTienda")
    
register_clcmd("nightvision""CmdGodmode")
    
    
register_elogevent("Round_Start"2"1=Round_Start")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled_Post")
    
    
    
cvar_status register_cvar("amx_status""1"// defecto 1
    
    
max_players get_maxplayers();
}
public 
Round_Start()
{
    new 
i
    
for(1max_playersi++)
    {
        
        if(
g_item[i][0] == true)
        {
            
set_user_health(i130)
        }
        if(
g_item[i][1] == true)
        {
            
set_user_armor(i150)
        }
        if(
g_item[i][2])
        {
            
set_user_gravity(i0.90)
            
set_user_maxspeed(i380.0)
        }
        if(
g_item[i][3])
        {
            
client_print(iprint_chat"Preciona N para activar el GODMODE.")
        }
    }
    return 
PLUGIN_HANDLED;
}
public 
fw_PlayerKilled_post(victimattackershouldgib)
{
    if(
victim == attacker || !is_user_alive(attacker) || !is_user_connected(attacker))
    {
        return 
HAM_IGNORED;
    }
    
g_frags[attacker]++
    
CheckLevel(attacker)
    return 
HAM_IGNORED;
}
public 
CheckLevel(id)
{
    if(
g_frags[id] >= FRAGS_REQUIRED[g_level[id]])
    {
        
g_level[id]++
        
g_points[id] += 100
    
}
    else
    {
        return 
PLUGIN_HANDLED;
    }
}
public 
CmdGodmode(id)
{
    if(
g_godmodeuse[id] = true)
    {
        
client_print(idprint_chat"Ya usaste tu godmode durante la ronda.")
    }
    else
    {
        
        
set_user_godmode(id1)
        
set_task(15.0"GodModeOff"id")
    }
    return PLUGIN_HANDLED;
}
public GodModeOff(id)
{
    client_print(id, print_chat, "
Tu godmode ha acabado.")
    set_user_godmode(id, 0)
    return PLUGIN_HANDLED;
}
public CmdTienda(id)
{
    if(get_pcvar_num(cvar_status)) 
    {
        return PLUGIN_HANDLED;
    }
    
    new len[200]
    new menu = menu_create("
Tienda simple", "HandlerTienda")
    
    formatex(len, charsmax(len), "
%- %d Puntos", item[0][nombre], item[0][costo])
    menu_additem(menu, len, "
1")
    
    formatex(len, charsmax(len), "
%- %d Puntos", item[1][nombre], item[1][costo])
    menu_additem(menu, len, "
2")
    
    formatex(len, charsmax(len), "
%- %d Puntos", item[2][nombre], item[2][costo])
    menu_additem(menu, len, "
3")
    
    formatex(len, charsmax(len), "
%- %d Puntos", item[3][nombre], item[3][costo])
    
    
    menu_display(id, menu, 0)
    return PLUGIN_HANDLED;
}
public Handlertienda(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED;
    }
    if(!is_user_alive(id))
    {
        client_print(id, print_chat, "
Debes estar vivo para habrir el menu.")
        return PLUGIN_HANDLED;
    }
    switch(item)
    {
        case 0: 
        {
            if(g_level[id] < item[0][level])
            {
                client_print(id, print_chat, "
No tienes nivel necesario para comprar este item.")
            }
            else
            {
                if(g_points[id] < item[0][costo])
                {
                    client_print(id, print_chat, "
No tienes puntos suficientes para comprar este item."
                }
                else
                {
                    set_user_health(id, 130)
                    g_points[id] -= item[0][costo]
                    client_print(id, print_chat, "
Obtienes +30 de HP puntos restantes %d.", g_points[id])
                    g_item[id][0] = true;
                }
            }
        }
        case 1:
        {
            if(g_level[id] < item[1][level])
            {
                client_print(id, print_chat, "
No tienes nivel necesario para comprar este item.")
                return PLUGIN_HANDLED;
            }
            else
            {
                if(g_points(id) < item[1][costo])
                {
                    client_print(id, print_chat, "
No tienes puntos suficientes para comprar este item.")
                }
                else
                {
                    set_user_armor(id, 150)
                    g_points[id] -= item[1][costo]
                    client_print(id, print_chat, "
Obtienes +50 ARMOR puntos restantes %d.", g_points[id])
                    g_item[id][1] = true;
                }
            }
        }
        case 2:
        {
            if(g_level[id] < item[2][level])
            {
                client_print(id, print_chat, "
No tienes nivel suficiente para comprar este item..")
            }
            else
            {
                if(g_points[id] < item[2][costo])
                {
                    client_print(id, print_chat, "
No tienes puntos suficientes para comprar este item.")
                }
                else
                {
                    set_user_gravity(id, 0.90)
                    set_user_maxspeed(id, 380.0)
                    g_points[id] -= item[2][costo]
                    client_print(id, print_chat, "
Recibes GRAVEDAD VELOCIDAD puntos resntates %d.", g_points[id])
                    g_item[id][2] -= item[2][costo]
                }
            }
        }
        case 3:
        {
            if(g_level[id] < item[3][level])
            {
                client_print(id, print_chat, "
No tienes nivel suficiente para comprar este item.")
            }
            else
            {
                if(g_points[id] < item[3][costo])
                {
                    client_print(id, print_chat, "
No tienes puntos suficientes para comprar este item.")
                }
                else
                {
                    g_points[id] -= item[3][costo]
                    client_print(id, print_chat, "
Recibes GODMODE (15 segundosPreciona la letra N para activarPuntos restantes %d.", g_points[id])
                    g_item[id][3] = true;
                }
            }
        }
    }
    return PLUGIN_HANDLED;
}

                    
        
                    
                
            
public client_disconnect(id)
{
    remove_task(id)


errores:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright © 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Tag mismatch on line 51
Warning: Tag mismatch on line 55
Warning: Function "CheckLevel" should return a value on line 92
Warning: Possibly unintended assignment on line 95
Error: Invalid string (possibly non-terminated string) on line 103
Warning: Expression has no effect on line 103
Error: Invalid subscript (not an array or too many subscripts): "item" on line 154
Warning: Expression has no effect on line 154
Error: Expected token: ";", but found "]" on line 154
Error: Invalid expression, assumed zero on line 154
Error: Too many error messages on one line on line 154

Compilation aborted.
5 Errors.
Could not locate output file C:\Users\Luis\Desktop\prueba.amx (compile failed).
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#10
Las comparaciones se hacen con 2 =.
Código PHP:
if(condición == true
Responder
#11
me sigue tirando error y solo tenia una comparacion con 1 =

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright © 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Tag mismatch on line 51
Warning: Tag mismatch on line 55
Warning: Function "CheckLevel" should return a value on line 92
Warning: Tag mismatch on line 95
Error: Invalid string (possibly non-terminated string) on line 103
Warning: Expression has no effect on line 103
Error: Invalid subscript (not an array or too many subscripts): "item" on line 154
Warning: Expression has no effect on line 154
Error: Expected token: ";", but found "]" on line 154
Error: Invalid expression, assumed zero on line 154
Error: Too many error messages on one line on line 154

Compilation aborted.
5 Errors.
Could not locate output file C:\Users\Luis\Desktop\prueba.amx (compile failed).
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#12
Código PHP:
/* Línea 103 */ set_task(15.0"GodModeOff"id") 
Fíjate que el id tiene una doble comilla al final que no va.

En la siguiente función:
Código PHP:
public Handlertienda(idmenuitem
Tenés el parámetro que se llama item y también tenés una variable que se llama item, cambia alguna de las 2.
Esto implica también cambiar la variable en todo el código o el parámetro en toda la función.
Responder
#13
carajo me sigue tirando error, y warning en las comparaciones ...

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright © 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Tag mismatch on line 51
Warning: Tag mismatch on line 55
Warning: Function "CheckLevel" should return a value on line 92
Warning: Tag mismatch on line 95
Error: Expected token: ",", but found "}" on line 162
Error: Invalid function call, not a valid address on line 182
Warning: Expression has no effect on line 182
Error: Expected token: ";", but found ")" on line 182
Error: Invalid expression, assumed zero on line 182
Error: Too many error messages on one line on line 182

Compilation aborted.
5 Errors.
Could not locate output file C:\Users\Luis\Desktop\prueba.amx (compile failed).

ya solucione los errores xD

disculpen las molestias, alguien me puede decir que significa este warning

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright © 1997-2013 ITB CompuPhase, AMX Mod X Team

Warning: Tag mismatch on line 51
Warning: Tag mismatch on line 55
Warning: Tag mismatch on line 92
Header size: 1080 bytes
Code size: 6056 bytes
Data size: 6024 bytes
Stack/heap size: 16384 bytes; estimated max. usage=781 cells (3124 bytes)
Total requirements: 29544 bytes

3 Warnings.
Done.
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#14
proba ahi saber

Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new max_playersg_item[33][4], g_level[33], g_frags[33], g_points[33], g_godmodeuse[33];
new 
cvar_status;

const 
MAX_FRAGS 121
new const FRAGS_REQUIRED[] = { 081625323648566674788495100120MAX_FRAGS }
const 
MAX_LEVEL 15

enum _
:datos {
    
nombre[40],
    
costo,
    
level
}
new const 
item_2[][datos] = {
    { 
"+30 HP"4004  },
    { 
"+50 ARMOR",800},
    { 
"+gravedad & velocidad"120012 },
    { 
"Godmode (15 segundos)"150015 }
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /tienda""CmdTienda")
    
register_clcmd("nightvision""CmdGodmode")
    
    
register_logevent("Round_Start"2"1=Round_Start")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled_Post")
    
    
    
cvar_status register_cvar("amx_status""1"// defecto 1
    
    
max_players get_maxplayers();
}
public 
Round_Start()
{
    new 
i
    
for(1max_playersi++)
    {
        
        if(
g_item[i][0])
        {
            
set_user_health(i130)
        }
        if(
g_item[i][1])
        {
            
set_user_armor(i150)
        }
        if(
g_item[i][2])
        {
            
set_user_gravity(i0.90)
            
set_user_maxspeed(i380.0)
        }
        if(
g_item[i][3])
        {
            
client_print(iprint_chat"Preciona N para activar el GODMODE.")
        }
    }
    return 
PLUGIN_HANDLED;
}
public 
fw_PlayerKilled_post(victimattackershouldgib)
{
    if(
victim == attacker || !is_user_alive(attacker) || !is_user_connected(attacker))
    {
        return 
HAM_IGNORED;
    }
    
g_frags[attacker]++
    
CheckLevel(attacker)
    return 
HAM_IGNORED;
}
public 
CheckLevel(id)
{
    if(
g_frags[id] >= FRAGS_REQUIRED[g_level[id]])
    {
        
g_level[id]++
        
g_points[id] += 100
    
}
    else
    {
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED
}
public 
CmdGodmode(id)
{
    if(
g_godmodeuse[id])
    {
        
client_print(idprint_chat"Ya usaste tu godmode durante la ronda.")
    }
    else
    {
        
        
set_user_godmode(id1)
        
set_task(15.0"GodModeOff"id)
    }
    return 
PLUGIN_HANDLED;
}
public 
GodModeOff(id)
{
    
client_print(idprint_chat"Tu godmode ha acabado.")
    
set_user_godmode(id0)
    return 
PLUGIN_HANDLED;
}
public 
CmdTienda(id)
{
    if(
get_pcvar_num(cvar_status)) 
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
len[200]
    new 
menu menu_create("Tienda simple""HandlerTienda")
    
    
formatex(lencharsmax(len), "%s - %d Puntos"item_2[0][nombre], item_2[0][costo])
    
menu_additem(menulen"1")
    
    
formatex(lencharsmax(len), "%s - %d Puntos"item_2[1][nombre], item_2[1][costo])
    
menu_additem(menulen"2")
    
    
formatex(lencharsmax(len), "%s - %d Puntos"item_2[2][nombre], item_2[2][costo])
    
menu_additem(menulen"3")
    
    
formatex(lencharsmax(len), "%s - %d Puntos"item_2[3][nombre], item_2[3][costo])
    
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED;
}
public 
Handlertienda(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED;
    }
    if(!
is_user_alive(id))
    {
        
client_print(idprint_chat"Debes estar vivo para habrir el menu.")
        return 
PLUGIN_HANDLED;
    }
    switch(
item)
    {
        case 
0
        {
            if(
g_level[id] < item_2[0][level])
            {
                
client_print(idprint_chat"No tienes nivel necesario para comprar este item.")
            }
            else
            {
                if(
g_points[id] < item_2[0][costo])
                {
                    
client_print(idprint_chat"No tienes puntos suficientes para comprar este item.")
                }
                else
                {
                    
set_user_health(id130)
                    
g_points[id] -= item_2[0][costo]
                    
client_print(idprint_chat"Obtienes +30 de HP puntos restantes %d."g_points[id])
                    
g_item[id][0] = true;
                }
            }
        }
        case 
1:
        {
            if(
g_level[id] < item_2[1][level])
            {
                
client_print(idprint_chat"No tienes nivel necesario para comprar este item.")
                return 
PLUGIN_HANDLED;
            }
            else if(
g_points[id] < item_2[1][costo])
            {
                 
client_print(idprint_chat"No tienes puntos suficientes para comprar este item.")
            }
        
            else
            {
                 
set_user_armor(id150)
                 
g_points[id] -= item_2[1][costo]
                 
client_print(idprint_chat"Obtienes +50 ARMOR puntos restantes %d."g_points[id])
                 
g_item[id][1] = true;
             }
         }
        case 
2:
        {
            if(
g_level[id] < item_2[2][level])
            {
                
client_print(idprint_chat"No tienes nivel suficiente para comprar este item..")
            }
            else
            {
                if(
g_points[id] < item_2[2][costo])
                {
                    
client_print(idprint_chat"No tienes puntos suficientes para comprar este item.")
                }
                else
                {
                    
set_user_gravity(id0.90)
                    
set_user_maxspeed(id380.0)
                    
g_points[id] -= item_2[2][costo]
                    
client_print(idprint_chat"Recibes GRAVEDAD & VELOCIDAD puntos resntates %d."g_points[id])
                    
g_item[id][2] -= item_2[2][costo]
                }
            }
        }
        case 
3:
        {
            if(
g_level[id] < item_2[3][level])
            {
                
client_print(idprint_chat"No tienes nivel suficiente para comprar este item.")
            }
            else
            {
                if(
g_points[id] < item_2[3][costo])
                {
                    
client_print(idprint_chat"No tienes puntos suficientes para comprar este item.")
                }
                else
                {
                    
g_points[id] -= item_2[3][costo]
                    
client_print(idprint_chat"Recibes GODMODE (15 segundos) Preciona la letra N para activar. Puntos restantes %d."g_points[id])
                    
g_item[id][3] = true;
                }
            }
        }
    }
    return 
PLUGIN_HANDLED;
}    
            
public 
client_disconnect(id)
{
    
remove_task(id)

Responder
#15
No estoy en la casa cuando llegue lo pruebo.

Pero dime como solucionate esos warning
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#16
cambie un poco el enum porque parecia estar mal

y en esta funcion ya estaba definido item asi que solo cambie el nombre del enum a item_2 porque te tiraba como que estaba definido 2 veces

Código PHP:
public Handlertienda(idmenuitem 
Responder
#17
(20/07/2018, 01:30 PM)Nelo escribió: cambie un poco el enum porque parecia estar mal

y en esta funcion ya estaba definido item asi que solo cambie el nombre del enum a item_2 porque te tiraba como que estaba definido 2 veces

Código PHP:
public Handlertienda(idmenuitem 

Básicamente lo que comentó Exertency.

(20/07/2018, 11:19 AM)Exertency escribió:
Código PHP:
/* Línea 103 */ set_task(15.0"GodModeOff"id") 
Fíjate que el id tiene una doble comilla al final que no va.

En la siguiente función:
Código PHP:
public Handlertienda(idmenuitem
Tenés el parámetro que se llama item y también tenés una variable que se llama item, cambia alguna de las 2.
Esto implica también cambiar la variable en todo el código o el parámetro en toda la función.
Responder
#18
Eso ya lo habia echo, cuando lo dijo exertency, pero igual me tiraba unos errores en el Round Start en las variables. Pero bueno, gracias. Whatever
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#19
porque Ham_Killed cuando se puede usar por lo mas facil client_death de csx
[Imagen: b_350_20_323957_202743_f19a15_111111.png]

(18/11/2014, 05:47 PM)Neeeeeeeeeel.- escribió: Por qué necesitan una guía para todo? Meté mano y que salga lo que salga... es la mejor forma de aprender.

(16/05/2016, 11:08 PM)kikizon2 escribió: No cabe duda que tienen mierda en vez de cerebro, par de pendejos v:
Responder
#20
Pues me parece mas completo (segun mi criterio) el ham_killed, y es el que mas se usar xD
Si no te gusta algo, cámbialo. Si no lo puedes cambiar, cambia la forma en que piensas sobre ello <3
Responder
#21
Código PHP:
public Round_Start()
{
    new 
i
    
for(1max_playersi++)
    {
        if(!
is_user_connected(i) || !is_user_alive(i)) continue;
        
        if(
g_item[i][0])
        {
            
set_user_health(i130)
        }
        if(
g_item[i][1])
        {
            
set_user_armor(i150)
        }
        if(
g_item[i][2])
        {
            
set_user_gravity(i0.90)
            
set_user_maxspeed(i380.0)
        }
        if(
g_item[i][3])
        {
            
client_print(iprint_chat"Preciona N para activar el GODMODE.")
        }
    }
    return 
PLUGIN_HANDLED;


Reemplaza la funcion RoundStart, te falto verificar que este conectado y vivo
Responder
#22
Verificaria solamente que no esté vivo, porque logicamente si está vivo está conectado...

Código PHP:
if(!is_user_alive(id)) // si no está conectado tampoco estaria vivo 
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)