AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting rid of Get_User_attack (https://forums.alliedmods.net/showthread.php?t=19385)

Sir-LaggAlot 10-15-2005 16:05

Getting rid of Get_User_attack
 
Im getting native run time errors on damage function
Code:
    new damage = read_data(2)     new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)

and i want to know what to add/remove/edit to get rid of this error.
Code:

Invalid player id 0
[AMXX] Run time error 10: native error (native "get_user_attacker")


Brad 10-15-2005 19:26

You need to check if id is a valid player id before passing it into get_user_attacker().

Sir-LaggAlot 10-15-2005 19:28

Can you give me the check function for the valid id player

Batman/Gorlag 10-15-2005 19:32

Code:
is_user_alive(id)  //Checks if the user is alive is_user_connected(id)  //Checks if the user is connected

Those are your two checks, to see if they are valid players or not.

Brad 10-15-2005 19:39

I don't recall what happens when you pass those two functions a value of 0 as the player id. To be safe, I'd check to make sure id > 0 before calling anything else. If it's 0, it's not a player.

Sir-LaggAlot 10-15-2005 19:43

Function Plz. :o

Batman/Gorlag 10-15-2005 19:44

When you pass 0 into the two functions all it will return is 0 or false, since it's not a player and all. The two functions won't explode :wink: .

Brad 10-15-2005 19:45

It's not a function. It's a comparison.
Code:
if (id > 0)

Brad 10-15-2005 19:47

Gorlag, if he's calling get_user_attacker, a check on is_user_alive isn't necessary is it? Perhaps the attacker killed the player.

XxAvalanchexX 10-15-2005 20:58

Quote:

Originally Posted by Brad
I don't recall what happens when you pass those two functions a value of 0 as the player id.

They return false. Also, is_user_alive returns false when the player isn't even connected, which is handy.


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

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