13.12.2013, 20:41
I am trying to make a position loader script using Y_Ini but I am encountering a problem.
The commands to save the position is:
The command to load the position is:
And:
So when i type /teleport in game it teleports me to the position i had previously saved.
But when i save a new position and then type the /teleport command i teleport at the old saved position, and only when i restart the server it will teleport me to the position i saved.
I think i do something wrong with the ParseFile function?
I will appreciate any help.
The commands to save the position is:
pawn Код:
CMD:save(playerid,params[])
{
if(IsPlayerAdmin(playerid))
{
new name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
new Float: Pos[3];
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
new fileToWrite[] = "/Saving/apos.INI";
new INI:iniFile = INI_Open(fileToWrite);
INI_SetTag(iniFile, "AP1");
INI_WriteFloat(iniFile, "X", Pos[0]);
INI_WriteFloat(iniFile, "Y", Pos[1]);
INI_WriteFloat(iniFile, "Z", Pos[2]);
INI_WriteString(iniFile,"Name",name);
INI_WriteInt(iniFile, "Interior",GetPlayerInterior(playerid));
INI_Close(iniFile);
SendClientMessage(playerid,0,"You have changed the server's saved position number 1.");
}
else
{
SendClientMessage(playerid,0,"You can't do that!");
}
return 1;
}
pawn Код:
CMD:teleport(playerid)
{
INI_ParseFile("/Saving/apos.INI", "apos_%s", .bExtra = true, .extra = playerid);
SetPlayerInterior(playerid,pInt);
SetPlayerPos(playerid,pPosx[playerid],pPosy[playerid],pPosz[playerid]);
SendClientMessage(playerid,0,"You have been teleported to the server's saved position 1");
return 1;
}
pawn Код:
new Float: pPosy[MAX_PLAYERS], Float: pPosx[MAX_PLAYERS], Float: pPosz[MAX_PLAYERS];
new pInt;
new PlayerInfo[MAX_PLAYERS][pInfo];
new pName[50];
forward apos_AP1(playerid,name[], value[]);
public apos_AP1(playerid,name[], value[])
{
INI_Float("X", pPosx[playerid]);
INI_Float("Y", pPosy[playerid]);
INI_Float("Z", pPosz[playerid]);
INI_Int("Interior" , pInt);
INI_String("Name",pName,50);
return 1;
}
But when i save a new position and then type the /teleport command i teleport at the old saved position, and only when i restart the server it will teleport me to the position i saved.
I think i do something wrong with the ParseFile function?
I will appreciate any help.