Automaticly Login not working. :(
#1

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;
Reply
#2

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

How does your 'OnPlayerLogin(playerid)' look like?
Reply
#4

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;
}
Reply
#5

bump
Reply
#6

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
Reply
#7

will send you if it works correctly ^^
Reply
#8

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

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
Reply
#10

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
Reply
#11

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).
Reply
#12

double post...
Reply
#13

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;
}
Reply
#14

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;
Reply
#15

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

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


Forum Jump:


Users browsing this thread: 4 Guest(s)