I just created my own registration system.. (but its not finished)
I was working with OnPlayerConnect, with Auto-Login + IP check Name check, and a check if a player is registered or not.
PHP код:
#include <a_samp>
#include <YSI\y_ini>
#include <dcmd>
#define FILTERSCRIPT
#define PATH "/Users/%s.ini"
#define COLOR_RED 0xFF0000AA
#define COLOR_ORANGE 0xFF9500AA
#define COLOR_YELLOW 0xFFFB00AA
#define COLOR_LIME 0x00FF15AA
enum pInfo
{
bool:pBanned,
pPass,
pLoggedIn,
pCash,
pAdminLvl,
pKills,
pDeaths,
pIP[16],
pColor,
pFS,
pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("LoggedIn",PlayerInfo[playerid][pLoggedIn]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("AdminLvl",PlayerInfo[playerid][pAdminLvl]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("IP",PlayerInfo[playerid][pIP]);
INI_Int("Color",PlayerInfo[playerid][pColor]);
INI_Int("FS",PlayerInfo[playerid][pFS]);
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
public OnFilterScriptInit()
{
print("<===> Registration loaded <===>");
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
new name[MAX_PLAYER_NAME], str[128], tmpip[16];
GetPlayerIp(playerid,tmpip,sizeof(tmpip));
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, sizeof(str), "LoadUser_%s", name);
new
FileIP[16],
INI:FileCheck = INI_Load(str);
INI_String(FileCheck, FileIP, sizeof(FileIP));
INI_Close(FileCheck);
if(!strcmp(FileCheck, tmp2, true))
{
SendClientMessage(playerid,COLOR_LIME,"Automatically Logged In.");
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else
{
SendClientMessage(playerid,COLOR_LIME,"Please use the /login command. We could not Automatially Log you in.");
}
else
{
SendClientMessage(playerid,COLOR_ORANGE,"You are not registered, please type /register <password> To register here.");
}
return 1;
}