09.10.2013, 19:49
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;
}


