Raised This Month: $ Target: $400
 0% 

[resolved] Custom Parse Function Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-29-2006 , 19:29   Re: New File Natives
Reply With Quote #1

stupok69: I'll post back in a few minutes. Adding debug.
__________________
Released six formerly private plugins. Not active here since ages.

Last edited by MaximusBrood; 12-29-2006 at 19:35.
MaximusBrood is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-29-2006 , 19:50   Re: New File Natives
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> new file[64] public plugin_init() {     register_plugin("Users List", "1.0", "stupok69")         register_concmd("readline", "read_function")         get_basedir(file, 63)     format(file, 63, "%s/users_list.txt", file) } public read_function() {     //Learn that strings are null-terminated!     new text[65], index[6], steamid[19], name[33], logs[5]         new fp = fopen(file, "rt")         if(fp)     {         fgets(fp, text, 64)             fclose(fp)             //The begin and ends were wrong!         //Learn that strings are null-terminated!         maximus_parse(text, 0, 5, index, 5)         maximus_parse(text, 6, 18, steamid, 18)         maximus_parse(text, 25, 32, name, 32)         maximus_parse(text, 63, 4, logs, 4)             server_print("text: %s", text)         server_print("INDEX:%s^nSTEAMID:%s^nNAME:%s^nLOGS:%s", index, steamid, name, logs)     }     else     {         server_print("File could not be opened.")     } } stock maximus_parse(text[], start, lenght, destination[], destlen) {     //Use errorchecking here, I'll not add it now     for(new a = 0; (a < lenght) && (a < destlen); ++a)         destination[a] = text[start + a]; }
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 12-29-2006 , 21:11   Re: New File Natives
Reply With Quote #3

Thanks MaximusBrood, it turns out I didn't determine the length properly, 5 should have been 6, 18 -> 19, 33 -> 34, etc.

Thanks for the short parse function, too. I love to see short, useful bits of code like that .

Everything works just like I wanted it to now.
stupok 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 22:22.


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