Raised This Month: $ Target: $400
 0% 

[HELP] Reading arguments from file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 11-06-2009 , 15:32   [HELP] Reading arguments from file
Reply With Quote #1

PHP Code:
public OnPlayerLogin(id,password[])
{
    new 
string2[64]
    new 
playername2[50]
    
get_user_name(idplayername2sizeof(playername2))
    
format(string2sizeof(string2), "%s/users/%s.ini"configsdirplayername2)
    new 
UserFile fopen(string2"r")
    if ( 
UserFile )
    {
        new 
PassData[256]
        new 
keytmp[256], valtmp[256]
        
fgetsUserFile PassData sizeofPassData ) )
        
keytmp ini_GetKeyPassData )
        if( 
strcmpkeytmp "Key" true ) == )
        {
            
valtmp ini_GetValuePassData )
            
strcat(PlayerInfo[id][pKey], valtmp,strlen(valtmp)-1)
        }
        if(
strcmp(PlayerInfo[id][pKey],passwordtrue) == )
        {
            new 
key256 ] , val256 ]
            new 
Data256 ]
            while ( 
            
fgetsUserFile Data sizeofData ) ) )
            {
                
key ini_GetKeyData )
                new 
sve[256]
                new 
iznos strcat(svevalsizeof(sve))
                if( 
strcmpkey "Registerd" true ) == ) { val ini_GetValueData ); PlayerInfo[id][pReg] = iznos; }
                if( 
strcmpkey "Money" true ) == ) { val ini_GetValueData ); PlayerInfo[id][pMoney] = iznos; }
                if( 
strcmpkey "Kills" true ) == ) { val ini_GetValueData ); PlayerInfo[id][pKills] = iznos; }
                if( 
strcmpkey "Deaths" true ) == ) { val ini_GetValueData ); PlayerInfo[id][pDeaths] = iznos; }
                    
            }
            
fclose(UserFile)
        }
        else
        {
            
client_print(idprint_chat"SERVER: Password does not match your name.")
            
fclose(UserFile)
            new 
userid get_user_userid(id
            if(
gPlayerLogTries[id] == 4) { server_cmd("kick #%i ^"You typed wrong password 4 times!^"",userid); }
            return 
1

        
}
        
cs_set_user_money(id,PlayerInfo[id][pMoney])
        
cs_set_user_deaths(idPlayerInfo[id][pDeaths])
        
set_user_frags(idPlayerInfo[id][pKills])
        if(
PlayerInfo[id][pReg] == 0)
        {
            
PlayerInfo[id][pMoney] = 0
            PlayerInfo
[id][pKills] = 0
            PlayerInfo
[id][pDeaths] = 0
            PlayerInfo
[id][pReg] = 1
            cs_set_user_money
(id,5000)
        }
        
client_print(idprint_chat"=============================================")
        
client_print(idprint_chat"%s , welcome to server.",playername2)
        
client_print(idprint_chat"=============================================")
        
gPlayerLogged[id] = 1
        OnPlayerUpdate
(id)
    }
    return 
1

When I login for first time I got 5000$, then I buy something and I have eg. 3000$. On disconnect my Money, Deaths and Kills are saved and in my file it says Money=3000, then I login again it should give me 3000$ but it give me 5000$ like I am not registered.

My nickname.ini looks like:
PHP Code:
Key=password
Registerd
=1
Money
=5000
Kills
=0
Deaths
=
I need simple script that will compare password I typed and Key from nickname.ini and then if password=Key it will continue reading file and setting Money, Kills and Deaths from file...

My say handle:
PHP Code:
public cmdSay(id)
{
    new 
string[256]
    new 
sendername[50]
    new 
komanda[256]
    new 
text[200]
    
read_args(text,199)
    
remove_quotes(text)
    
read_argv(0komanda255)

    
strtok(textkomanda255text199' ')    
    if (
equali(komanda"/login"))
    {
        if(
is_user_connected(id))
        {
            new 
cmdtext[32]
            
strtok(textcmdtext31text199' ')
            new 
tmppass[64]
            if(
gPlayerLogged[id] == 1)
            {
                
client_print(idprint_chat"SERVER: You are already logged in.")
                return 
1
            
}
            if(!
strlen(cmdtext))
            {
                
client_print(idprint_chat"HELP: /login [password]")
                return 
1
            
}
            
strcat(tmppasscmdtextstrlen(cmdtext))
            
OnPlayerLogin(id,tmppass)
        }
        return 
1
    
}
    return 
1

AoD90 is offline
Send a message via MSN to AoD90
 



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 17:41.


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