SA-MP Forums Archive
Automaticly Login not working. :( - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Automaticly Login not working. :( (/showthread.php?tid=124050)



Automaticly Login not working. :( - `FuTuRe- - 28.01.2010

i am connecting to my server and it isn't logging me automaticly in. I hope anybody can help me with this.

pawn Код:
new tmp[50],tmp2[256]; GetPlayerIp(playerid,tmp,50); tmp2 = dini_Get(udb_encode(pInfo[playerid][name]),"IP");
  if(!strcmp(tmp,tmp2,false)) {
  SendClientMessage(playerid, ADMIN,"Welcome to Rofl The Poffle Server!");
  SendClientMessage(playerid, ADMIN,"To save your stats + progress use: /register password!");
  SendClientMessage(playerid, ADMIN,"Have fun playing!"); }
  else if(!strcmp(tmp,tmp2,true)) {
  SendClientMessage(playerid,oranje,"You have been automaticly logged in!");
    OnPlayerLogin(playerid); }
    return 1;



Re: Automaticly Login not working. :( - `FuTuRe- - 28.01.2010

Going to pay Ђ3,00 for first one who can help me fix this I need it badly


Re: Automaticly Login not working. :( - WackoX - 28.01.2010

How does your 'OnPlayerLogin(playerid)' look like?


Re: Automaticly Login not working. :( - ~Dangun! - 28.01.2010

pawn Код:
public OnPlayerLogin(playerid)
{
    new string[265];

    pInfo[playerid][logged] = 1;
    pInfo[playerid][money] = dini_Int(udb_encode(pInfo[playerid][name]), "money");
    pInfo[playerid][score] = dini_Int(udb_encode(pInfo[playerid][name]), "score");
    pInfo[playerid][level] = dini_Int(udb_encode(pInfo[playerid][name]), "level");
    pInfo[playerid][perfect] = dini_Int(udb_encode(pInfo[playerid][name]), "perfect");

  format(string, sizeof(string), "[SUCCES] You Are Now Logged In!");
    SendClientMessage(playerid,ADMIN,string);

    GivePlayerMoney(playerid,pInfo[playerid][money]);
  SetPlayerScore(playerid,pInfo[playerid][score]);
    return 1;
}



Re: Automaticly Login not working. :( - ~Dangun! - 29.01.2010

bump


Re: Automaticly Login not working. :( - ray187 - 29.01.2010

Your two if statements are wrong.

strcmp(const string1[], const string2[], bool:ignorecase, length)

-> you re first if statement returns true if the strings are the same with case sensitivity off
-> you re second if statement returns true if the strings are the same with case sensitivity on

Correct code is:

Код:
new tmp[50],tmp2[256]; GetPlayerIp(playerid,tmp,50); tmp2 = dini_Get(udb_encode(pInfo[playerid][name]),"IP");
  if(strcmp(tmp,tmp2,true)) {
  SendClientMessage(playerid, ADMIN,"Welcome to Rofl The Poffle Server!");
  SendClientMessage(playerid, ADMIN,"To save your stats + progress use: /register password!");
  SendClientMessage(playerid, ADMIN,"Have fun playing!"); }
  else if(!strcmp(tmp,tmp2,true)) {
  SendClientMessage(playerid,oranje,"You have been automaticly logged in!");
 	OnPlayerLogin(playerid); }
	return 1;
or better

Код:
new tmp[50],tmp2[256]; GetPlayerIp(playerid,tmp,50); tmp2 = dini_Get(udb_encode(pInfo[playerid][name]),"IP");
if(strcmp(tmp,tmp2,true)) {
	SendClientMessage(playerid, ADMIN,"Welcome to Rofl The Poffle Server!");
	SendClientMessage(playerid, ADMIN,"To save your stats + progress use: /register password!");
	SendClientMessage(playerid, ADMIN,"Have fun playing!"); }
else
{
	SendClientMessage(playerid,oranje,"You have been automaticly logged in!");
	OnPlayerLogin(playerid); 
}
return 1;
"NOW GIMME MY 3 EUROZZZ!!!" :P


Re: Automaticly Login not working. :( - ~Dangun! - 29.01.2010

will send you if it works correctly ^^


Re: Automaticly Login not working. :( - ray187 - 29.01.2010

Btw... don`t create strings with a length of 50 or 256... IPs have a max of 15 chars so create strings with 16.


Re: Automaticly Login not working. :( - ~Dangun! - 29.01.2010

Emmh, i just tryed it. When i join with a unregistered name. it logging me in also. but just data 0 and when i try to /register it will just say You are already logged in


Re: Automaticly Login not working. :( - pagie1111 - 29.01.2010

Quote:
Originally Posted by ray187
Btw... don`t create strings with a length of 50 or 256... IPs have a max of 15 chars so create strings with 16.
dini returns strings as 255


Re: Automaticly Login not working. :( - ray187 - 29.01.2010

What you`re doing with this code is that you compare the IP of the person connecting with the IP of whats stored at pInfo[playerid][name].

If they are not the same

Код:
if(strcmp(tmp,tmp2,true)) {
	SendClientMessage(playerid, ADMIN,"Welcome to Rofl The Poffle Server!");
	SendClientMessage(playerid, ADMIN,"To save your stats + progress use: /register password!");
	SendClientMessage(playerid, ADMIN,"Have fun playing!"); }
gets executed.

If they are the same

Код:
else
{
	SendClientMessage(playerid,oranje,"You have been automaticly logged in!");
	OnPlayerLogin(playerid); 
}
gets executed.

I don`t get your exact problem, what`s wrong?

Quote:
Originally Posted by {Awaran};
dini returns strings as 255
Sry then, I don`t work with dini (and thats like one top reason why :P).


Re: Automaticly Login not working. :( - ray187 - 29.01.2010

double post...


Re: Automaticly Login not working. :( - ~Dangun! - 29.01.2010

When i connect with the right username. And it's registered. It just load my stats. As i want to.

When i connect with a unregistered name. It's logging me in also. but the stats are just 0. When i try to /register it says i am logged in.

my onplayerregister
pawn Код:
public OnPlayerRegister(playerid)
{
    dini_IntSet(udb_encode(pInfo[playerid][name]), "money", pInfo[playerid][money]);
    dini_IntSet(udb_encode(pInfo[playerid][name]), "score", pInfo[playerid][score]);
    dini_IntSet(udb_encode(pInfo[playerid][name]), "level", 0);
    dini_IntSet(udb_encode(pInfo[playerid][name]), "perfect", 0);
    new IP[16];
    GetPlayerIp(playerid, IP, 16);
    dini_Set(udb_encode(pInfo[playerid][name]), "IP", IP);
}
And my onplayerlogin
pawn Код:
public OnPlayerLogin(playerid)
{
    new string[265];

    pInfo[playerid][logged] = 1;
    pInfo[playerid][money] = dini_Int(udb_encode(pInfo[playerid][name]), "money");
    pInfo[playerid][score] = dini_Int(udb_encode(pInfo[playerid][name]), "score");
    pInfo[playerid][level] = dini_Int(udb_encode(pInfo[playerid][name]), "level");
    pInfo[playerid][perfect] = dini_Int(udb_encode(pInfo[playerid][name]), "perfect");

  format(string, sizeof(string), "[SUCCES] You Are Now Logged In!");
    SendClientMessage(playerid,ADMIN,string);

  format(string, sizeof(string), "[STATS]Kills: %d Admin Level: %d V.I.P Member: %d Money: %d", pInfo[playerid][score], pInfo[playerid][level], pInfo[playerid][perfect], pInfo[playerid][money]);
    SendClientMessage(playerid,loginz,string);

    GivePlayerMoney(playerid,pInfo[playerid][money]);
  SetPlayerScore(playerid,pInfo[playerid][score]);
  return 1;
}



Re: Automaticly Login not working. :( - ray187 - 29.01.2010

I don`t know what dini_Get returns if it can`t find the respective line but try this then:

Код:
new tmp[50],tmp2[256]; GetPlayerIp(playerid,tmp,50); tmp2 = dini_Get(udb_encode(pInfo[playerid][name]),"IP");
if(strcmp(tmp,tmp2,true) || !strlen(tmp2)) {
	SendClientMessage(playerid, ADMIN,"Welcome to Rofl The Poffle Server!");
	SendClientMessage(playerid, ADMIN,"To save your stats + progress use: /register password!");
	SendClientMessage(playerid, ADMIN,"Have fun playing!"); }
else
{
	SendClientMessage(playerid,oranje,"You have been automaticly logged in!");
	OnPlayerLogin(playerid); 
}
return 1;



Re: Automaticly Login not working. :( - ~Dangun! - 29.01.2010

W000T it worked thank you very much. PM me your msn.


Re: Automaticly Login not working. :( - ray187 - 29.01.2010

Did you understand the problem as that`s probably more important than that it works now