AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [resolved] Parse/strbreak etc. (https://forums.alliedmods.net/showthread.php?t=45895)

stupok 10-14-2006 00:12

[resolved] Parse/strbreak etc.
 
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 :D :D.

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 :D

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 }

jim_yang 10-14-2006 01:54

Re: Parse/strbreak etc.
 
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.

stupok 10-14-2006 02:36

Re: Parse/strbreak etc.
 
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?

[ --<-@ ] Black Rose 10-14-2006 03:23

Re: Parse/strbreak etc.
 
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) }

organizedKaoS 10-14-2006 03:29

Re: Parse/strbreak etc.
 
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.

SweatyBanana 10-14-2006 09:46

Re: Parse/strbreak etc.
 
Are you releasing this plugins cause I like it :D


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.

stupok 10-14-2006 12:16

Re: Parse/strbreak etc.
 
I wasn't going to release the plugin, because I figured there are already ones like it, but maybe I will now :D

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:cry: .


All times are GMT -4. The time now is 04:52.

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