Raised This Month: $ Target: $400
 0% 

Run time error 10: native error (native "get_user_stats")


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-22-2010 , 05:19   Run time error 10: native error (native "get_user_stats")
Reply With Quote #1

Code:
		new targetid, body
		get_user_aiming(id, targetid, body, 9999)
		new SzRankPos, SzRankMax, SzABC[8]
		SzRankPos = get_user_stats(targetid, SzABC, SzABC)
		SzRankMax = get_statsnum()
		set_hudmessage(10, 10, 50, -1.00, 0.63, 0, 1.0, 1.0, 0.1, 0.2, -1) 
		ShowSyncHudMsg(id, hudsync, "His Rank %d/%d", SzRankPos, SzRankMax)
This is a easy code, but I get error when the server run a period time.
Not crash server.
Run time error 10: native error (native "get_user_stats")
How can I fix it?
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 08-22-2010 , 10:18   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #2

What is the entire error?
RedRobster is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-22-2010 , 16:18   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #3

I'm most certain it's the "invalid player #??" one.

In your code, you don't even check if targetid exists before doing something. Check if targetid is a player... with 1 <= targetid <= get_maxplayers() (cache the value in a global variable set in plugin_init() )
__________________
Hunter-Digital is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-22-2010 , 23:16   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #4

Quote:
Originally Posted by RedRobster View Post
What is the entire error?
L 08/23/2010 - 11:139: [CSX] Player out of range (7X)
L 08/23/2010 - 11:139: [AMXX] Displaying debug trace (plugin "SPEC+Hud+Message.amxx")
L 08/23/2010 - 11:139: [AMXX] Run time error 10: native error (native "get_user_stats")
L 08/23/2010 - 11:139: [AMXX] [0] Rank.sma:HM (line 47)

Quote:
Originally Posted by Hunter-Digital View Post
I'm most certain it's the "invalid player #??" one.

In your code, you don't even check if targetid exists before doing something. Check if targetid is a player... with 1 <= targetid <= get_maxplayers() (cache the value in a global variable set in plugin_init() )
What do you mean?
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-22-2010 , 23:26   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #5

What do you mean what do I mean ?

That's the error, "Player out of range", it triggers because you don't check if get_user_aiming() actually hits a player or even hits anything at all ! get_user_stats() only works on players.
__________________
Hunter-Digital is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-22-2010 , 23:55   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #6

Quote:
Originally Posted by Hunter-Digital View Post
What do you mean what do I mean ?

That's the error, "Player out of range", it triggers because you don't check if get_user_aiming() actually hits a player or even hits anything at all ! get_user_stats() only works on players.
Then I need to change or add what in my code?
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 08-23-2010 , 00:04   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #7

maybe is_user_alive(targetid)

or

is_user_connected(targetid)
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
GarbageBox
Senior Member
Join Date: Feb 2010
Old 08-23-2010 , 03:07   Re: Run time error 10: native error (native "get_user_stats")
Reply With Quote #8

Fixed, thanks all.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Reply


Thread Tools
Display Modes

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 21:55.


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