24.11.2014, 18:43
I've created a login/register/saving system in my GM using dfile, so this should save player position too.
This worked but when i've added a "first spawn" script i got a problem.
If is the first player spawn:
Servers sends a client message to the player and sets his first spawn trough "SetPlayerPos" function.
And this is fine.
--
But when the register player login for the second, third ecc. time, he gets this screen:
Which lines i've to post?
OnPlayerSpawn:
LoadPlayer Stock
SavePlayer Stock
I've created the variable pPrimoSpawn (means FirstSpawn in Italian language) in the enum of the playerinfo:
Where i've failed?
This worked but when i've added a "first spawn" script i got a problem.
If is the first player spawn:
Servers sends a client message to the player and sets his first spawn trough "SetPlayerPos" function.
And this is fine.
--
But when the register player login for the second, third ecc. time, he gets this screen:
Which lines i've to post?
OnPlayerSpawn:
Код:
public OnPlayerSpawn(playerid) { if(PlayerInfo[playerid][pPrimoSpawn] == 0) { PlayerInfo[playerid][pPrimoSpawn] = 1; SCM(playerid,COLOR_RED,"PRIMO ACCESSO, BENVENUTO"); SetPlayerPos(playerid,-1985.0490,138.4170,27.6875); } else { SCM(playerid,COLOR_RED,"BENTORNATO, NON E' IL TUO PRIMO ACCESSO"); } SetPlayerWeather(playerid, 1); return 1; }
Код:
stock LoadPlayer(playerid) { dfile_Open(PlayerFile(playerid)); dfile_MultiGet("iiiliiiffffiiff", "Livello", PlayerInfo[playerid][pLevel], "Livello_Admin", PlayerInfo[playerid][pAdminLevel], "Primo Spawn", PlayerInfo[playerid][pPrimoSpawn], "Conto Bancario", PlayerInfo[playerid][pContoBancario], "Exp", PlayerInfo[playerid][pExp], "Soldi", PlayerInfo[playerid][pMoney], "Skin", PlayerInfo[playerid][pSkin], "PosX", PlayerInfo[playerid][pPos][0], "PosY", PlayerInfo[playerid][pPos][1], "PosZ", PlayerInfo[playerid][pPos][2], "PosA", PlayerInfo[playerid][pPos][3], "Interior", PlayerInfo[playerid][pInterior], "Virtual_World", PlayerInfo[playerid][pWorld], "HP", PlayerInfo[playerid][pHP], "AP", PlayerInfo[playerid][pAP]); PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0); SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]); ResetPlayerMoney(playerid); SetPlayerMoney(playerid, PlayerInfo[playerid][pMoney]); SetPlayerHealth(playerid, PlayerInfo[playerid][pHP]); SetPlayerArmour(playerid, PlayerInfo[playerid][pAP]); SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]); SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pWorld]); return 1; }
Код:
stock SavePlayer(playerid) { GetPlayerPos(playerid, PlayerInfo[playerid][pPos][0], PlayerInfo[playerid][pPos][1], PlayerInfo[playerid][pPos][2]); GetPlayerAngle(playerid, PlayerInfo[playerid][pPos][3]); new Float:hp, Float:ap; GetPlayerHealth(playerid, hp); GetPlayerArmour(playerid, ap); if(hp > 100)PlayerInfo[playerid][pHP] = 100; if(ap > 100)PlayerInfo[playerid][pAP] = 100; dfile_Open(PlayerFile(playerid)); dfile_MultiSet("iiiliiiffffiiff", "Livello", PlayerInfo[playerid][pLevel], "Livello Admin", PlayerInfo[playerid][pAdminLevel], "Primo Spawn", PlayerInfo[playerid][pPrimoSpawn], "Conto Bancario", PlayerInfo[playerid][pContoBancario], "Exp", PlayerInfo[playerid][pExp], "Soldi", PlayerInfo[playerid][pMoney], "Skin", PlayerInfo[playerid][pSkin], "PosX", PlayerInfo[playerid][pPos][0], "PosY", PlayerInfo[playerid][pPos][1], "PosZ", PlayerInfo[playerid][pPos][2], "PosA", PlayerInfo[playerid][pPos][3], "Interior", PlayerInfo[playerid][pInterior], "Virtual_World", PlayerInfo[playerid][pWorld], "HP", PlayerInfo[playerid][pHP], "AP", PlayerInfo[playerid][pAP]); dfile_SaveFile(); dfile_CloseFile(); return 1; }
Код:
enum playerenum { pPass[MAX_LENGHT_PASS], pLevel, pAdminLevel, pPrimoSpawn, bool:pContoBancario, pExp, pMoney, pSkin, Float:pPos[4], pInterior, pWorld, Float:pHP, Float:pAP, pIP[16], bool:pBanned, pBannedReason[MAX_BAN_REASON], pLoginAttempts, bool:pLogged };
Where i've failed?