AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with reduce damage (https://forums.alliedmods.net/showthread.php?t=12865)

jo12a 04-27-2005 02:52

help with reduce damage
 
Hello all,
i need help for plugin for reduce damage if victim is have admin flag.
every shot to get random heal from 1 to 5 heal without any reason what is the weapon that shoot to admin.
I tryed to change one script awp_damage but does not work :(
Here are a code:
Code:

#include <amxmodx>
 #include <amxmisc>
 #include <fun>
 #include <engine>
 #include <fakemeta>
 #include <cstrike>

 public plugin_init() {
        register_plugin("AWP Damage Reducer","0.11","Avalanche");
        register_cvar("mp_awpdmgreducer","1");
        register_forward(FM_TraceLine,"fw_traceline",1);

        // get name of mod
        new modname[32];
        get_modname(modname,31);

        // if not cstrike
        if(!equal(modname,"cstrike")) {
                pause("ae"); // lock plugin
        }
 }

 public plugin_modules() {
        require_module("FakeMeta");
 }

 public fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id) {

        // if cvar is off
        if(get_cvar_num("mp_awpdmgreducer") < 1) {
                return FMRES_IGNORED;
        }

        // id could be any entity id, not just a player, so...
        if(!is_user_connected(id) || !is_user_alive(id)) {
                return FMRES_IGNORED;
        }

        // get what the traceline hit
        new victim = get_tr(TR_pHit);

        // once again, victim could be any entity id, not just a player
        if(!is_user_connected(victim) || !is_user_alive(victim)) {
                return FMRES_IGNORED;
        }

        // check for admin flag
        if(!(is_user_admin(victim))) {
                return FMRES_IGNORED;
        }

        // get the weapon goodies
        new clip, ammo, weapon = get_user_weapon(id,clip,ammo);

        // stop if it is not the AWP or they have no bullets in the clip
        // if(weapon != CSW_AWP || clip <= 0) {
//              return FMRES_IGNORED;
//      }

        // get where the bullet hit
        new hitplace = get_tr(TR_iHitgroup);

        if(hitplace == HIT_CHEST) { // if it hit in chest
                set_tr(TR_iHitgroup,random_num(HIT_LEFTARM,HIT_RIGHTARM)); // redirect it an arm
        }
        else if(hitplace == HIT_STOMACH) { // if hit in stomach
                set_tr(TR_iHitgroup,random_num(HIT_LEFTLEG,HIT_RIGHTLEG)); // redirect to a leg
        }
        else if(hitplace == HIT_HEAD) { // if hit in head
                set_tr(TR_iHitgroup,random_num(HIT_LEFTARM,HIT_RIGHTARM)); // redirect to a leg
        }

        return FMRES_IGNORED;
 }

Any body can help ?

BioHazardousWaste 04-27-2005 07:44

I would just use on damage event, i'm not quite sure how the procedure you posted is called.

Code:
public plugin_init {     register_event("Damage", "DamageEvent", "b", "2!0")//When someone gets shot } public DamageEvent(id) {   //get who was hit, where and with what   new Weapon=0, HitZone=0   new Attacker = get_user_attacker(id,Weapon,HitZone)   /make sure they are both alive   if(!is_user_alive(id) || user_is_alive(Attacker))       return PLUGIN_HANDLED   /if victim is admin   if(is_user_admin(id))   {     //randomly heal     new Heal = random_num(1,5)     set_user_health(id, get_user_health(id) + Heal)    }    return PLUGIN_HANDLED }

That will randomly heal an admin 1 - 5 hp everytime he gets shot. If you want to know what weapon, use the numeric constants e.x. CSW_HEGRENADE. Hope it helps.

jo12a 04-27-2005 10:03

If i understand this will give heal to admin, but i want to reduce damage, to give only 5 heal from admin witout reason if has been shooted with awp or ak.

XxAvalanchexX 04-27-2005 13:17

rofl bio, just heal the users after they get headshotted with an AWP, maybe it'll bring them back to life! ;-)

*sigh*

No one understands me OR my coding.

BioHazardousWaste 04-27-2005 15:33

well that code is called BEFORE they get shot!! so.. if you wanted to, just do

if((get_user_health(Target) - Damage) < 5)
set_user_health(Target, Damage + 5)

That would leave them with 5 hp after the shot I believe. But personally, I think you need to learn to play cs, not have "hax" (scripts) so admins have an unfair advantage over others.

jo12a 04-27-2005 15:47

Yes i know, this is for one my friend.
Target i replace with id
but what can be Damage ?
how i say how to be or what to be ?

Sorry for my questions but i am newbie in cs scriptnig.

BioHazardousWaste 04-27-2005 16:37

look through the code, damage is set in this line:

new Attacker = get_user_attacker(id,Weapon,HitZone)

It sets Damage to the amount of HP the shot is about to take off.

jo12a 04-27-2005 16:45

I recive follow errors:
damage.sma(28) : error 017: undefined symbol "Target"
damage.sma(29) : error 017: undefined symbol "Target"
damage.sma(29) : warning 217: loose indentation
damage.sma(29) : error 017: undefined symbol "Damage"
damage.sma(29) : warning 215: expression has no effect
damage.sma(29) : error 001: expected token: ";", but found ")"
damage.sma(29) : fatal error 107: too many error messages on one line

and my script is:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Anti-Cheat", "2.0", "Condor Inc.");     register_event("Damage", "DamageEvent", "b", "2!0"); //When someone gets shot } public DamageEvent(id) {   //get who was hit, where and with what   new Weapon=0, HitZone=0;   new Attacker = get_user_attacker(id,Weapon,HitZone);   //make sure they are both alive   if(!is_user_alive(id) || is_user_alive(Attacker))       return PLUGIN_HANDLED;   //if victim is admin   if(is_user_admin(id))   {     //randomly heal     //new Heal = random_num(1,5)     //set_user_health(id, get_user_health(id) - Heal)     //set_user_hitzones(0, id, 64);     if((get_user_health(Target) - Damage) < 5)        set_user_health(Target, Damage + 5)    }    return PLUGIN_HANDLED; }

sorry, i am really newbie with this, do you can fix my error ?

xeroblood 04-27-2005 17:42

Quote:

Originally Posted by BioHazardousWaste
well that code is called BEFORE they get shot!!

No, the Damage Event is called after the damage is inflicted, unfortunately..
So Avalanche was right in his post, but he knew that..

Quote:

Originally Posted by BioHazardousWaste
look through the code, damage is set in this line:

new Attacker = get_user_attacker(id,Weapon,HitZone)

It sets Damage to the amount of HP the shot is about to take off.

No, that line will return the ID of the Attacking Player, and will also store values in the Weapon variable indicating the Weapon ID that was used by the Attacker, and the HitZone variable will have the HitZone ID of where the Victim was hit during the attack..

Maybe you just posted the wrong line of code you were talking about?

Anyway, I hope that lil' bit helps..

xeroblood 04-27-2005 17:51

Quote:

Originally Posted by jo12a
I recive follow errors:
damage.sma(28) : error 017: undefined symbol "Target"
damage.sma(29) : error 017: undefined symbol "Target"
damage.sma(29) : warning 217: loose indentation
damage.sma(29) : error 017: undefined symbol "Damage"
damage.sma(29) : warning 215: expression has no effect
damage.sma(29) : error 001: expected token: ";", but found ")"
damage.sma(29) : fatal error 107: too many error messages on one line

and my script is:
Code:
// [...]

sorry, i am really newbie with this, do you can fix my error ?


I am not sure exactly what you want, but maybe this helps (I put some comments in there):
Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Anti-Cheat", "2.0", "Condor Inc.");     register_event("Damage", "DamageEvent", "b", "2!0"); } public DamageEvent(id) {     //get who was hit, where and with what     new Weapon=0, HitZone=0; // Not used yet, but maybe you were planning to use them?     new Attacker = get_user_attacker(id,Weapon,HitZone);     // new Damage = read_data(2);     //make sure they are both alive     if(!is_user_alive(id) || is_user_alive(Attacker))         return PLUGIN_CONTINUE; // <-- Shouldn't return PLUGIN_HANDLED from hooked events..     //if victim is admin     if(is_user_admin(id))     {         //randomly heal, Damage WILL be done already tho, I dont know if you want to add         // that back too, if so The Damage variable is commented above, just add it here...         set_user_health(id, get_user_health(id) + random_num(1,5))     }     return PLUGIN_CONTINUE; // <-- Shouldn't return PLUGIN_HANDLED from hooked events.. }

Oh, and I changed your PLUGIN_HANDLED's to PLUGIN_CONTINUE's, read comments..

I hope that helps..


All times are GMT -4. The time now is 16:42.

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