PDA

View Full Version : /spawn doesn't load


kbalor
09/10/2013, 07:49 PM
HI guys I need your help. I have here spawn command which save/load spawn point. It works nice. But the problem after I get disconnect and reconnects again then in spawn it doesn't load the last time I used the command /spawn.. It was like its not triggering the save to load on player connect or on player spawn? what you think?

CMD:spawn(playerid,params[])
{
GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
GetPlayerFacingAngle( playerid, Angle[ playerid ] );
GetPlayerInterior (playerid);
GetPlayerVirtualWorld (playerid);
GameTextForPlayer(playerid,"~y~Spawn Point ~n~~g~Saved",2000,3);
return 1;
}

INI_WriteFloat( ACCOUNT, "PositionX", PosX[ playerid ] );
INI_WriteFloat( ACCOUNT, "PositionY", PosY[ playerid ] );
INI_WriteFloat( ACCOUNT, "PositionZ", PosZ[ playerid ] );
INI_WriteFloat( ACCOUNT, "Angle", Angle[ playerid ] );

public OnPlayerDisconnect(playerid, reason)
{

GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
GetPlayerFacingAngle( playerid, Angle[ playerid ] );


public OnPlayerSpawn(playerid)
{

if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
{
SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
SetPlayerFacingAngle( playerid, Angle[ playerid ] );
SetPlayerInterior( playerid, Interior[ playerid ] );
SetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
SetCameraBehindPlayer(playerid);
}
else
{
new Random = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
// set the position for those who has not saved
}
return 1;
}

xVIP3Rx
09/10/2013, 07:58 PM
First thing, check if the saving works, Go somewhere and type /spawn then check the Ini file,
if the coords are the same, Then the problem will be on the loading not the saving.

Konstantinos
09/10/2013, 08:02 PM
You get the coordinates when the player disconnects but do you save them in the file?

xVIP3Rx
09/10/2013, 08:05 PM
Deleted :\

kbalor
09/10/2013, 08:06 PM
You get the coordinates when the player disconnects but do you save them in the file?

Yes man it saves. I check the scriptfiles and I found this under my user.ini.

PositionX = -2244.840576
PositionY = 2293.785888
PositionZ = 4.969128
Angle = 136.209747

So basically it does saved the coordinates. So I wonder why it doesn't load. Thanks for the reply looking forward.


EDIT:

I think I missed something here? Yes I get the coordinates but

public LoginPlayer(playerid, name[], value[])
{
INI_Int("Level", pInfo[playerid][pLevel]);
INI_Int("Donator", pInfo[playerid][Donator]);
INI_Int("Banned", pInfo[playerid][Banned]);
INI_Int("Kills", pInfo[playerid][Kills]);
INI_Int("Deaths", pInfo[playerid][Deaths]);
INI_Int("Muted", pInfo[playerid][Muted]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Cash", pInfo[playerid][Cash]);
INI_Int("Skin", pInfo[playerid][Skin]);
INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
INI_Int("Wep0",pInfo[playerid][pWep0]);
INI_Int("Wep1",pInfo[playerid][pWep1]);
INI_Int("Wep2",pInfo[playerid][pWep2]);
INI_Int("Wep3",pInfo[playerid][pWep3]);
INI_Int("Wep4",pInfo[playerid][pWep4]);
INI_Int("Wep5",pInfo[playerid][pWep5]);
INI_Int("Wep6",pInfo[playerid][pWep6]);
INI_Int("Wep7",pInfo[playerid][pWep7]);
INI_Int("Wep8",pInfo[playerid][pWep8]);
INI_Int("Wep9",pInfo[playerid][pWep9]);
INI_Int("Wep10",pInfo[playerid][pWep10]);
INI_Int("Wep11",pInfo[playerid][pWep11]);
INI_Int("Wep12",pInfo[playerid][pWep12]);
INI_Int("Ammo0",pInfo[playerid][pAmmo0]);
INI_Int("Ammo1",pInfo[playerid][pAmmo1]);
INI_Int("Ammo2",pInfo[playerid][pAmmo2]);
INI_Int("Ammo3",pInfo[playerid][pAmmo3]);
INI_Int("Ammo4",pInfo[playerid][pAmmo4]);
INI_Int("Ammo5",pInfo[playerid][pAmmo5]);
INI_Int("Ammo6",pInfo[playerid][pAmmo6]);
INI_Int("Ammo7",pInfo[playerid][pAmmo7]);
INI_Int("Ammo8",pInfo[playerid][pAmmo8]);
INI_Int("Ammo9",pInfo[playerid][pAmmo9]);
INI_Int("Ammo10",pInfo[playerid][pAmmo10]);
INI_Int("Ammo11",pInfo[playerid][pAmmo11]);
INI_Int("Ammo12",pInfo[playerid][pAmmo12]);
INI_String("Color",pInfo[playerid][color],11);
return 1;
}

Can you please arrange this for me?

xVIP3Rx
09/10/2013, 08:07 PM
You get the coordinates when the player disconnects but do you save them in the file?

I think yes he did

INI_WriteFloat( ACCOUNT, "PositionX", PosX[ playerid ] );
INI_WriteFloat( ACCOUNT, "PositionY", PosY[ playerid ] );
INI_WriteFloat( ACCOUNT, "PositionZ", PosZ[ playerid ] );
INI_WriteFloat( ACCOUNT, "Angle", Angle[ playerid ] );

Konstantinos
09/10/2013, 08:14 PM
EDIT:

I think I missed something here?

public LoginPlayer(playerid, name[], value[])
{
INI_Int("Level", pInfo[playerid][pLevel]);
INI_Int("Donator", pInfo[playerid][Donator]);
INI_Int("Banned", pInfo[playerid][Banned]);
INI_Int("Kills", pInfo[playerid][Kills]);
INI_Int("Deaths", pInfo[playerid][Deaths]);
INI_Int("Muted", pInfo[playerid][Muted]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Cash", pInfo[playerid][Cash]);
INI_Int("Skin", pInfo[playerid][Skin]);
INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
INI_Int("Wep0",pInfo[playerid][pWep0]);
INI_Int("Wep1",pInfo[playerid][pWep1]);
INI_Int("Wep2",pInfo[playerid][pWep2]);
INI_Int("Wep3",pInfo[playerid][pWep3]);
INI_Int("Wep4",pInfo[playerid][pWep4]);
INI_Int("Wep5",pInfo[playerid][pWep5]);
INI_Int("Wep6",pInfo[playerid][pWep6]);
INI_Int("Wep7",pInfo[playerid][pWep7]);
INI_Int("Wep8",pInfo[playerid][pWep8]);
INI_Int("Wep9",pInfo[playerid][pWep9]);
INI_Int("Wep10",pInfo[playerid][pWep10]);
INI_Int("Wep11",pInfo[playerid][pWep11]);
INI_Int("Wep12",pInfo[playerid][pWep12]);
INI_Int("Ammo0",pInfo[playerid][pAmmo0]);
INI_Int("Ammo1",pInfo[playerid][pAmmo1]);
INI_Int("Ammo2",pInfo[playerid][pAmmo2]);
INI_Int("Ammo3",pInfo[playerid][pAmmo3]);
INI_Int("Ammo4",pInfo[playerid][pAmmo4]);
INI_Int("Ammo5",pInfo[playerid][pAmmo5]);
INI_Int("Ammo6",pInfo[playerid][pAmmo6]);
INI_Int("Ammo7",pInfo[playerid][pAmmo7]);
INI_Int("Ammo8",pInfo[playerid][pAmmo8]);
INI_Int("Ammo9",pInfo[playerid][pAmmo9]);
INI_Int("Ammo10",pInfo[playerid][pAmmo10]);
INI_Int("Ammo11",pInfo[playerid][pAmmo11]);
INI_Int("Ammo12",pInfo[playerid][pAmmo12]);
INI_String("Color",pInfo[playerid][color],11);
return 1;
}

You do not load the coordinates.


INI_Float( "PositionX", PosX[ playerid ] );
INI_Float( "PositionY", PosY[ playerid ] );
INI_Float( "PositionZ", PosZ[ playerid ] );
INI_Float( "Angle", Angle[ playerid ] );

xVIP3Rx
09/10/2013, 08:15 PM
You missed the loading of the positions..

public LoginPlayer(playerid, name[], value[])
{
INI_Int("Level", pInfo[playerid][pLevel]);
INI_Int("Donator", pInfo[playerid][Donator]);
INI_Int("Banned", pInfo[playerid][Banned]);
INI_Int("Kills", pInfo[playerid][Kills]);
INI_Int("Deaths", pInfo[playerid][Deaths]);
INI_Int("Muted", pInfo[playerid][Muted]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Cash", pInfo[playerid][Cash]);
INI_Int("Skin", pInfo[playerid][Skin]);
INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
INI_Int("Wep0",pInfo[playerid][pWep0]);
INI_Int("Wep1",pInfo[playerid][pWep1]);
INI_Int("Wep2",pInfo[playerid][pWep2]);
INI_Int("Wep3",pInfo[playerid][pWep3]);
INI_Int("Wep4",pInfo[playerid][pWep4]);
INI_Int("Wep5",pInfo[playerid][pWep5]);
INI_Int("Wep6",pInfo[playerid][pWep6]);
INI_Int("Wep7",pInfo[playerid][pWep7]);
INI_Int("Wep8",pInfo[playerid][pWep8]);
INI_Int("Wep9",pInfo[playerid][pWep9]);
INI_Int("Wep10",pInfo[playerid][pWep10]);
INI_Int("Wep11",pInfo[playerid][pWep11]);
INI_Int("Wep12",pInfo[playerid][pWep12]);
INI_Int("Ammo0",pInfo[playerid][pAmmo0]);
INI_Int("Ammo1",pInfo[playerid][pAmmo1]);
INI_Int("Ammo2",pInfo[playerid][pAmmo2]);
INI_Int("Ammo3",pInfo[playerid][pAmmo3]);
INI_Int("Ammo4",pInfo[playerid][pAmmo4]);
INI_Int("Ammo5",pInfo[playerid][pAmmo5]);
INI_Int("Ammo6",pInfo[playerid][pAmmo6]);
INI_Int("Ammo7",pInfo[playerid][pAmmo7]);
INI_Int("Ammo8",pInfo[playerid][pAmmo8]);
INI_Int("Ammo9",pInfo[playerid][pAmmo9]);
INI_Int("Ammo10",pInfo[playerid][pAmmo10]);
INI_Int("Ammo11",pInfo[playerid][pAmmo11]);
INI_Int("Ammo12",pInfo[playerid][pAmmo12]);
INI_String("Color",pInfo[playerid][color],11);
INI_Int("PositionX", PosX[playerid];
INI_Int("PositionY", PosY[playerid];
INI_Int("PositionZ", PosZ[playerid];
INI_Int("Angle", Angle[playerid]);
return 1;
}

kbalor
09/10/2013, 08:20 PM
You missed the loading of the positions..

public LoginPlayer(playerid, name[], value[])
{
INI_Int("Level", pInfo[playerid][pLevel]);
INI_Int("Donator", pInfo[playerid][Donator]);
INI_Int("Banned", pInfo[playerid][Banned]);
INI_Int("Kills", pInfo[playerid][Kills]);
INI_Int("Deaths", pInfo[playerid][Deaths]);
INI_Int("Muted", pInfo[playerid][Muted]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Cash", pInfo[playerid][Cash]);
INI_Int("Skin", pInfo[playerid][Skin]);
INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
INI_Int("Wep0",pInfo[playerid][pWep0]);
INI_Int("Wep1",pInfo[playerid][pWep1]);
INI_Int("Wep2",pInfo[playerid][pWep2]);
INI_Int("Wep3",pInfo[playerid][pWep3]);
INI_Int("Wep4",pInfo[playerid][pWep4]);
INI_Int("Wep5",pInfo[playerid][pWep5]);
INI_Int("Wep6",pInfo[playerid][pWep6]);
INI_Int("Wep7",pInfo[playerid][pWep7]);
INI_Int("Wep8",pInfo[playerid][pWep8]);
INI_Int("Wep9",pInfo[playerid][pWep9]);
INI_Int("Wep10",pInfo[playerid][pWep10]);
INI_Int("Wep11",pInfo[playerid][pWep11]);
INI_Int("Wep12",pInfo[playerid][pWep12]);
INI_Int("Ammo0",pInfo[playerid][pAmmo0]);
INI_Int("Ammo1",pInfo[playerid][pAmmo1]);
INI_Int("Ammo2",pInfo[playerid][pAmmo2]);
INI_Int("Ammo3",pInfo[playerid][pAmmo3]);
INI_Int("Ammo4",pInfo[playerid][pAmmo4]);
INI_Int("Ammo5",pInfo[playerid][pAmmo5]);
INI_Int("Ammo6",pInfo[playerid][pAmmo6]);
INI_Int("Ammo7",pInfo[playerid][pAmmo7]);
INI_Int("Ammo8",pInfo[playerid][pAmmo8]);
INI_Int("Ammo9",pInfo[playerid][pAmmo9]);
INI_Int("Ammo10",pInfo[playerid][pAmmo10]);
INI_Int("Ammo11",pInfo[playerid][pAmmo11]);
INI_Int("Ammo12",pInfo[playerid][pAmmo12]);
INI_String("Color",pInfo[playerid][color],11);
INI_Int("PositionX", PosX[playerid];
INI_Int("PositionY", PosY[playerid];
INI_Int("PositionZ", PosZ[playerid];
INI_Int("Angle", Angle[playerid]);
return 1;
}


The below warning was from what you added :D
error 017: undefined symbol "INI_Int"
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found ";"
error 017: undefined symbol "INI_Int"
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found ";"
error 017: undefined symbol "INI_Int"
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found ";"
warning 213: tag mismatch

EDIT: I've added ")" from each now the warning is only number of arguments does not match definition.

and maybe beause it was float? not int?

xVIP3Rx
09/10/2013, 08:23 PM
The below warning was from what you added :D
error 017: undefined symbol "INI_Int"
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found ";"
error 017: undefined symbol "INI_Int"
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found ";"
error 017: undefined symbol "INI_Int"
warning 202: number of arguments does not match definition
error 001: expected token: ",", but found ";"
warning 213: tag mismatch

EDIT: I've added ")" from each now the warning is only number of arguments does not match definition.

Oh my bad, Missed some ")"'s

INI_Int("PositionX", PosX[playerid]);
INI_Int("PositionY", PosY[playerid]);
INI_Int("PositionZ", PosZ[playerid]);
INI_Int("Angle", Angle[playerid]);


Edit:
Can you show us where did you add PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] ?

Konstantinos
09/10/2013, 08:25 PM
They're floats; therebefore it's INI_Float.

kbalor
09/10/2013, 08:26 PM
Oh my bad, Missed some ")"'s

INI_Int("PositionX", PosX[playerid]);
INI_Int("PositionY", PosY[playerid]);
INI_Int("PositionZ", PosZ[playerid]);
INI_Int("Angle", Angle[playerid]);


I have already added but warning 213: tag mismatch maybe because it was INIT_Writefloat not Int?

EDIT: INI_Float works :D


+Rep to all who helped me :D