22.03.2012, 01:17
I've encountered a problem while chaging some stuff and i'm comfused : I need to ---->
When i login , I want the player to spawn at his last saved position :
When i spawn I want to go at the position show below : SetPlayerPos(playerid, 1176.6880,-1323.2609,14.0337); // CharacterPosOnDeath
And when i die I want to respawn atthe hostpital which is the same position as respawn.
Here what you'll need to have :
When i login , I want the player to spawn at his last saved position :
Код:
SetPlayerPos(playerid, PlayerInfo[playerid][X], PlayerInfo[playerid][Y], PlayerInfo[playerid][Z]); SetPlayerInterior(playerid, dini_Int(NameToFile(playerid), "LastInt"));
And when i die I want to respawn atthe hostpital which is the same position as respawn.
Here what you'll need to have :
Код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][Spawned] = 0;
PlayerInfo[playerid][Mute] = 0;
PlayerInfo[playerid][Login] = 1;
TogglePlayerSpectating(playerid, 1);
TextDrawShowForPlayer(playerid, t_Time);
for(new i=0; i<=4; i++)
TextDrawShowForPlayer(playerid, Welcome[i]);
SetTimer("ShowLogin", 5000, 0);
SetupPlayerMap(playerid);
PlayerInfo[playerid][IsShot] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(PlayerInfo[playerid][Logged] == 1)
{
GetPlayerPos(playerid, PlayerInfo[playerid][X], PlayerInfo[playerid][Y], PlayerInfo[playerid][Z]);
dini_FloatSet(NameToFile(playerid), "LastX", PlayerInfo[playerid][X]);
dini_FloatSet(NameToFile(playerid), "LastY", PlayerInfo[playerid][Y]);
dini_FloatSet(NameToFile(playerid), "LastZ", PlayerInfo[playerid][Z]);
dini_IntSet(NameToFile(playerid), "LastInt", GetPlayerInterior(playerid));
dini_IntSet(NameToFile(playerid), "ResetPosOnConnect", 1);
SavePlayerStats(playerid);
if(reason == 0)
dini_IntSet(NameToFile(playerid), "Mute", 0); //If player is muted and crashes. He shouldn't get the mute warning on next login.
}
TextDrawHideForPlayer(playerid, t_Time);
return 1;
}
/*SetPlayerPos(playerid, PlayerInfo[playerid][X], PlayerInfo[playerid][Y], PlayerInfo[playerid][Z]);
SetPlayerInterior(playerid, dini_Int(NameToFile(playerid), "LastInt"));*/
public OnPlayerSpawn(playerid)
{
PlayerInfo[playerid][gHP] = 100;
if(PlayerInfo[playerid][Logged] == 1)
//PlayerInfo[playerid][Spawned] = 1;
{
SetPlayerPos(playerid, 1176.6880,-1323.2609,14.0337); // CharacterPosOnDeath
}
else
{
SetPlayerPos(playerid, 1176.6880,-1323.2609,14.0337); // CharacterPosOnDeath
}
return 1;
}
#pragma unused GunObjects
public OnPlayerDeath(playerid, killerid, reason)
{
if(PlayerInfo[playerid][Logged] == 1)
{
SetPlayerPos(playerid, 1176.6880,-1323.2609,14.0337); // CharacterPosOnDeath
}
return 1;
}


!