AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   wall kill scripting help (https://forums.alliedmods.net/showthread.php?t=49244)

SAMURAI16 12-30-2006 12:47

wall kill scripting help
 
i maked this plugin and i have an problem :
When i switch team appear that message like when i kill an enemy trough wall
Rest of all plugin works (when i kill an enemy trough wall appear message correct)
Please if somebody can fix
Code :
Code:

#include <amxmodx>
#include <fakemeta>
#include <xs>

new const PLUGIN[] = "Wall Shot"
new const VERSION[] = "0.1"
new const AUTHOR[] = "SAMURAI"

new mWallKills[33]
new cvartipe
new cvarduration

new mlist[2][]=
{
    "%s killed %s trough wall !",
    "%s killed %s with him Wallhack :)"
}

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("DeathMsg", "deathMSG", "a")
    cvartipe = register_cvar("wallshot_showtype","1")
    cvarduration = register_cvar("wallshot_hudtime","5.0") // time in seconds
   
}

public deathMSG()
{
    new iAttacker = read_data(1)
    new iVictim = read_data(2)
    new kname[32], vname[32]
    get_user_name(iVictim,kname,31)
    get_user_name(iAttacker,vname,31)
   
    new bool:qVisible = fm_is_ent_visible(iAttacker, iVictim)
    if (!qVisible)
    {
        mWallKills[iAttacker]++
        switch (get_pcvar_num(cvartipe))
        {
            case 1:
            {
                set_hudmessage(0, 0, 255, 0.28, 0.26, 0, 6.0, get_pcvar_float(cvarduration))
                show_hudmessage(0,(mlist[random_num(0,1)]),vname,kname)
            }
            case 2:
            {
                client_print(0,print_chat,(mlist[random_num(0,1)]),vname,kname)
            }
            case 3:
            {
                client_print(0,print_center,(mlist[random_num(0,1)]),vname,kname)
            }
        }
    }
}
       
stock bool:fm_is_ent_visible(index, entity) {
    new Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
    pev(index, pev_origin, origin)
    pev(index, pev_view_ofs, view_ofs)
    xs_vec_add(origin, view_ofs, eyespos)

    new Float:entpos[3]
    pev(entity, pev_origin, entpos)
    engfunc(EngFunc_TraceLine, eyespos, entpos, 0, index)

    switch (pev(entity, pev_solid)) {
        case SOLID_BBOX..SOLID_BSP: return global_get(glb_trace_ent) == entity
    }

    new Float:fraction
    global_get(glb_trace_fraction, fraction)
    if (fraction == 1.0)
        return true

    return false
}


stupok 12-30-2006 13:11

Re: wall kill scripting help
 
You have to check not only if the attacker is not visible, but if the attacker is another player. So check if the attacker is alive or connected. If the player commits suicide or switches teams, the "attacker" may not be visible.

SAMURAI16 12-30-2006 13:31

Re: wall kill scripting help
 
something like this ?
Code:

#include <amxmodx>
#include <fakemeta>
#include <xs>

new const PLUGIN[] = "Wall Shot"
new const VERSION[] = "0.1"
new const AUTHOR[] = "SAMURAI"

new mWallKills[33]
new cvartipe
new cvarduration

new mlist[2][]=
{
    "%s killed %s trough wall !",
    "%s killed %s with him Wallhack :)"
}

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("DeathMsg", "deathMSG", "a")
    cvartipe = register_cvar("wallshot_showtype","1")
    cvarduration = register_cvar("wallshot_hudtime","5.0") // time in seconds
   
}

public deathMSG()
{
    new iAttacker = read_data(1)
    new iVictim = read_data(2)
    new kname[32], vname[32]
    get_user_name(iVictim,kname,31)
    get_user_name(iAttacker,vname,31)
   
    new bool:qVisible = fm_is_ent_visible(iAttacker, iVictim)
    if ((qVisible) && !is_user_connected(iAttacker) && !is_user_alive(iAttacker))
    {
        return PLUGIN_HANDLED
}
   
    if ((!qVisible) && !(iAttacker == iVictim) && is_user_alive(iAttacker) && is_user_connected(iAttacker))
    {
        mWallKills[iAttacker]++
        switch (get_pcvar_num(cvartipe))
        {
            case 1:
            {
                set_hudmessage(0, 0, 255, 0.28, 0.26, 0, 6.0, get_pcvar_float(cvarduration))
                show_hudmessage(0,(mlist[random_num(0,1)]),vname,kname)
            }
            case 2:
            {
                client_print(0,print_chat,(mlist[random_num(0,1)]),vname,kname)
            }
            case 3:
            {
                client_print(0,print_center,(mlist[random_num(0,1)]),vname,kname)
            }
        }
    }
    return PLUGIN_CONTINUE
}
       
stock bool:fm_is_ent_visible(index, entity) {
    new Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
    pev(index, pev_origin, origin)
    pev(index, pev_view_ofs, view_ofs)
    xs_vec_add(origin, view_ofs, eyespos)

    new Float:entpos[3]
    pev(entity, pev_origin, entpos)
    engfunc(EngFunc_TraceLine, eyespos, entpos, 0, index)

    switch (pev(entity, pev_solid)) {
        case SOLID_BBOX..SOLID_BSP: return global_get(glb_trace_ent) == entity
    }

    new Float:fraction
    global_get(glb_trace_fraction, fraction)
    if (fraction == 1.0)
        return true

    return false
}


stupok 12-30-2006 13:46

Re: wall kill scripting help
 
Looks good, check the results. However:

Code:

!(something == anothersomething)
Should be replaced with:

Code:

something != anothersomething

SAMURAI16 12-30-2006 13:47

Re: wall kill scripting help
 
ya works thanks man


All times are GMT -4. The time now is 22:23.

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