Raised This Month: $ Target: $400
 0% 

[resolved] Parse/strbreak etc.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 10-14-2006 , 00:12   [resolved] Parse/strbreak etc.
Reply With Quote #1

I made a simple plugin that creates a log that looks like this:
(I removed the actual steamids)

My real log now has 742 unique users .

Code:
1	STEAM_0:1:11111		Ma$termind
2	STEAM_0:0:11111		hagen
3	STEAM_0:1:11111		The Federal Offender
4	STEAM_0:1:11111		Luis Rios
5	STEAM_0:1:11111		Zach' Triad' Bowman
6	STEAM_0:1:11111		Adolfus
7	STEAM_0:1:11111		sprayer
8	STEAM_0:1:11111		HABIB
9	STEAM_0:1:11111		Hellucard
10	STEAM_0:0:11111		Fillipeano
11	STEAM_0:0:11111		Jeff From accounting
12	STEAM_0:1:11111		jalop
13	STEAM_0:1:11111		nomel
However, I want to add a counter after the player's name, showing how many times the user has connected to my server. I've tried many variations of strbreak and parse, and I could not get the number to increase by 1 every time the user connected. It would just stay at 1.

Here's the code without the parse/strbreak or any variable to hold the number of times the user has connected. I'd like to know how to do this properly

Code:
    #include <amxmodx>     #include <amxmisc>     #include <file>     new szFile[32] = "addons/amxmodx/users_list.txt" public plugin_init() {     register_plugin("Steam n Nick Logger","1.0","stupok69") } public client_authorized(id) {     check_name(id)      return PLUGIN_CONTINUE } public check_name(id) {             new pAuth[33], pName[33], Len, szText[101]         get_user_authid(id, pAuth, 32)         if(containi(pAuth,"BOT") != -1)         return PLUGIN_CONTINUE         get_user_name(id, pName, 32)            for(new i=0;i<file_size(szFile, 1);i++)     {         format(szText, 20, "")         read_file(szFile, i, szText, 23, Len)             if (containi(szText, pAuth) != -1)         {             return PLUGIN_CONTINUE         }     }         format( szText , 100 , "%d  %s      %s",file_size(szFile, 1),pAuth,pName)     write_file(szFile, szText ,-1)     return PLUGIN_CONTINUE }

Last edited by stupok; 10-14-2006 at 12:23.
stupok is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 10-14-2006 , 01:54   Re: Parse/strbreak etc.
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #define FILENAME "users_list.txt" new szFile[32] public plugin_init() {         register_plugin("Steam n Nick Logger", "1.0", "stupok69")         new amxxdir[20]         get_basedir(amxxdir, 19)         format(szFile, 31, "%s/%s", amxxdir, FILENAME) } public client_authorized(id) {         check_name(id)         return PLUGIN_CONTINUE } public check_name(id) {         new pAuth[33], pName[33], Len, szText[101]         get_user_authid(id, pAuth, 32)         if(containi(pAuth,"BOT") != -1)                 return PLUGIN_CONTINUE         get_user_name(id, pName, 32)         new lines = file_size(szFile, 1)         new Index[5], Auth[33], Name[33], LogTimes[5]         new logtimes         for(new i=0; i<lines; i++) {                 read_file(szFile, i, szText, 100, Len)                 parse(szText, Index, 4, Auth, 32, Name, 32, LogTimes, 4)                 if(equali(pAuth, Auth)) {                         logtimes = str_to_num(LogTimes)                         format(szText, 100, "%s   %s    %s    %d", Index, Auth, Name, logtimes + 1)                         write_file(szFile, szText, i)                         return PLUGIN_CONTINUE                 }         }         format(szText, 100, "%d   %s   %s   %d", lines, pAuth, pName, 1)         write_file(szFile, szText)         return PLUGIN_CONTINUE }
i even don't compile it , it should work, if wrong ingore it.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>

Last edited by jim_yang; 10-14-2006 at 02:13.
jim_yang is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 10-14-2006 , 02:36   Re: Parse/strbreak etc.
Reply With Quote #3

Holy crap +karma it worked first try!

Maybe you can help me with a second, unrelated problem.

Code:
public whatever() {     for(new a = 1; a <= u; a++)     {         set_task(float(a) * 0.2, "kickzombiesfunction(bots[a])")     } } public kickzombiesfunction(bots[a]) {       new userid = get_user_userid(bots[a])     server_cmd("kick #%d",userid) }

How can I make the kickzombiesfunction() receive the bots[a] as the id?
stupok is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-14-2006 , 03:23   Re: Parse/strbreak etc.
Reply With Quote #4

Code:
public whatever() {     for(new a = 1; a <= u; a++)     {         set_task(float(a) * 0.2, "kickzombiesfunction", bots[a])     } } public kickzombiesfunction(id) {       new userid = get_user_userid(id)     server_cmd("kick #%d",userid) }

Last edited by [ --<-@ ] Black Rose; 10-14-2006 at 03:25.
[ --<-@ ] Black Rose is offline
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 10-14-2006 , 03:29   Re: Parse/strbreak etc.
Reply With Quote #5

Are you trying to kick all bots or just some?

If you are trying to kick all bots...this would be easier
Code:
server_cmd("bot_kick all")

Otherwise black rose's edit should work.
organizedKaoS is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 10-14-2006 , 09:46   Re: Parse/strbreak etc.
Reply With Quote #6

Are you releasing this plugins cause I like it


Im installing it on my server for sure..

Somehow yesterday, somebody with no admin that only registered anything in my logs when he actually did something was changing map (nobody has access to mapchange but me, and it wasnt thru rcon..) and pausint the server (yes of course pausable 0 was on...)

So this plugin would be great in situations like that.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
stupok
Veteran Member
Join Date: Feb 2006
Old 10-14-2006 , 12:16   Re: Parse/strbreak etc.
Reply With Quote #7

I wasn't going to release the plugin, because I figured there are already ones like it, but maybe I will now

Though, I will change it so that it records the last name used by the player instead of only the first name used.

I thought ULogger would be out by now .

Last edited by stupok; 10-14-2006 at 12:21.
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 04:52.


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