13.11.2013, 21:45
Quote:
When you register it doesn't say "Server closed the connection" only when you try to spawn?
|
I changed Publics,OnPlayerConnection OnPlayerRegister and OnPlayerUpdateEx
EXAMPES:
From
pawn Code:
public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new string3[64];
new string[128];
new playersip[24];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
GetPlayerIp(playerid, playersip, sizeof(playersip));
format(string3, sizeof(string3), "LARP/Users/%s.ini", playername3);
dini_Create(string3);
new password2 = num_hash(password);
PlayerInfo[playerid][pKey] = password2;
dini_IntSet(string3, "Password",password2);
dini_IntSet(string3, "Level",PlayerInfo[playerid][pLevel]);
dini_IntSet(string3, "Spawn",PlayerInfo[playerid][pSpawn]);
ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_INPUT,"Welcome, Please Log-In","Account Successfuly Registred into the database!\nType your password below to log-in","Log-in","Quit");
new y,m,d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d) [%d:%d:%d] %s Has registred in under IP %s.",d,m,y,h,mi,s,playername3,playersip);
PlayerInfo[playerid][pReg] = 0;
LoginLog(string);
}
return 1;
}
pawn Code:
public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new string3[64];
new string[128];
new playername3[MAX_PLAYER_NAME];
new playersip[24];
GetPlayerName(playerid, playername3, sizeof(playername3));
GetPlayerIp(playerid, playersip, sizeof(playersip));
format(string3, sizeof(string3), "LARP/Users/%s.ini", playername3);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
new var[176];
format(var, 128, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
format(var, 128, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 128, "Spawn=%d\n",PlayerInfo[playerid][pSpawn]);fwrite(hFile, var);
fclose(hFile);
ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_PASSWORD,"Welcome, Please Log-In","Account Successfuly Registered into the database!\nType your password below to log-in","Log-in","Quit");
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has registered under IP %s.",d,m,y,h,mi,s,playername3,playersip);
LoginLog(string);
}
}
return 1;
}
pawn Code:
public OnPlayerLogin(playerid,password[])
{
new tmp2[256]
new string2[64];
new string[128];
new playername2[MAX_PLAYER_NAME];
new playersip[24];
SetRealName(playerid);
GetPlayerName(playerid, playername2, sizeof(playername2));
GetPlayerIp(playerid, playersip, sizeof(playersip));
format(string2, sizeof(string2), "LARP/Users/%s.ini", playername2);
if (dini_Exists(string2))
{
new password2 = num_hash(password);
if(dini_Int(string2,"Password") == password2)
{
PlayerInfo[playerid][pKey] = dini_Int(string2,"Password");
PlayerInfo[playerid][pLevel] = dini_Int(string2,"Level");
PlayerInfo[playerid][pSpawn] = dini_Int(string2,"Spawn");
etc,etc
Its long code
pawn Code:
public OnPlayerLogin(playerid,password[])
{
new tmp2[256];
new string2[64];
new string[128];
new playersip[24];
new playername2[MAX_PLAYER_NAME];
new playernamesplit[3][MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
GetPlayerIp(playerid, playersip, sizeof(playersip));
split(playername2, playernamesplit, '_');
format(string2, sizeof(string2), "LARP/Users/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
if( strcmp( key , "Spawn" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSpawn] = strval( val ); }