Sometimes when i logged into game, server kill me, i don't know the reason.
I need to Mention, when i try to loggin into server, all my variables goes to 0, regardless my saving system is ok.
And my skin are changed at CJ.
Or sometimes when i connect in game, server kick me before logging.
I use system which block arrows on connect, because i don't like that, i dont use class for that, i used toggleplayerspectate..
Here is the code:
I need to Mention, when i try to loggin into server, all my variables goes to 0, regardless my saving system is ok.
And my skin are changed at CJ.
Or sometimes when i connect in game, server kick me before logging.
I use system which block arrows on connect, because i don't like that, i dont use class for that, i used toggleplayerspectate..
Here is the code:
PHP Code:
forward CreateSpawnInfo(playerid);
public CreateSpawnInfo(playerid)
{
new rand = random(sizeof(SpawnRandom));
PlayerInfo[playerid][pPos_x] = SpawnRandom[rand][0];
PlayerInfo[playerid][pPos_y] = SpawnRandom[rand][1];
PlayerInfo[playerid][pPos_z] = SpawnRandom[rand][2];
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pChar], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 270, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnPlayerConnect(playerid)
{
TogglePlayerSpectating(playerid, true);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_SPAWNED)
{
PlayerInfo[playerid][pHealth] = 50.0;
SafeSetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]); // Set player health to 50
}
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(gPlayerLogged[playerid] == true)
{
CreateSpawnInfo(playerid);
SpawnPlayer(playerid);
}
else return false;
return true;
}
public OnPlayerRequestSpawn(playerid)
{
if(gPlayerLogged[playerid] == true)
{
CreateSpawnInfo(playerid);
SpawnPlayer(playerid);
}
else return false;
return true;
}
Dialog(Login)
{
new query[100], hashpass[129], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(!strcmp(hashpass, PlayerInfo[playerid][pPass]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `Players` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
Login[playerid] = 1;
}
else
{
gPlayerLogTries[playerid] += 1;
ShowPlayerDialog(playerid, 888, DIALOG_STYLE_PASSWORD, "Try Again, please Loggin", "{800000}Password {FFFFFF}which you type is incorrect.\nType your {800000}password {FFFFFF}in fields bellow.", "Login", "Quit");
if(gPlayerLogTries[playerid] == 3) { Kick(playerid); gPlayerLogTries[playerid] = 0; printf("6");}
}
return 1;
}
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
PlayerInfo[playerid][pLevel] = cache_get_field_content_int(0, "Level");
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin");
PlayerInfo[playerid][pMoney] = cache_get_field_content_int(0, "Money");
PlayerInfo[playerid][pPos_x] = cache_get_field_content_float(0, "Pos_x");
PlayerInfo[playerid][pPos_y] = cache_get_field_content_float(0, "Pos_y");
PlayerInfo[playerid][pPos_z] = cache_get_field_content_float(0, "Pos_z");
PlayerInfo[playerid][pChar] = cache_get_field_content_int(0, "Char");
PlayerInfo[playerid][pHealth] = cache_get_field_content_float(0, "Health");
TogglePlayerSpectating(playerid, false);
gPlayerLogged[playerid] = true;
CreateSpawnInfo(playerid);
SpawnPlayer(playerid);
//Here i don't use SafeSetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]); because not work
return 1;
}