Raised This Month: $ Target: $400
 0% 

plugin crashes after some while


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hops
Junior Member
Join Date: Mar 2006
Old 01-19-2008 , 17:30   plugin crashes after some while
Reply With Quote #1

Hi!
I have plugin that writes some info in file and it works fine some while, but after ~1h it crashes

here is the error log
Code:
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::info (line 32)
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::CTspeletaji (line 79)
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::Tspeletaji (line 108)
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::CTfragi (line 128)
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::Tfragi (line 148)
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::CTkills (line 168)
L 01/19/2008 - 00:00:00: Couldn't create temp file
L 01/19/2008 - 00:00:00: [AMXX] Displaying debug trace (plugin "test.amxx")
L 01/19/2008 - 00:00:00: [AMXX] Run time error 10: native error (native "write_file")
L 01/19/2008 - 00:00:00: [AMXX]    [0] test.sma::Tkills (line 188)
and here is plugin

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Server status" #define VERSION "1.0" #define AUTHOR "Hops" new id, confdir[128], logfile[128], log[64], log2[64], name[32], Players[32]; new playerCount, player, emtline, i, rinda; new maplog[32], connplalog[16], maxsplalog[16], timeleftlog[16], nextmlog[32], hotlog[64], timelimlog[16]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     get_configsdir( confdir, 127 );     format(logfile, 128, "%s/serverinfo.log", confdir);     set_task(5.0, "info",id,"",0, "b");     set_task(5.0, "CTspeletaji",id,"",0, "b");     set_task(5.0, "Tspeletaji",id,"",0, "b");     set_task(5.0, "CTfragi",id,"",0, "b");     set_task(5.0, "Tfragi",id,"",0, "b");     set_task(5.0, "CTkills",id,"",0, "b");     set_task(5.0, "Tkills",id,"",0, "b"); } public info() {     new karte[32];     get_mapname(karte, 31);     format(maplog, 31, "%s", karte);     write_file(logfile, maplog, 0);     format(connplalog, 15, "%d", get_playersnum(1));     write_file(logfile, connplalog, 1);     format(maxsplalog, 15, "%d", get_maxplayers());     write_file(logfile, maxsplalog, 2);     new timeleft = get_timeleft();     format(timeleftlog, 15, "%d:%02d", (timeleft / 60), (timeleft % 60));     write_file(logfile, timeleftlog, 3);     new nextm[32];     get_cvar_string("amx_nextmap",nextm,31)     format(nextmlog, 31, "%s", nextm);     write_file(logfile, nextmlog, 4);     new hostname[64];     get_cvar_string("hostname",hostname,63)       format(hotlog, 63, "%s", hostname);     write_file(logfile, hotlog, 5);     new timelim[16];     get_cvar_string("mp_timelimit",timelim,15)       format(timelimlog, 15, "%s", timelim);     write_file(logfile, timelimlog, 6); } public CTspeletaji() {     new CTsprnd = 7;     get_players(Players, playerCount, "e", "CT")     for (i=0; i<playerCount; i++) {         player = Players[i];         get_user_name(player, name, 31);         if(is_user_alive(player)) {             format(log, 63, "%s", name);             write_file(logfile, log, CTsprnd);             CTsprnd++;         }         else {             format(log, 63, "gxPtrw%s", name);             write_file(logfile, log, CTsprnd);             CTsprnd++;         }     }     if(i==0) {         emtline = 6;     }     else {         emtline = 6 + playerCount;     }     while(++emtline<17) {         format(log2, 63, "");         write_file(logfile, log2, emtline);     } } public Tspeletaji() {     new Tsprnd = 17;     get_players(Players, playerCount, "e", "TERRORIST")     for (i=0; i<playerCount; i++) {         player = Players[i];         get_user_name(player, name, 31);         if(is_user_alive(player)) {             format(log, 63, "%s", name);             write_file(logfile, log, Tsprnd);             Tsprnd++;         }         else {             format(log, 63, "gxPtrw%s", name);             write_file(logfile, log, Tsprnd);             Tsprnd++;         }     }     if(i==0) {         emtline = 16;     }     else {         emtline = 16 + playerCount;     }     while(++emtline<27) {         format(log2, 63, "");         write_file(logfile, log2, emtline);     } }     public CTfragi() {     rinda = 27;     get_players(Players, playerCount, "e", "CT")     for (i=0; i<playerCount; i++) {         player = Players[i];         format(log, 63, "%d", get_user_frags(player));         write_file(logfile, log, rinda);         rinda++;     }     if(i==0) {         emtline = 26;     }     else {         emtline = 26 + playerCount;     }     while(++emtline<37) {         write_file(logfile, "", emtline);     } } public Tfragi() {     rinda = 37;     get_players(Players, playerCount, "e", "TERRORIST")     for (i=0; i<playerCount; i++) {         player = Players[i];         format(log, 63, "%d", get_user_frags(player));         write_file(logfile, log, rinda);         rinda++;     }     if(i==0) {         emtline = 36;     }     else {         emtline = 36 + playerCount;     }     while(++emtline<47) {         write_file(logfile, "", emtline);     } } public CTkills() {     rinda = 47;     get_players(Players, playerCount, "e", "CT")     for (i=0; i<playerCount; i++) {         player = Players[i];         format(log, 63, "%d", get_user_deaths(player));         write_file(logfile, log, rinda);         rinda++;     }     if(i==0) {         emtline = 46;     }     else {         emtline = 46 + playerCount;     }     while(++emtline<57) {         write_file(logfile, "", emtline);     } } public Tkills() {     rinda = 57;     get_players(Players, playerCount, "e", "TERRORIST")     for (i=0; i<playerCount; i++) {         player = Players[i];         format(log, 63, "%d", get_user_deaths(player));         write_file(logfile, log, rinda);         rinda++;     }     if(i==0) {         emtline = 56;     }     else {         emtline = 56 + playerCount;     }     while(++emtline<67) {         write_file(logfile, "", emtline);     } }

