Raised This Month: $ Target: $400
 0% 

[Ayuda] touch weapon


  
 
 
Thread Tools Display Modes
Author Message
KermesS
Senior Member
Join Date: Jan 2013
Location: Amsterdam
Old 08-18-2013 , 09:07   [Ayuda] touch weapon
#1

Estoy tratando de hacer para que al tirar un arma nueva al piso el siguiente owner tenga esa arma exactamente, ocea si yo tengo:

g_m4a1super, al tirarla al piso el siguiente owner que la obtenga reciba: g_m4a1super...
para esto me base en el code de un lanza granadas simplemente:

PHP Code:
// Setear arma nueva      
public fw_SetArma(ent, const model[])
{
    
// Entity invalido
    
if (!pev_valid(ent))
        return 
FMRES_IGNORED
     
    
// Obtener owner y classname
    
new owner pev(entpev_owner)
    new 
classname[33]; pev(entpev_classnameclassnamecharsmax(classname))
     
    
// Entity classname es weaponbox 
    
if(equal(classname"weaponbox"))
    {
        
// El arma del anterior owner era
        
if(g_m4a1super[owner], g_ak47super[owner])
        {
            
// Cuando cae al piso sigue siendo
            
g_m4a1super[owner] = g_ak47super[owner] = false
             
            
// Model w_
            
engfunc(EngFunc_SetModelentW_MODEL)

            
// Touch fix
            
set_task(0.1"touch_fix"owner)

            return 
FMRES_SUPERCEDE
        
}
    }
    return 
FMRES_IGNORED
}

public 
touch_fix(id

    if (
g_m4a1super[id] || g_ak47super[id]) 
            
g_m4a1super[id] = g_ak47super[id] = false
}

