Raised This Month: $ Target: $400
 0% 

How to swap between lines?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 12-29-2012 , 16:33   How to swap between lines?
Reply With Quote #1

I have a file like this format
Code:
[STEAM_ID_1] // SteamId
Noob1 // name
13/9/2012 14:50:49 // last connect time

[STEAM_ID_2]
Noob2
12/9/2012 11:30:12

[STEAM_ID_3]
Noob3
21/12/2012 21:21:21
Let's assume that I'm in the first line, how to go to the second and the third line and read them using fgets() in the same function?

Here is my current code:
Code:
enum _:DATA {     NAME[32],     STEAMID[35],     LAST_CONNECT[50] } public admin_cmd(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         CheckFile()         //console_print(id, "# %s %-22.22s %-22.22s", "Name", "SteamId", "Last Connect Time")     server_print("# %-22.22s %-22.22s %s", "Name", "SteamId", "Last Connect Time")         new f = fopen(FILE, "r")         if(!f)         return console_print(id, "Couldn't open file")         new szLine[50], Data[DATA]     while(!feof(f))     {         fgets(f, szLine, charsmax(szLine))                 if(!szLine[0] || szLine[0] == ';' || szLine[0] != '[')             continue;                 replace(szLine, charsmax(szLine), "[", "")         replace(szLine, charsmax(szLine), "]", "")         replace(szLine, charsmax(szLine), "^n", "")                 copy(Data[STEAMID], charsmax(Data[STEAMID]), szLine)         // Here i should get the name and last connection time                 server_print("%d %-22.22s %-22.22s %s", ++i, Data[NAME], Data[STEAMID], Data[LAST_CONNECT])     }         fclose(f)         return PLUGIN_HANDLED }
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
 


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 13:25.


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