Need help with autologin -
~Dangun! - 04.01.2010
Hello, i need somehelp with creating autologin since i don't know how...
This is the pawn code
pawn Код:
#include <a_samp>
#include <dutils>
#include <dudb>
#include <dini>
#include <core>
#include <float>
////////////////////////////////////////////////////////////////////////////////
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
////////////////////////////////////////////////////////////////////////////////
forward UpdateStats();
forward OnPlayerRegister(playerid);
forward OnPlayerLogin(playerid);
////////////////////////////////////////////////////////////////////////////////
enum player_account_info
{
logged,
name[MAX_PLAYER_NAME],
money,
score,
perfect,
level,
}
new pInfo[MAX_PLAYERS][player_account_info];
new Kills[MAX_PLAYERS];
////////////////////////////////////////////////////////////////////////////////
public OnPlayerConnect(playerid)
{
pInfo[playerid][logged] = 0;
pInfo[playerid][level] = 0;
pInfo[playerid][money] = 0;
pInfo[playerid][score] = 0;
pInfo[playerid][perfect] = 0;
GetPlayerName(playerid,pInfo[playerid][name],128);
}
////////////////////////////////////////////////////////////////////////////////
public OnPlayerDisconnect(playerid, reason)
{
pInfo[playerid][logged] = 0;
pInfo[playerid][level] = 0;
pInfo[playerid][money] = 0;
pInfo[playerid][score] = 0;
pInfo[playerid][perfect] = 0;
}
////////////////////////////////////////////////////////////////////////////////
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(login,5,cmdtext);
dcmd(REGISTER,8,cmdtext);
////////////////////////////////////////////////////////////////////////////////
dcmd_login(playerid,params[])
{
new string[265];
new tmp[265];
if(pInfo[playerid][logged] == 1)return SendMsg(playerid, 5000, "~r~Information: ~w~You are already ~r~logged~w~ in!");
if(!strlen(params))return SendMsg(playerid, 5000, "~b~USAGE: ~w~/login [password]");
if (dini_Exists(udb_encode(pInfo[playerid][name])))
{
tmp = dini_Get(udb_encode(pInfo[playerid][name]), "password");
if (udb_hash(params) != strval(tmp))
{
SendMsg(playerid, 5000, "~r~Information: ~w~Wrong password!");
}
else
{
OnPlayerLogin(playerid);
}
}
else
{
format(string, sizeof(string), "The Account %s does not exist in our Database yet, use /register password to register it!", pInfo[playerid][name]);
SendMsg(playerid, 5000, string);
}
return 1;
}
dcmd_REGISTER(playerid,params[])
{
new string[128];
if(pInfo[playerid][logged] == 1)return SendMsg(playerid, 5000, "~r~Information: ~w~You are already logged in");
if(!strlen(params))return SendMsg(playerid, 5000, "~r~Information:~w~ Use /register password");
if (!dini_Exists(udb_encode(pInfo[playerid][name])))
{
format(string, sizeof(string), "The Account %s has been Succesfully registered! You have been automaticly logged in - Password: %s]", pInfo[playerid][name], params);
SendClientMessage(playerid, COLOR_NOTICE, string);
dini_Create(udb_encode(pInfo[playerid][name]));
dini_IntSet(udb_encode(pInfo[playerid][name]), "password", udb_hash(params));
OnPlayerRegister(playerid);
OnPlayerLogin(playerid);
}
else
{
format(string, sizeof(string), "~r~Information: ~w~%s is already registered!", pInfo[playerid][name]);
SendMsg(playerid, 5000, string);
}
return 1;
}
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), "~r~Information: ~w~your now logged in! [~r~Score: ~w~%d] [~r~Admin Level: ~w~%d] [~r~Premium Member:~w~ %d] [~r~Money: ~w~%d]", pInfo[playerid][score], pInfo[playerid][level], pInfo[playerid][perfect], pInfo[playerid][money]);
SendMsg(playerid, 5000, string);
GivePlayerMoney(playerid,pInfo[playerid][money]);
SetPlayerScore(playerid,pInfo[playerid][score]+GetPlayerScore(playerid));
}
////////////////////////////////////////////////////////////////////////////////
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);
}
////////////////////////////////////////////////////////////////////////////////
public UpdateStats()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
pInfo[i][money] = GetPlayerMoney(i);
pInfo[i][score] = GetPlayerScore(i);
if(pInfo[i][logged] == 1)
{
dini_IntSet(udb_encode(pInfo[i][name]), "perfect", pInfo[i][perfect]);
dini_IntSet(udb_encode(pInfo[i][name]), "money", pInfo[i][money]);
dini_IntSet(udb_encode(pInfo[i][name]), "score", pInfo[i][score]);
dini_IntSet(udb_encode(pInfo[i][name]), "level", pInfo[i][level]);
}
}
}
I already requested at Script Requesting Thread but no one responding ;( so i hope it works here.
Re: Need help with autologin -
Zamaroht - 04.01.2010
You will have to store his last used IP address somewhere, then when they connect check if it's the same IP address than the one they had stored. If it is, just login them.
Re: Need help with autologin -
`FuTuRe- - 04.01.2010
nvm.
Re: Need help with autologin -
~Dangun! - 04.01.2010
Can somebody do this for me? i am nab with this
Re: Need help with autologin -
Lajko1 - 04.01.2010
just put on Player Connect PlayerLogged or what ever u have there put on ''1''
Re: Need help with autologin -
Lajko1 - 04.01.2010
OnPlayerConnect
Код:
pInfo[playerid][logged] = 1;
and OnPlayerDisconect leave this
Код:
pInfo[playerid][logged] = 0;
not tested

u can try if i am right
Re: Need help with autologin -
~Dangun! - 04.01.2010
I think this will take his name.. so anyone would be able to join on his name. ;(
I hope somebody can make it for me because i don't understand poopy about it :O
To make it work on ip. If you can do this i will pay like Ђ3,00 through paypal.
Re: Need help with autologin -
GhoulSlayeR - 04.01.2010
It's not that hard, and surely isn't worth 3.00.
Код:
new ipaddress[16];
GetPlayerIp(playerid,ipaddress,sizeof(ipaddress));
Store & Compare, it's that simple.
Re: Need help with autologin -
[HiC]TheKiller - 04.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");
new IP[56];
GetPlayerIP(playerid, IP, 56);
dini_Set(udb_encode(pInfo[playerid][name]), "IP", IP);
format(string, sizeof(string), "~r~Information: ~w~your now logged in! [~r~Score: ~w~%d] [~r~Admin Level: ~w~%d] [~r~Premium Member:~w~ %d] [~r~Money: ~w~%d]", pInfo[playerid][score], pInfo[playerid][level], pInfo[playerid][perfect], pInfo[playerid][money]);
SendMsg(playerid, 5000, string);
GivePlayerMoney(playerid,pInfo[playerid][money]);
SetPlayerScore(playerid,pInfo[playerid][score]+GetPlayerScore(playerid));
}
And under OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
new IP[56];
GetPlayerIP(playerid, IP, 56);
if(strcmp(dini_Get(pInfo[playerid][name], "IP"), IP) OnPlayerLogin(playerid);
}
But yeah, don't pay people :P. Use my donate button if you want to rofl :P.
Re: Need help with autologin -
~Dangun! - 05.01.2010
Thanks for this.. but it is giving me a error ;(
Код:
(522) : error 017: undefined symbol "GetPlayerIP"
(523) : error 001: expected token: ")", but found "-identifier-"
(1549) : error 017: undefined symbol "GetPlayerIP"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.