Allied Modders en español

Versión completa: [ZP][Aporte] Hats por reset
Actualmente estas viendo una versión simplificada de nuestro contenido. Ver la versión completa con el formato correcto.
Páginas: 1 2
Bueno gente les voy a dejar una forma facil de hacer hats por reset, aunque no sea la mejor sirve ya que vi varios post sobre el tema...
Empecemos:

Código PHP:
    // Primero agregamos estas variables que vendrian a ser la entidad y los modelos de nuestros hats
    
new g_ent[33]
    new const 
hat_1[] = { "models/hats/dunce.mdl" }
    new const 
hat_2[] = { "models/hats/headphones.mdl" }
    new const 
hat_3[] = { "models/hats/pbbears.mdl" 

Código PHP:
    // Despues nos vamos al public plugin_precache() y precacheamos los modelos
    
engfunc(EngFunc_PrecacheModelhat_1)
    
engfunc(EngFunc_PrecacheModelhat_2)
    
engfunc(EngFunc_PrecacheModelhat_3

Código PHP:
    // De ahi nos vamos a public fw_PlayerSpawn_Post(id) y agregamos los siguiente arriba de // Show custom buy menu?

    
new ent g_ent[id]
    new 
infotarget engfunc(EngFunc_AllocString"info_target")

    if (!
pev_valid(ent))
    {
        
engfunc(EngFunc_RemoveEntityent)
        
g_ent[id] = ent engfunc (EngFunc_CreateNamedEntityinfotarget)
        
set_pev(entpev_movetypeMOVETYPE_FOLLOW)
        
set_pev(entpev_aimentid)
        
// Aca indicamos que a partir del primer reset en adelante use el hat_1, luego a partir del reset 3 en adelante use el hat_2 y a partir del reset 5 use el hat_3 
        
if (g_isalive[id]) // Nos fijamos si el usuario que lo va a utilizar esta vivo
        
{
            if (
g_reset[id] >= 1)
                
engfunc(EngFunc_SetModelenthat_1)
            if (
g_reset[id] >= 3)
                
engfunc(EngFunc_SetModelenthat_2)
            if (
g_reset[id] >= 5)
                
engfunc(EngFunc_SetModelenthat_3)
        }
    } 

Aca les dejo algunos models de hats para los que necesiten:
http://www.mediafire.com/download/z0tppx...3/hats.rar

Eso es todo y espero que les haya sido de utilidad
Muy buen aporte, me viene al pelo.

Una pregunta, no tendrias los models de los hats por casualidad?
(14/01/2014, 12:17 PM)wiD escribió: [ -> ]Muy buen aporte, me viene al pelo.

Una pregunta, no tendrias los models de los hats por casualidad?

Me alegro de que te haya servido, ahi deje algunos hats Guiño
hay que remover los hats cuando mueren o se desconectan, para evitar bugs
(14/01/2014, 12:29 PM)RauliTop escribió: [ -> ]hay que remover los hats cuando mueren o se desconectan, para evitar bugs

No creo que haya problemas pero por las dudas puse que solo esten habilitados para cuando estas vivo, gracias por avisar
Código PHP:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <engine>

enum _:e_Data
{
    
i_Reset,
    
s_Model[64]
}

#define MaxHats 3
    
new const g_HatsConst[MaxHats][e_Data] = 

    { 
0"models/hats/dunce.mdl" }, 
    { 
1"models/hats/headphones.mdl" },
    { 
2"models/hats/pbbears.mdl" 
}

native zp_get_user_reset(id)
new 
g_Hat[33], g_DisabledHat[MaxHats]

public 
plugin_precache() {
    
register_plugin("?""?""?")
    
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
    
    for(new 
0MaxHatsi++)
    {
        if(
file_exists(g_HatsConst[i][s_Model]))
            
precache_model(g_HatsConst[i][s_Model])
        else 
        {
            
server_print("Hats: %s no existe en el directorio"g_HatsConst[i][s_Model])
            
g_DisabledHat[i] = true
        
}
    }
}

public 
fw_PlayerSpawn_Post(id)
{
    if(!
is_user_alive(id) || !get_user_team(id))
        return
        
    static 
iResetsiResets zp_get_user_reset(id)
    
    if(
iResets == g_HatsConst[iResets][i_Reset])
        if(!
g_DisabledHat[iResets]) fnSetHat(id_g_HatsConst[iResets][s_Model])
}

fnSetHat(idiRemove 0, const sModel[] = "")
{
    if(!
iRemove)
    {
        if (!
is_valid_ent(g_Hat[id]))
        {
            
g_Hat[id] = create_entity("info_target")
            if (!
is_valid_ent(g_Hat[id])) return;
            
            
entity_set_int(g_Hat[id], EV_INT_movetypeMOVETYPE_FOLLOW);
            
entity_set_edict(g_Hat[id], EV_ENT_aimentid);
            
entity_set_int(g_Hat[id], EV_INT_rendermodekRenderNormal)
        }
        
entity_set_model(g_Hat[id], sModel)
    }
    else
    {
        if (
is_valid_ent(g_Hat[id]))
        {
            
remove_entity(g_Hat[id])
            
g_Hat[id] = 0
        
}        
    }



Quien testea?
Código PHP:
new g_hats[33]

new 
g_hats_ent[33]
new 
g_reset[33]

new const 
g_hats_modes[][] =  // 30 modelos
{
    
"models/hat/jason.mdl",
    
"models/hat/ushanka.mdl",
    
"models/hat/viking.mdl",
    
"models/hat/santahat.mdl",
    
"models/hat/scream.mdl",
    
"models/hat/tv.mdl",
    
"models/hat/tophat.mdl",
    
"models/hat/sumbraro2.mdl",
    
"models/hat/sortinghat.mdl",
    
"models/hat/ShoopDaWhoop.mdl",
    
"models/hat/pirate2.mdl",
    
"models/hat/pillsburyhat.mdl",
    
"models/hat/paperbag.mdl",
    
"models/hat/pbbears.mdl",
    
"models/hat/merlin.mdl",
    
"models/hat/jamacahat2.mdl",
    
"models/hat/jackolantern.mdl",
    
"models/hat/jackinbox.mdl",
    
"models/hat/hood.mdl",
    
"models/hat/headphones.mdl",
    
"models/hat/giantscap.mdl",
    
"models/hat/earth.mdl",
    
"models/hat/dunce.mdl",
    
"models/hat/dodgerscap.mdl",
    
"models/hat/darth.mdl",
    
"models/hat/cheesehead.mdl",
    
"models/hat/bighead.mdl",
    
"models/hat/beerhat.mdl",
    
"models/hat/arrow.mdl",
    
"models/hat/afro.mdl"
}
public 
plugin_precache()
{
    static 
i
    
for(0sizeof g_hats_modesi++)
        
precache_model(g_hats_modes[i])
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}

// Sombreritos!
public dar_sombrero(id
{
    if(!
g_reset[id])
        return;

    switch(
g_reset[id]) 
    {
        case 
1..2g_hats[id] = 1
        
case 3..5g_hats[id] = 2
        
case 6..7g_hats[id] = 3
        
case 8..10g_hats[id] = 4
        
case 11..15g_hats[id] = 5
        
case 16..20g_hats[id] = 6
        
case 21..25g_hats[id] = 7
        
case 26..30g_hats[id] = // 30 casos osea los casos 1 - 30 serian los numeros de reset y los iguales a 1 2 3 etc. serian los models q seteas
    
}

    if(!
g_hats_ent[id] || !is_valid_ent(g_hats_ent[id])) 
    {
        new 
ent create_entity("info_target")
        
entity_set_int(entEV_INT_movetypeMOVETYPE_FOLLOW)
        
entity_set_edict(entEV_ENT_aimentid)
        
g_hats_ent[id] = ent
    
}

    
entity_set_model(g_hats_ent[id], g_hats_modes[g_hats[id]])
}

public 
del_sombrero(id
{
    if(
is_valid_ent(g_hats_ent[id]))
        
remove_entity(g_hats_ent[id])

    
g_hats_ent[id] = 0
}
client_putinserver(id)
{
    
g_hats[id] = 0

Mucho mas simple el precache y un poco mejor
No puedo descargar los hats. Fijate de subirlos a mediafire
(14/01/2014, 12:33 PM)exodisto escribió: [ -> ]
(14/01/2014, 12:29 PM)RauliTop escribió: [ -> ]hay que remover los hats cuando mueren o se desconectan, para evitar bugs

No creo que haya problemas pero por las dudas puse que solo esten habilitados para cuando estas vivo, gracias por avisar

si que hay problemas, porque a mí me pasaba que entraba alguien con gorro y se desconectaba, el siguiente en ocupar su slot, si no tiene "reset" mantendrá el gorro del otro.
aparte de este bug me pasaban otros del mismo estilo.
(14/01/2014, 02:12 PM)wiD escribió: [ -> ]No puedo descargar los hats. Fijate de subirlos a mediafire

Link arreglado

h34s en tu forma cuando se ejecuta la funcion para quitar el hat?
si, es mas la agregas donde quieras que se quite el sombrero con la función del_sombrero(id)
(14/01/2014, 09:28 PM)exodisto escribió: [ -> ]
(14/01/2014, 02:12 PM)wiD escribió: [ -> ]No puedo descargar los hats. Fijate de subirlos a mediafire

Link arreglado

h34s en tu forma cuando se ejecuta la funcion para quitar el hat?

no se puede subir un zip o rar? es mas cómodo...
Cita:no se puede subir un zip o rar? es mas cómodo...

http://www.mediafire.com/download/z0tppx...3/hats.rar
(15/01/2014, 01:43 AM)exodisto escribió: [ -> ]
Cita:no se puede subir un zip o rar? es mas cómodo...

http://www.mediafire.com/download/z0tppx...3/hats.rar

me refiero a AM-es... Genius
(15/01/2014, 03:42 AM)[Anti] escribió: [ -> ]
(15/01/2014, 01:43 AM)exodisto escribió: [ -> ]
Cita:no se puede subir un zip o rar? es mas cómodo...

http://www.mediafire.com/download/z0tppx...3/hats.rar

me refiero a AM-es... Genius

Ah ni idea como es xD
igualmente da lo mismo
sigan dejando entidades sueltas por ahi...
Recuerden remover todo cuando se desconecte
Código PHP:
new ent g_ent[id]
    new 
infotarget engfunc(EngFunc_AllocString"info_target")

    if (!
pev_valid(ent))
    {
        
engfunc(EngFunc_RemoveEntityent)
        
g_ent[id] = ent engfunc (EngFunc_CreateNamedEntityinfotarget)
        
set_pev(entpev_movetypeMOVETYPE_FOLLOW)
        
set_pev(entpev_aimentid)
        
// Aca indicamos que a partir del primer reset en adelante use el hat_1, luego a partir del reset 3 en adelante use el hat_2 y a partir del reset 5 use el hat_3 
        
if (g_isalive[id]) 
        {
            if (
g_reset[id] >= 1)
                
engfunc(EngFunc_SetModelenthat_1)
            if (
g_reset[id] >= 3)
                
engfunc(EngFunc_SetModelenthat_2)
            if (
g_reset[id] >= 5)
                
engfunc(EngFunc_SetModelenthat_3)
        }
    } 

en if (g_isalive[id]) tendrias que explicar/agregar que ahi hay que meter una variable que detecte que el usuario este conectado si no me equivoco

ejemplo: g_conectado que la mayoria usa eso para detectar si un player esta conect

pd: igual exelente post me re sirvio
si esta vivo esta conectado.
no sé porque miran este tutorial, está mal hecho y las cosas que le dijimos que tiene que cambiar no nos hace ni caso.

reportado y debería irse al trash
Yo use el otro de skrolex y me sirvio muchisimo. A este le tube que arreglar 500 cosas y encima se bugeaba to2
Creo yo que este es el unico post donde se encuentra algo util acerca de este tema
Lastima que se me bugio el sv al poner el code tal cual, s2
Para eso es un foro de ayuda, decis como se te bugueo y se trata de solucionarlo
Ami me sirvio y no se me cae el sv nada .. -.-
Whatever

Se podria crear un menu dentro del sma que paso LA BANDA ?
Código PHP:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <engine>

enum _:e_Data
{
    
i_Reset,
    
s_Model[64]
}

#define MaxHats 3
    
new const g_HatsConst[MaxHats][e_Data] = 

    { 
0"models/hats/dunce.mdl" }, 
    { 
1"models/hats/headphones.mdl" },
    { 
2"models/hats/pbbears.mdl" 
}

native zp_get_user_reset(id)
new 
g_Hat[33], g_DisabledHat[MaxHats]

public 
plugin_precache() {
    
register_plugin("?""?""?")
    
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
    
    for(new 
0MaxHatsi++)
    {
        if(
file_exists(g_HatsConst[i][s_Model]))
            
precache_model(g_HatsConst[i][s_Model])
        else 
        {
            
server_print("Hats: %s no existe en el directorio"g_HatsConst[i][s_Model])
            
g_DisabledHat[i] = true
        
}
    }
}

public 
fw_PlayerSpawn_Post(id)
{
    if(!
is_user_alive(id) || !get_user_team(id))
        return
        
    static 
iResetsiResets zp_get_user_reset(id)
    
    if(
iResets == g_HatsConst[iResets][i_Reset])
        if(!
g_DisabledHat[iResets]) fnSetHat(id_g_HatsConst[iResets][s_Model])
}

fnSetHat(idiRemove 0, const sModel[] = "")
{
    if(!
iRemove)
    {
        if (!
is_valid_ent(g_Hat[id]))
        {
            
g_Hat[id] = create_entity("info_target")
            if (!
is_valid_ent(g_Hat[id])) return;
            
            
entity_set_int(g_Hat[id], EV_INT_movetypeMOVETYPE_FOLLOW);
            
entity_set_edict(g_Hat[id], EV_ENT_aimentid);
            
entity_set_int(g_Hat[id], EV_INT_rendermodekRenderNormal)
        }
        
entity_set_model(g_Hat[id], sModel)
    }
    else
    {
        if (
is_valid_ent(g_Hat[id]))
        {
            
remove_entity(g_Hat[id])
            
g_Hat[id] = 0
        
}        
    }


Páginas: 1 2