AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fall damage? (https://forums.alliedmods.net/showthread.php?t=133297)

Gadzislaw007 07-23-2010 19:43

Fall damage?
 
Well, Hi. Another problem here...

Code:

public Ham_Damage(id, inflictor, attacker, Float:damage, Damage)
{
       
        if(get_user_weapon(attacker) == CSW_KNIFE && zwiadowca[attacker] && cs_get_user_team(attacker) != cs_get_user_team(id))
        {
                user_kill(id)
                set_user_frags(attacker, get_user_frags(attacker)+1)
               
               
        }

       
}

Well it works well, but when I hurt myself by falling from high or something like that console says that id is invalid and it deos not hurt me... How to fix it?

Gadzislaw007 07-23-2010 19:59

Re: Fall damage?
 
Gosh, I'm so stupid :D.
Fixed, but if somebody has a problem like this here is the answer:


Code:

public Ham_Damage(id, inflictor, attacker, Float:damage, Damage)
{
        if(attacker != 0){
                if(get_user_weapon(attacker) == CSW_KNIFE && zwiadowca[attacker] && cs_get_user_team(attacker) != cs_get_user_team(id))
                                {
                                user_kill(id)
                                set_user_frags(attacker, get_user_frags(attacker)+1)
               
               
                                }
                        }

}


Bugsy 07-24-2010 07:05

Re: Fall damage?
 
Quote:

Originally Posted by PattyBiena (Post 1249771)
if (damage & DMG_FALL)

Do you ever read a thread before posting. Your little code snippet there has nothing to do with his problem.

Hunter-Digital 07-24-2010 09:18

Re: Fall damage?
 
And his problem is ? I don't get it, the title says "Fall damage ?" and the code checks for knife and team... WTF ?!

It's not even a good method, if player is killed by a grenade the hook will still continue if player has knife in his hand while the grenade explodes.

So, you might want to explain what you want to do, expecially if you have foreign language variable names (zwiadowca[attacker]).

Bugsy 07-24-2010 09:30

Re: Fall damage?
 
Quote:

Originally Posted by Gadzislaw007 (Post 1249533)
Well it works well, but when I hurt myself by falling from high or something like that console says that id is invalid and it deos not hurt me... How to fix it?

He was getting an invalid player error because when fall damage occurs attacker = 0. So when get_user_weapon( attacker ) is called he would error. He selected a bad thread title.

Gadzislaw007 07-24-2010 11:58

Re: Fall damage?
 
Well topic name isn't really bad, because it is basicaly about fall damage.

Quote:

Originally Posted by Hunter-Digital (Post 1250020)
It's not even a good method, if player is killed by a grenade the hook will still continue if player has knife in his hand while the grenade explodes.

It is, because in this mod someone who has knife deosn't get a grenade :P.

Hunter-Digital 07-25-2010 09:38

Re: Fall damage?
 
No it's not, you should check inflictor if it's a player index, if it is then get the player's weapon... if not, then it's a nade, c4, map entity or map itself.

Just replace "attacker != 0" with "1 <= inflictor <= maxplayers" (maxplayers is the get_maxplayers() global var)

Gadzislaw007 07-25-2010 09:54

Re: Fall damage?
 
There is no need for fixing the knife kill, because somebody who has knife can't actually have c4, granade and anything what allows you to change weapon before it damages.

But thanks for the second tip, I'll try it.


All times are GMT -4. The time now is 00:14.

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