24.05.2014, 14:14
I just created a new script, with player coordinate saving system (for spawning to proper place when relogging).
But when the player connects, he is spawned - but he is frozen, can't move or control the camera. (I've tried using 'TogglePlayerControllable(playerid, 1) - but it won't help)
Here are the only callbacks I have edited:
The saving system DOES work, the coordinates are properly saved into the file, the only problem is that the player is frozen upon spawning.
(here are the saving system related lines though, if it helps)
But when the player connects, he is spawned - but he is frozen, can't move or control the camera. (I've tried using 'TogglePlayerControllable(playerid, 1) - but it won't help)
Here are the only callbacks I have edited:
pawn Код:
public OnGameModeInit()
{
SetGameModeText("Blank Script");
//AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
/...
public OnPlayerRequestClass(playerid, classid)
{
/*
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);*/
return 1;
}
/...
public OnPlayerConnect(playerid)
{
if(fexist(GetUserPath(playerid)))
{
INI_ParseFile(GetUserPath(playerid), "LoadPlayer_%s", .bExtra = true, .extra = playerid);
SetSpawnInfo(playerid, 0, 0, PlayerData[playerid][posX], PlayerData[playerid][posY], PlayerData[playerid][posZ], 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
if(!fexist(GetUserPath(playerid)))
{
new INI:File = INI_Open(GetUserPath(playerid));
INI_SetTag(File, "Player data");
INI_WriteFloat(File, "PlayerPosX", 0.0);
INI_WriteFloat(File, "PlayerPosY", 0.0);
INI_WriteFloat(File, "PlayerPosZ", 0.0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.342773, 1337.705932 ,16.008468, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SavePlayerData(playerid);
return 1;
}
(here are the saving system related lines though, if it helps)
pawn Код:
#define USERS_PATH "/Users/%s.ini"
/...
enum pDataEnum
{
Float:posX,
Float:posY,
Float:posZ
}
new PlayerData[MAX_PLAYERS][pDataEnum];
stock GetUserPath(playerid)
{
new contentString[126], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(contentString, sizeof(contentString), USERS_PATH, pName);
return contentString;
}
forward LoadPlayer_data(playerid, name[], value[]);
public LoadPlayer_data(playerid, name[], value[])
{
INI_Float("PlayerPosX", PlayerData[playerid][posX]);
INI_Float("PlayerPosY", PlayerData[playerid][posY]);
INI_Float("PlayerPosZ", PlayerData[playerid][posZ]);
return 1;
}
forward SavePlayerData(playerid);
public SavePlayerData(playerid)
{
GetPlayerPos(playerid, PlayerData[playerid][posX], PlayerData[playerid][posY], PlayerData[playerid][posZ]);
new INI:File = INI_Open(GetUserPath(playerid));
INI_SetTag(File, "Player data");
INI_WriteFloat(File, "PlayerPosX", PlayerData[playerid][posX]);
INI_WriteFloat(File, "PlayerPosY", PlayerData[playerid][posY]);
INI_WriteFloat(File, "PlayerPosZ", PlayerData[playerid][posZ]);
INI_Close(File);
return 1;
}