I can't figure it out why it works for 1h and then crashes, meybe its dumping RAM?

p.s. sorry for my eanglish
Hops is offline
kof2000k
Junior Member
Join Date: Jan 2008
Old 01-21-2008 , 01:58   Re: plugin crashes after some while
Reply With Quote #2

Check your hard disk space if enough for temp file.
kof2000k is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 01-21-2008 , 05:52   Re: plugin crashes after some while
Reply With Quote #3

I figure there's more to this plugin than listed. If that's true then you should also consider switching to the new file natives. If that's the entire plugin ( ie. the plugin is used just for logging purposes ) then make a single task that gets the info you require and dump it on file, again using the new file natives.

write_file() is inefficient because the work load it involves ( create a temp file, copy line by line the initial file to the temp one, add your line, copy the rest of the initial file, re-create initial file, copy the temp to the initial file ). All this can be done more efficiently using the new file natives ( replacing a line with a new one from a text file can be done within the same file - tho limited by initial line length )

EDIT: Looking again at your plugin I guess you don't actually need to replace a line in the file as it is re-created every time you dump the info

Last edited by _Master_; 01-21-2008 at 06:00.
_Master_ is offline
Hops
Junior Member
Join Date: Mar 2006
Old 01-21-2008 , 17:11   Re: plugin crashes after some while
Reply With Quote #4

to kof2000k

in hdd there is much of space thats not a problem


to _Master_

nop, thats all, plugin just logs some specific info in specific lines in file

I'm new in amxx scripting so could you give me a hinch with what I could replace write_file

actualy I need to replace a specific lines in file I don't need to re-create the file every time, as I sed I'm new in amxx scripting and I wrote this plugin as I could, if there is a better way to do that then please help me, if you can ofcourse

I know that there is a function fprintf(), but as I understand with this function I can't write in specific line or I'm wrong

Last edited by Hops; 01-21-2008 at 17:14.
Hops is offline
Hops
Junior Member
Join Date: Mar 2006
Old 01-23-2008 , 06:29   Re: plugin crashes after some while
Reply With Quote #5

enyone
Hops is offline
Alexutzu
Member
Join Date: Jan 2008
Location: Romania
Old 01-23-2008 , 06:51   Re: plugin crashes after some while
Reply With Quote #6

I don't know to help because I don't know how to create a plugin
Alexutzu 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 10:20.


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