Raised This Month: $ Target: $400
 0% 

Why am I getting this error?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-11-2006 , 23:45   Why am I getting this error?
Reply With Quote #1

For some reason I'm getting a runtime error on set_user_frags, but the plugin is working. o.O

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx>   #include <csstats>   #include <cstrike>   #include <fun>   /*Description What this plugin does is determine a user's overall kills/deaths and sets their scores accordingly. So, if I have for example 300 kills and 123 deaths, when I join the server my score will be 300-123. Credits: GHW_Chronic - Coding help. v3x - Coding help.                     Changelog                 v. 1.0 - Original Coding                 v. 1.1 - Addition of Description, credits, changelog                 v. 1.2 - Coding Optimization                 v. 1.3 - Removed sv_restartround bug.                 v. 1.4 - Added new event.                 v. 1.5 - Fixed bug! :)*/ new bool:gSet[33]; new gStats[8]; new gBodyhits[8]; public plugin_init() {       register_plugin("Set Stats", "1.5", "Satan")     register_event("ResetHUD" , "round", "be")     register_event("TextMsg", "event_game_will_restart", "a", "2=#Game_will_restart_in")     register_logevent("new_round" , 2 , "1=Round_Start");       register_logevent("MyFuncRoundStart", 2, "0=World triggered", "1=Round_Start") }   //------------------------------------------------------------------- public client_connect(id) {     gSet[id] = false } //------------------------------------------------------------------- public new_round(id) {     set_task(0.1, "set_stats", id) } //------------------------------------------------------------------- public round(id) {     set_task(0.1, "set_stats", id) } //------------------------------------------------------------------- public event_game_will_restart(id) {     set_task(0.1, "set_stats", id) } //------------------------------------------------------------------- public MyFuncRoundStart(id) {     set_task(0.1, "set_stats", id) } //------------------------------------------------------------------- public set_stats(id) {     get_user_stats(id, gStats, gBodyhits)     new kills = get_user_frags(id)     new timesdied = get_user_deaths(id)     new frags = gStats[0]     new deaths = gStats[1]         if(!gSet[id] && frags != kills || deaths != timesdied)     {         set_user_frags(id, frags)         cs_set_user_deaths(id, deaths);         gSet[id] = true;     }     return PLUGIN_CONTINUE }

Quote:

L 03/11/2006 - 23:45:02: [AMXX] Run time error 10: native error (native "set_user_frags")
L 03/11/2006 - 23:45:02: [AMXX] [0] phpFtkpF2.sma::set_stats (line 74)
Anyone have any clue as to what I did wrong? Thanks a lot
Jordan is offline
Kraugh
Senior Member
Join Date: Jan 2006
Location: barrington, ri
Old 03-12-2006 , 00:16  
Reply With Quote #2

new_round, event_game_will_restart, and MyFuncRoundStart are not passed player ids. even though you have them in the header, the value is 0 because this is a global event and there is no individual id. thus, you end up trying to assign frags to player 0, which is not in game.
__________________
"You can not restrain a fool from speaking, but nothing obliges you to listen."
Kraugh is offline
Send a message via AIM to Kraugh
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-12-2006 , 00:55  
Reply With Quote #3

So getting rid of the ids in the function header and then making the set_task to 0 will fix this I assume. Thanks a lot
Jordan is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 03-12-2006 , 08:41  
Reply With Quote #4

That might get rid of the current error but it's bound to add more errors because then you'd be trying to pass 0 to a whole host of functions that don't expect 0 to be passed in.

What are you trying to do? Mess with the stats on every new round? Is it acceptable to change them when freezetime ends each round?
Brad is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-12-2006 , 09:46  
Reply With Quote #5

This is the same things (round start (freezetime end)):
Code:
    register_logevent("new_round" , 2 , "1=Round_Start");
Code:
    register_logevent("MyFuncRoundStart", 2, "0=World triggered", "1=Round_Start")
VEN is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-12-2006 , 10:10  
Reply With Quote #6

I'm trying to make it so that when the round is manually restarted the stats reset, but also so that when the round starts the stats reset too, and it's working, but I'm still getting the errors. -.-

Code:
new bool:gSet[33]; new gStats[8]; new gBodyhits[8]; public plugin_init() {       register_plugin("Set Stats", "1.6", "Satan")     register_event("ResetHUD", "round", "be")     register_event("TextMsg", "event_game_will_restart", "a", "2=#Game_will_restart_in")     register_logevent("new_round", 2 , "1=Round_Start");       register_logevent("MyFuncRoundStart", 2, "0=World triggered", "1=Round_Start") }   //------------------------------------------------------------------- public client_connect(id) {     gSet[id] = false } //------------------------------------------------------------------- public new_round() {     set_task(0.1, "set_stats") } //------------------------------------------------------------------- public round(id) {     set_task(0.1, "set_stats", id) } //------------------------------------------------------------------- public event_game_will_restart() {     set_task(0.1, "set_stats") } //------------------------------------------------------------------- public MyFuncRoundStart() {     set_task(0.1, "set_stats") } //------------------------------------------------------------------- public set_stats(id) {     get_user_stats(id, gStats, gBodyhits)     new kills = get_user_frags(id)     new timesdied = get_user_deaths(id)     new frags = gStats[0]     new deaths = gStats[1]         if(!gSet[id] && frags != kills || deaths != timesdied)     {         set_user_frags(id, frags) // this line here         cs_set_user_deaths(id, deaths);         gSet[id] = true;     }     return PLUGIN_CONTINUE }

I don't know why it would work, but there's no bugs with the plugin (with the exception of the runtime error).


L 03/12/2006 - 10:11:42: [AMXX] Displaying debug trace (plugin "setstats.amxx")
L 03/12/2006 - 10:11:42: [AMXX] Run time error 10: native error (native "set_user_frags")
L 03/12/2006 - 10:11:42: [AMXX] [0] php0KsT1q.sma::set_stats (line 78)
Jordan is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-12-2006 , 10:24  
Reply With Quote #7

Because you not always pass positive id to the function. Also read what i posted above. You do not need two equal function.
VEN is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-12-2006 , 10:38  
Reply With Quote #8

So how would I pass a positive id to the function?
Jordan is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 03-12-2006 , 10:39  
Reply With Quote #9

Quote:
Originally Posted by Brad
What are you trying to do? Mess with the stats on every new round?
Quote:
Originally Posted by ^_^Satan^_^
I'm trying to make it so that when the round is manually restarted the stats reset, but also so that when the round starts the stats reset too, and it's working, but I'm still getting the errors.
So, the answer is yes, you are trying to alter the stats at the beginning of every round. You don't need to capture all that stuff you're trying to capture. If altering the stats at freeze end is acceptable, you only need to capture that ONE thing.

Quote:
Originally Posted by Brad
That might get rid of the current error but it's bound to add more errors because then you'd be trying to pass 0 to a whole host of functions that don't expect 0 to be passed in.
Quote:
Originally Posted by ^_^Satan^_^
I don't know why it would work, but there's no bugs with the plugin (with the exception of the runtime error).
I already answered this.
Brad is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-12-2006 , 11:14  
Reply With Quote #10

I tried using just new_round but for some reason the stats don't get reset unless I use ResetHUD.
Jordan 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 20:22.


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