[SOLVED]Login System (Dini) -
Mike_Peterson - 10.10.2010
Me, my friend and another scripter are making a roleplay server from scratch and I'm making the auto login system.. but i get something wierd...
I tried to go under my friend's name and i get auto logged in.. and i made that theres a check fi the players ip is same as in his userfile the player logs in automatically.. and my ip isnt same as him..
Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
new ip[50];
new tmp2[256];
tmp2 = dini_Get(file,"IP-Adress");
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"SF-RP/%s.ini",name);
new namestring = strfind(name, "_", true);
if(namestring == -1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "[System] This server only allows Firstname_Lastname");
Kick(playerid);
return 1;
}
if(!fexist(file))
{
IsRegistered[playerid] = 0;
SCM(playerid,COLOR_YELLOW,"[System]You have not registered, please /register");
SetSpawnInfo(playerid,0,26,-1969.3481,117.7218,27.6875,359,0,0,0,0,0,0);
return 1;
}
if(dini_Exists(file))
{
GetPlayerIp(playerid,ip,50);
if( (!strcmp(ip,tmp2)))
SetSpawnInfo(playerid,0,PlayerInfo[playerid][Skin],PlayerInfo[playerid][playerX],PlayerInfo[playerid][playerY],PlayerInfo[playerid][playerZ],0,0,0,0,0,0,0);
SCM(playerid,COLOR_GREEN,"[System]You have been automatically logged in, Welcome back!");
IsLogged[playerid] = 1;
SpawnPlayer(playerid);
return 1;
}
else if((!strcmp(ip,!tmp2)) && (dini_Exists(file)))
{
SCM(playerid,COLOR_YELLOW,"[System] You have to login to your account, please /login");
IsLogged[playerid] = 0;
return 0;
}
return 1;
}
Please help me A.S.A.P.
Re: Login System (Dini) -
[HiC]TheKiller - 10.10.2010
Make sure the tmp2 and ip both actually are values and not just blank strings.
Re: Login System (Dini) -
Mike_Peterson - 11.10.2010
tmp2 stands for dini_Get(file,Ip-Adress);
and ip i used in getplayerip.. so yeah..
bump
Re: Login System (Dini) -
JamesC - 11.10.2010
You are trying to get the IP from the file without first formatting the 'file' variable with the actual name of the file.
Put tmp2 = ... after format(file ...
Re: Login System (Dini) -
LarzI - 11.10.2010
You never added a bracket after the strcmp check, and you should use strmid to assign the value of tmp2 to the ip
pawn Код:
strmid(tmp2, ip, 0, 255);
Re: Login System (Dini) -
Mike_Peterson - 11.10.2010
Its fixed, figured it out myself with a lil help from TheKiller
and @ James
Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
new ip[50];
new tmp2[256];
tmp2 = dini_Get(file,"IP-Adress");
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"SF-RP/%s.ini",name);
See that on top? and
@ LarzI
I always have no idea when u comment something xD
The problem was strcmp, i did !strcmp(ip,!tmp2 this will actually do: ip false tmp2 true now i deleted both ! !
becoz strcmp returns 0 and it works