public 
fw_Touch(enttoucher

    
// ent/toucher invalido
    
if(!pev_valid(ent) || !pev_valid(toucher)) 
        return 
FMRES_IGNORED
     
    
// Obtener model, toucherclass, entityclass 
    
new model[33], toucherclass[33], entityclass[33
    
pev(entpev_modelmodelcharsmax(model)) 
    
pev(entpev_classnameentityclasscharsmax(entityclass)) 
    
pev(toucherpev_classnametoucherclasscharsmax(toucherclass)) 
     
    
// Si el toucher no es un player no le da el arma
    
if (!equali(toucherclass"player") || !equali(entityclass"weaponbox")) 
        return 
FMRES_IGNORED 
     
    
// Model w_
    
if(equali(modelW_MODEL)) 
    { 
        
// Si el toucher no es zombie
        
if(allowed_toucher(toucher)) 
        { 
            
// Le da el arma nueva
            
g_m4a1super[toucher] = g_ak47super[toucher] = true
        

    } 
     
    return 
FMRES_IGNORED

Como hago para que al tirar al piso el arma 1 (g_m4a1super) detecte que es el model_w de esa arma (M4A1) y despues lo mismo con la g_ak47super? (suponiendo que realmente tengo muchas mas armas ademas de esas 2).

Estaba pensando en algo como que el W_MODEL al llamarlo en el orden que va me de el arma algo como:

PHP Code:
new const W_MODEL[] = "models/w_m4a1.mdl""models/w_ak47.mdl" 
obviamente que eso no funcionaria pero es una idea general...
__________________

Last edited by KermesS; 08-18-2013 at 09:29.
KermesS is offline
Matians
Veteran Member
Join Date: Nov 2010
Location: ME QUIEREN ROBAR
Old 08-18-2013 , 10:51   Re: [Ayuda] touch weapon
#2

Podrias hacer una variable para entidad....

new bool:g_ent[256]

Cuando tira el arma...

g_ent[wEnt] = true
g_m4a1super[owner] = false

Si toca un arma
if (g_ent[wEnt]) // Y tiene el wEnt
g_m4a1super[toucher] = true
g_ent[wEnt] = false
__________________
Quote:
Originally Posted by YakumoHiratsuhi View Post
@DiegoCS
No sé talvez solo sea yo, pero tu me caes mal campeón.


JAJAJAJAJAJAJAJAJA

Quote:
Originally Posted by meTaLiCroSS View Post
Con 12 años quien no habla mierda detras de un PC, esperate a que te diga algo en persona jajajajaj VIVO DE AHI NO SALE JAJAJA
Matians is offline
KermesS
Senior Member
Join Date: Jan 2013
Location: Amsterdam
Old 09-01-2013 , 19:08   Re: [Ayuda] touch weapon
#3

Nuevamente intente recrear la forma para agarrar el arma de otro jugador, probando la forma de matians pero no me resulto, que estoy haciendo mal?

PHP Code:
public fw_SetModel(ent, const model[])
{
    if (!
pev_valid(ent))     
        return 
FMRES_IGNORED 
     
    
new owner pev(entpev_owner
    new 
classname[33]; pev(entpev_classnameclassnamecharsmax(classname)) 
     
    if(
equal(classname"weaponbox")) 
    { 
        if(
g_arma_prim[owner]) 
        {
            
zp_colored_print(owner"[ZP] Tiraste el arma :D")
            
g_entidad[ent] = true
            g_arma_prim
[owner] = false
             
            set_task
(0.1"touch_fix"owner)
             
            return 
FMRES_SUPERCEDE 
        
}
    }
     
    return 
FMRES_IGNORED 

}

public 
touch_fix(ident

    if (
g_arma_prim[id])
        
g_entidad[ent] = true
        g_arma_prim
[id] = false 


public 
fw_Touch(enttoucher

    if(!
pev_valid(ent) || !pev_valid(toucher)) 
        return 
FMRES_IGNORED
     
    new 
model[33], toucherclass[33], entityclass[33
    
pev(entpev_modelmodelcharsmax(model)) 
    
pev(entpev_classnameentityclasscharsmax(entityclass)) 
    
pev(toucherpev_classnametoucherclasscharsmax(toucherclass)) 
     
    if (!
equali(toucherclass"player") || !equali(entityclass"weaponbox")) 
        return 
FMRES_IGNORED 
    
    
if(allowed_toucher(toucher)) 
    { 
    
g_arma_prim[toucher] = true
    g_entidad
[ent] = false
    zp_colored_print
(toucher"[ZP] Agarraste el arma :D")
    }
     
    return 
FMRES_IGNORED;
}

stock allowed_toucher(player

    if (
g_zombie[player] || g_nemesis[player] || g_assassin[player] || g_arma_prim[player] || g_survivor[player] || g_wesker[player]) 
        return 
false 
     
    
return true 

__________________

Last edited by KermesS; 09-01-2013 at 19:08.
KermesS is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 09-01-2013 , 20:07   Re: [Ayuda] touch weapon
#4

Podrías probar algo con pev_iuser*
Cumple la funcion de asignar un número a una entidad.
Le podrías asignar muchos tipos de armas, por ej que cuando este en 0, arma original, en 1, arma especial 1 y asi infinitamente.
Solo tendrías que buscar como utilizarlo
__________________
alan_el_more is offline
UnrealT
Member
Join Date: Jul 2013
Old 09-01-2013 , 21:02   Re: [Ayuda] touch weapon
#5

PHP Code:
#define WEAPONKEY 300

public plugin_init () {
        
RegisterHam(Ham_Item_AddToPlayerweapon_m4a1"fw_m4a1_AddToPlayer"1)
}
public 
fw_SetModel(entmodel[])
{
    if(!
is_valid_ent(ent))
        return 
FMRES_IGNORED
    
    
static classname[33]
    
pev(entpev_classnameclassnamesizeof(classname))
    
    if(!
equal(classname"weaponbox"))
        return 
FMRES_IGNORED
        
    
static iOwner
    
    iOwner 
entity_get_edict(entEV_ENT_owner)
    
    
    if(
equal(model"models/w_m4a1.mdl"))
    {
        static 
weapon
        weapon 
find_ent_by_owner(-1"weapon_m4a1"ent)    
        
        if(!
pev_valid(weapon))
            return 
FMRES_IGNORED
        
        
if(g_m4a1super[iOwner])
        {
            
g_m4a1super[iOwner] = false
            
            entity_set_model
(entw_model)
            
entity_set_int(weaponEV_INT_impulseWEAPONKEY)

            return 
FMRES_SUPERCEDE
        
}
    }

    return 
FMRES_IGNORED
}

public 
fw_m4a1_AddToPlayer(entid)
{
    if(!
is_valid_ent(ent) || !is_user_connected(id))
        return 
HAM_IGNORED
        

    
    
if(entity_get_int(entEV_INT_impulse) == WEAPONKEY)
    {
        
g_m4a1super[id] = true
    

    return 
HAM_IGNORED

Espero que te sirva.

Last edited by UnrealT; 09-01-2013 at 21:05.
UnrealT is offline
 



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:38.


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