PHP Code:
public OnPlayerLogin(id,password[])
{
new string2[64]
new playername2[50]
get_user_name(id, playername2, sizeof(playername2))
format(string2, sizeof(string2), "%s/users/%s.ini", configsdir, playername2)
new UserFile = fopen(string2, "r")
if ( UserFile )
{
new PassData[256]
new keytmp[256], valtmp[256]
fgets( UserFile , PassData , sizeof( PassData ) )
keytmp = ini_GetKey( PassData )
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData )
strcat(PlayerInfo[id][pKey], valtmp,strlen(valtmp)-1)
}
if(strcmp(PlayerInfo[id][pKey],password, true) == 0 )
{
new key[ 256 ] , val[ 256 ]
new Data[ 256 ]
while (
fgets( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data )
new sve[256]
new iznos = strcat(sve, val, sizeof(sve))
if( strcmp( key , "Registerd" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[id][pReg] = iznos; }
if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[id][pMoney] = iznos; }
if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[id][pKills] = iznos; }
if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[id][pDeaths] = iznos; }
}
fclose(UserFile)
}
else
{
client_print(id, print_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(id, PlayerInfo[id][pDeaths])
set_user_frags(id, PlayerInfo[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(id, print_chat, "=============================================")
client_print(id, print_chat, "%s , welcome to server.",playername2)
client_print(id, print_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=0
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(0, komanda, 255)
strtok(text, komanda, 255, text, 199, ' ')
if (equali(komanda, "/login"))
{
if(is_user_connected(id))
{
new cmdtext[32]
strtok(text, cmdtext, 31, text, 199, ' ')
new tmppass[64]
if(gPlayerLogged[id] == 1)
{
client_print(id, print_chat, "SERVER: You are already logged in.")
return 1
}
if(!strlen(cmdtext))
{
client_print(id, print_chat, "HELP: /login [password]")
return 1
}
strcat(tmppass, cmdtext, strlen(cmdtext))
OnPlayerLogin(id,tmppass)
}
return 1
}
return 1
}