Raised This Month: $ Target: $400
 0% 

while loop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hops
Junior Member
Join Date: Mar 2006
Old 01-14-2008 , 03:55   while loop
Reply With Quote #1

Hi! this is my first plugin and I got stuck whith this while loop and I can't figure out where is the problem.

Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Plugin" #define VERSION "1.0" #define AUTHOR "author" new id, confdir[128], logfile[128], log[64], log2[64], name[32], Players[32]; new playerCount, player, emtline; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     get_configsdir( confdir, 127 );     format(logfile, 128, "%s/logfile.log", confdir);     set_task(5.0, "CTspeletaji",id,"",0, "b"); } public CTspeletaji() {     new CTsprnd = 7;     new i;     get_players(Players, playerCount, "e", "CT")     for (i=0; i<playerCount; i++) {         player = Players[i]         get_user_name(player, name, 31);         format(log, 63, "%s%d%d%d", name, i, playerCount, CTsprnd);         write_file(logfile, log, CTsprnd); //writes line with player name         CTsprnd++;     }     if(i==0) {         emtline = CTsprnd; //if there is no players in CT team start write from 7 line     }     else {         emtline = CTsprnd + i;     }     while(emtline<17) {         format(log2, 63, "%d%d%d%d", emtline, i, playerCount, CTsprnd);         write_file(logfile, log2, emtline); //writes emty line to log         emtline++;     } }

output for this code is(if one CT player is connected):
player017
8007
9118
10118
11118
12118
13118
14118
15118
16118

so, my problem is, why second line is 8007 while it must be 8118

amxx is just putting some info in log, it's not reading log file
in full code there is some more functions like CTspeletaji(), but they are doing the same(and have the same bug) and they actualy are the same, they only differs from CTspeletaji() with that, that they ar colecting info about Terrorist team player names or kills and so... but code of function is same, so I didn't post them becose then code would be very long

p.s sorry for my eanglish, hope u can understand what i wrote

Last edited by Hops; 01-15-2008 at 10:12.
Hops is offline
Old 01-14-2008, 09:28
_Master_
This message has been deleted by _Master_.
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 01-14-2008 , 14:47   Re: while loop
Reply With Quote #2

Could you possibly show us the full code? Or at least the relevant parts of it (where the Players, playerCount, log, log2 are defined, where is function called from, where the logfile is opened etc). But for a sake of finding this strange bug, you should post a full code.

Thanks.
__________________

Last edited by alien; 01-14-2008 at 14:51.
alien is offline
Send a message via ICQ to alien
Hops
Junior Member
Join Date: Mar 2006
Old 01-15-2008 , 10:06   Re: while loop
Reply With Quote #3

Quote:
Originally Posted by alien View Post
Could you possibly show us the full code? Or at least the relevant parts of it (where the Players, playerCount, log, log2 are defined, where is function called from, where the logfile is opened etc). But for a sake of finding this strange bug, you should post a full code.

Thanks.
I have updated original message
Hops 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