Raised This Month: $ Target: $400
 0% 

read from file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 07-24-2008 , 19:06   read from file
Reply With Quote #1

how can i do something if some1's steam id is in the file it will do this action...like for example i want to put my steam id in file named lvl14.ini and i will be the only1 who will get access to something like this
Code:
if(steam id is in file or how ever its done)
{
do this
}
or even better like steam id and then numbers for example
Code:
steam_0:2382738927 14
steam_0:2382738927 15
steam_0:2382738927 16
steam_0:2382738927 17
and if its 14 it will do one if statement if its 15 it will do another if statement etc...
whosyourdaddy is offline
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 07-24-2008 , 22:39   Re: read from file
Reply With Quote #2

well i found this but can some1 help me make it do this... it reads not only the steam id but after it a number and if it as number 14 it will do

Code:
 
#define MAX_LEVELS               14


and etc.. for the other numbers... like make an if statement if possible?

Code:
#include <amxmodx>

#define MULTIPLE_USERS

#if defined MULTIPLE_USERS

#define MAX_USERS 100
#define USER_LIST_LOCATION "addons/amxmodx/configs/myuserlist.txt"

new userList[MAX_USERS][32];

public plugin_cfg()
{
    loadUsers();
}

loadUsers()
{
    new fileHandle = fopen(USER_LIST_LOCATION, "r");
    
    if(!fileHandle)
    {
        return;
    }
    
    new lineBuffer[64], userCount;
        
    while(!feof(fileHandle) && userCount < MAX_USERS)
    {
        fgets(fileHandle, lineBuffer, charsmax(lineBuffer));
        
        if(equal("STEAM_", lineBuffer, strlen("STEAM_")))
        {
            copyc(userList[userCount++], charsmax(userList[]), lineBuffer, ' ');
        }
    }

    fclose(fileHandle);
}

bool:hasAccess(userSteamID[])
{   
    for(new i; i < MAX_USERS; i++)
    {
        if(equal(userList[i], userSteamID))
        {
            return true;
        }
    }

    return false;
}

#else
    #define PRIVELEGED_USER "STEAM_0:0:17"
#endif

public plugin_init()
{
    register_clcmd("amx_mycommand", "myCommand");
}

public myCommand(id)
{
    new userSteamID[32];
    get_user_authid(id, userSteamID, charsmax(userSteamID));

#if defined MULTIPLE_USERS

    if(!hasAccess(userSteamID))
    {
        client_print(id, print_console, "You have no access to that command");
        return PLUGIN_HANDLED;
    }

#else

    if(!equal(userSteamID, PRIVELEGED_USER))
    {
        client_print(id, print_console, "You have no access to that command");
        return PLUGIN_HANDLED;
    }

#endif

    //command goes here
    
    return PLUGIN_HANDLED;
}
whosyourdaddy is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 07-25-2008 , 01:55   Re: read from file
Reply With Quote #3

not exaclty sure what your looking for but this might help
PHP Code:
new MAX_LEVEL 14
public plugin_int() {
     new 
filename[72]
     
get_configdir(filename,72);
     
format(filename,72,"%s/lvl14.ini",filename)
}
 
public function(
id) {
     new 
file fopen(filename,"rt")
     new 
steamid[32],parsedid[32],parsedlevel[32]
     
get_user_authid(id,steamid,31)
     if(
file_exists,filename)
     {
           if(
file)
          {
                new 
readdata[128]
                while(
fgets(file,readdata,127))
                {
                      
parse(readdata,parsedid,31,parsedlevel,31)
                      if(
contain(parsedid,steamid) != -&& contain(parsedlevel,MAX_LEVEL) != -1)
                     {
                          
//do somin
                     
}
                }
          }
     }

__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress

Last edited by scrtxxcaz; 07-25-2008 at 02:00.
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 07-25-2008 , 03:59   Re: read from file
Reply With Quote #4

looks pretty good but is there a way i can have my lvl14.ini look like this

Code:
steam_0:232972 14
steam_0:232972 15
where max_level = the numbers after the steam id for example on the first one 14 and on the second one 15
whosyourdaddy is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 07-25-2008 , 12:18   Re: read from file
Reply With Quote #5

yea just make the little change like below and when the players id is found their max_level in the file will be saved to MAX_LEVEL. hopefully thats what ur looking for.
PHP Code:
new MAX_LEVEL
public plugin_int() {
     new 
filename[72]
     
get_configdir(filename,72);
     
format(filename,72,"%s/lvl14.ini",filename)
}
 
public function(
id) {
     new 
file fopen(filename,"rt")
     new 
steamid[32],parsedid[32],parsedlevel[32]
     
get_user_authid(id,steamid,31)
     if(
file_exists,filename)
     {
           if(
file)
          {
                new 
readdata[128]
                while(
fgets(file,readdata,127))
                {
                      
parse(readdata,parsedid,31,parsedlevel,31)
                      if(
contain(parsedid,steamid) != -1)
                     {
                          
MAX_LEVEL str_to_num(parsedlevel)
                     }
                }
          }
     }

__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 07-25-2008 , 14:11   Re: read from file
Reply With Quote #6

wait would this work?

Code:
 
                      parse(readdata,parsedid,31,parsedlevel,31)
                      if(contain(parsedid,steamid) != -1)
                     {
                          MAX_LEVEL = str_to_num(parsedlevel)
                          if(MAX_LEVEL == 14)
                          {
                               (level 14 code)
                          }
                          if(MAX_LEVEL == 15)
                          {
                                (level 15 code and etc for other levels)
                          }
                     }
but what would i do if their steam id isnt in the .ini and i want it to do a code for those guys 2

Last edited by whosyourdaddy; 07-25-2008 at 19:33.
whosyourdaddy is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 07-26-2008 , 00:40   Re: read from file
Reply With Quote #7

yea but it would be better to do this...
PHP Code:
switch(MAX_LEVEL)
{
     case 
14:           //level 14
     
case 15:           // level 15
     
case 16:           // level 16
     //so on

__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 07-26-2008 , 04:41   Re: read from file
Reply With Quote #8

what if their steam id isnt in the file? how can i make it do something on them?
whosyourdaddy is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 07-28-2008 , 01:22   Re: read from file
Reply With Quote #9

PHP Code:
 parse(readdata,parsedid,31,parsedlevel,31)
 if(
contain(parsedid,steamid))
 {
       
MAX_LEVEL str_to_num(parsedlevel)
       switch(
MAX_LEVEL)
       {
              case 
14:           //level 14
              
case 15:           // level 15
              
case 16:           // level 16
              //so on
        
}
}
else
{
    
//steam id wasnt found so do this

or even
PHP Code:
if(!contain(parsedid,steamid))
{
     
//steam id not found do this

but using "else" would work to because if the steam id isnt found it will then execute the "else" lines
__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress

Last edited by scrtxxcaz; 07-28-2008 at 01:41.
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 07-29-2008 , 00:54   Re: read from file
Reply With Quote #10

ya im having problems is there a way you can make a .sma for me so i can copy and paste it because for some reason its not working correctly for me.. sorry for the trouble
whosyourdaddy 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 05:30.


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