Shield Tutorial - Sequence Check

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1229
Gender:
United States of America

Shield Tutorial - Sequence Check

Post by Archive-Poster »

Heres a new way of getting whether a person has shield.
By sequence

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <engine>

public plugin_init()
{
    register_plugin("Shield","1.0","default");
    register_clcmd("get_shield","shield",ADMIN_LEVEL_A,": name")
}

public shield(id)
{
    new arg[32]
    read_argv(1,arg,31)
    
    new vid = cmd_target(id,arg,8);
    
    new seq = entity_get_int(vid,EV_INT_sequence);
    
    new name[32]
    get_user_name(vid,name,31);
    
    //SEQUENCCE 89 = Shield + Knife
    //SEQUENCE 94 = Shield + Pistol
    //SEQUENCE 98 = Shield only (right clicked)
    
    
    if(seq == 89)
    {
        client_print(0,3,"%s has shield and a knife",name);
    }
    else if(seq == 94)
    {
        client_print(0,3,"%s has shield and a pistol",name);
    }
    else if(seq == 98)
    {
        client_print(0,3,"%s has shield",name);
    }
    
    client_print(0,3,"Sequence: %d",seq);
    
    return PLUGIN_HANDLED
}
User avatar
Archive-Poster
Posts: 1229
Gender:
United States of America

Re: Shield Tutorial - Sequence Check

Post by Archive-Poster »

Another one. Originaly posted by Ryan on AMX forums.

Code: Select all

#include <amxmodx>
#include <engine>

new bool:gotShield[33]

public pfn_touch(ptr, ptd) {

    new entId   = ptr
    new id      = ptd

    if ( id < 0 || id > 32 || !is_user_alive(id) || gotShield[id] )
        return PLUGIN_CONTINUE


    new modelName[32]
    entity_get_string(entId, EV_SZ_model, modelName, 31)

    if ( containi(modelName,"w_shield.mdl") != -1 ) {

        new parm[1]
        parm[0] = id

        remove_task(2200 + id,0)
        set_task(0.1,"check_shield",2200 + id,parm,1)

    }


    return PLUGIN_CONTINUE

}


public check_shield(parm[1]) {

    new id = parm[0]

    new modelName[32]
    entity_get_string(id, EV_SZ_viewmodel, modelName, 31)

    if ( containi(modelName,"v_shield_") != -1 ) {

        // Do some stuff in here. It's found!

    }
       

    return PLUGIN_HANDLED

}
User avatar
Archive-Poster
Posts: 1229
Gender:
United States of America

Re: Shield Tutorial - Sequence Check

Post by Archive-Poster »

Hmm the shield Offset in CS is 494. Only a few bugs with it though. (engine problem of-course)
Im gonna do a few more tests and let you now about it
User avatar
Archive-Poster
Posts: 1229
Gender:
United States of America

Re: Shield Tutorial - Sequence Check

Post by Archive-Poster »

The problem is finding an efficient way of getting the shield (ie- a forward).. having to listen to too many events for different parts makes for big and sloppy code to find out one simple thing! and setting a milisecond timer (task) is a no no.

the only ways to detect shield are...

client command: shield (whatever buys it right out)
menu command: equipment menu, key 8
touch event when walking over it to pick it up
hideweapon event -OR- curweapon event... just in case any of the above were missed.

however, many plugins give players shields via the give_item function, which does not trigger any of the above events.

it's too bad valve (ming) didnt make this easier for scripters to detect.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests