Raised This Month: $ Target: $400
 0% 

Getting rid of Get_User_attack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sir-LaggAlot
Member
Join Date: Oct 2005
Location: USA
Old 10-15-2005 , 16:05   Getting rid of Get_User_attack
Reply With Quote #1

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")
Sir-LaggAlot is offline
Send a message via AIM to Sir-LaggAlot
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-15-2005 , 19:26  
Reply With Quote #2

You need to check if id is a valid player id before passing it into get_user_attacker().
Brad is offline
Sir-LaggAlot
Member
Join Date: Oct 2005
Location: USA
Old 10-15-2005 , 19:28  
Reply With Quote #3

Can you give me the check function for the valid id player
Sir-LaggAlot is offline
Send a message via AIM to Sir-LaggAlot
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 10-15-2005 , 19:32  
Reply With Quote #4

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.
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-15-2005 , 19:39  
Reply With Quote #5

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.
Brad is offline
Sir-LaggAlot
Member
Join Date: Oct 2005
Location: USA
Old 10-15-2005 , 19:43  
Reply With Quote #6

Function Plz.
Sir-LaggAlot is offline
Send a message via AIM to Sir-LaggAlot
Batman/Gorlag
Senior Member
Join Date: Aug 2005
Old 10-15-2005 , 19:44  
Reply With Quote #7

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 .
__________________
GRR If only the amxmod programming were in Java.....
Java and C used to be two different languages, now Java is turning into another C. My logevent plugin
Batman/Gorlag is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-15-2005 , 19:45  
Reply With Quote #8

It's not a function. It's a comparison.
Code:
if (id > 0)
Brad is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-15-2005 , 19:47  
Reply With Quote #9

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.
Brad is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-15-2005 , 20:58  
Reply With Quote #10

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.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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