AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Authid.ini (https://forums.alliedmods.net/showthread.php?t=20381)

Kensai 11-07-2005 14:04

Authid.ini
 
I need to know how to retrieve a users authid, and write it to the specified .ini file.

Then I need to know how to open the file and check to see if a player's ID has a match, then go to a function.

v3x 11-07-2005 14:43

Try this:
Code:
#include <amxmodx> #include <amxmisc> new g_szCfgsDir[64]; new g_szFile[] = "authid.ini"; public plugin_init() {   // ...   get_configsdir(g_szCfgsDir, 63); } public WriteIt( id ) {   new szAuthID[33];   get_user_authid(id, szAuthID, 32);   new szFileStr[64];   format(szFileStr, 63, "%s/%s", g_szCfgsDir, g_szFile);   new szText[64]   format(szText, 63, "^n^"%s^"", szAuthID);   if(file_exists(szFileStr))   {     write_file(szFileStr, szText, -1);     console_print(id, "Added %s", szAuthID);   }   else   {     log_amx("File not found: %s", szFileStr);   }   return PLUGIN_HANDLED; } public client_putinserver( id ) {   get_configsdir(g_szCfgsDir, 63);       new szFileStr[64];   format(szFileStr, 63, "%s/%s", g_szCfgsDir, g_szFile);   if(file_exists(szFileStr))   {     new szAuthID[64];     get_user_authid(id, szAuthID, 63);         new szText[164];     new nLen=0, nLine=0;     while(read_file(szFileStr, nLine++, szText, 163, nLen))     {       if(szText[0] == ';') continue;               remove_quotes(szText);       new szUserName[33];       get_user_name(id, szUserName, 32);       if(equali(szAuthID,szText))       {         FoundID(id);         server_print("Found positive match for %s", szAuthID);       }       else       {         server_print("No match for %s", szAuthID);       }     }   }   else   {     log_amx("File not found: %s", szFileStr);   } } public FoundID( id ) {   // Hooray! We found it! }

Kensai 11-07-2005 18:38

Sweet, thanks.

Now if I wanted to make a HUD message for a player. How can I check to see if their Steam ID is in the .ini

And I don't want it to, like log steam ids.

v3x 11-07-2005 20:19

A pre-defined HUD message in the file?

Kensai 11-07-2005 20:50

This is what I have, without your code.

I would like it to do this.

I'll make a command, or you could, and it let's admins add steam ids to the .ini And another cvar will control whether the hud displays for EVERYONE or just the people on the "list"

But I don't know how to write a steam id to the file with a command, and show the HUD to only those people.


Code:
#include <amxmodx> #include <amxmisc> #include <csstats> #define HUD_INTERVAL 1.0 new msgtext public plugin_init() {     register_plugin("Stats Display","1.0","Kensai")     msgtext = get_user_msgid("StatusText") } public client_putinserver(id) {       set_task(HUD_INTERVAL,"ShowHUD",id); }   public ShowHUD(id)     {       if(!is_user_connected(id))         return 0;     new stats[8]     new hits[8]     get_user_stats(id,stats,hits)     new name[33]     get_user_name(id,name,32)     new HUD[51]     format(HUD, 50, "%s [Kills: %i] [Deaths: %i] [Headshots: %i]",name,stats[0],stats[1],stats[2])     message_begin(MSG_ONE, msgtext, {0,0,0}, id)       write_byte(0)       write_string(HUD)       message_end()       set_task(HUD_INTERVAL,"ShowHUD",id);     return PLUGIN_CONTINUE }

[C]oN -X- 11-07-2005 21:15

bah
 
bah CS hack coding is so much easier...

there its just tmp say "blah blah blah %d"

and so on.. coded hacks half my cs palying.. now i stopped cuz hacking got gay :-] :wink:

Striker 11-13-2005 07:18

hello,

I edited the plugin like this:

Code:
#include <amxmodx> #include <amxmisc> new g_szCfgsDir[64]; new g_szFile[] = "authid.ini"; public plugin_init(){     register_plugin("Plugin Name","0.1","Author")     get_configsdir(g_szCfgsDir, 63); } public WriteIt( id ){     new szAuthID[33];     get_user_authid(id, szAuthID, 32);     new szFileStr[64];     format(szFileStr, 63, "%s/%s", g_szCfgsDir, g_szFile);     new szText[64]     format(szText, 63, "^n^"%s^"", szAuthID);     if(file_exists(szFileStr)){         write_file(szFileStr, szText, -1);         console_print(id, "Added %s", szAuthID);     }else{         log_amx("File not found: %s", szFileStr);     }     return PLUGIN_HANDLED; } public client_putinserver( id ){     get_configsdir(g_szCfgsDir, 63);           new szFileStr[64];     format(szFileStr, 63, "%s/%s", g_szCfgsDir, g_szFile);     if(file_exists(szFileStr)){         new szAuthID[64];         get_user_authid(id, szAuthID, 63);               new szText[164];         new nLen=0, nLine=0;         while(read_file(szFileStr, nLine++, szText, 163, nLen)) {             if(szText[0] == ';') continue;                       remove_quotes(szText);             new szUserName[33];             get_user_name(id, szUserName, 32);             if(equali(szAuthID,szText)){                 server_print("Found positive match for %s", szAuthID);             }else{                 server_print("No match for %s, creating one", szAuthID);                 client_cmd(id, "resetattribs")                 client_cmd(id, "resetresists")                 set_task(5.0, "WriteIt", id)             }         }     }else{         log_amx("File not found: %s", szFileStr);     } }

But it doesn't work.

Can someone help me please ?

Kensai 11-13-2005 09:36

I gave up using the .ini file for this. Too many issues, and wasn't working at all. Might wanna try having something other then writing steam ids in that.

XxAvalanchexX 11-13-2005 13:01

What's wrong with using a .ini file?

Code:
#define FILENAME "addons/amxmodx/data/authids.ini"  public write_authid(id) {     if(check_authid(id)) return 0;     new authid[32];     get_user_authid(id,authid,31);     return write_file(FILENAME,authid);  }  public check_authid(id) {     new authid[32];     get_user_authid(id,authid,31);     new line, text[32], txtLen;     while((line = read_file(FILENAME,line,text,31,txtLen)) != 0) {         if(equali(authid,text)) return 1;     }     return 0;  }

Kensai 11-13-2005 13:36

There's nothing really wrong with using a .ini Just doesn't really work for what I was trying to do.

Someone wanted my Stats Display plugin to have a .ini So only people with their Stema ID's in the file could have the HUD Display. I thought that kind of defeated the purpose.

Thanks for the help anyways.


All times are GMT -4. The time now is 23:44.

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