AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get user attack (https://forums.alliedmods.net/showthread.php?t=24714)

NeverDie 03-01-2006 12:38

Get user attack
 
Hi i was wonding how i can get a user attacker and make it so if a user is attacked with anything but a knife it will force them to drop a weapon i been trying to use something like
Code:

register_event("Damage", "checkDamage", "b", "2!0")

public checkDamage(id)
{
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
       
        if ( attacker <= 0 )
        {
                return
        }       
        else if ( weapon == CSW_KNIFE )
        {
                return
        }
        else
        {
                client_cmd(attacker, "drop")
        }
       
        return
}

But this seems not to work because when you fall of something it makes the victim still drop his weapon and when u att some1 it makes them drop there weapon.

v3x 03-01-2006 12:42

Code:
register_event("Damage", "checkDamage", "b", "2!0") public checkDamage(id) {    new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)    if(!is_user_alive(attacker) || attacker == id)       return PLUGIN_CONTINUE    if(weapon != CSW_KNIFE)       client_cmd(attacker, "drop")    return PLUGIN_CONTINUE }

NeverDie 03-01-2006 12:52

Thx, but if i fall of something it still makes me drop my own weapon.

v3x 03-01-2006 12:55

Try the edited version.

NeverDie 03-01-2006 12:58

Thanks now it doesnt make me drop my weapon just need to get some1 on my server now to see if works.

NeverDie 03-01-2006 13:06

Is there anyway i can make it so it checks every few seconds for a few seconds if your being attacked rather then always? i have been lookin at somethin like set_task(1.0,"checkDamage",0,"",0,"b" ) but i not sure how it would be used?

v3x 03-01-2006 13:16

Yes.

Code:
public client_putinserver(id) {   set_task(1.0, "checkDamage", id, _, _, "b") } public checkDamage(id) {   if(!is_user_connected(id) || !is_user_alive(id))     return;   // stuff }

NeverDie 03-01-2006 13:18

But how can u make it loop for a few seconds then stop for few etc?


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

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