Respawn Hospital Problem ! -
Mikeydoo - 22.03.2012
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 :
Код:
SetPlayerPos(playerid, PlayerInfo[playerid][X], PlayerInfo[playerid][Y], PlayerInfo[playerid][Z]);
SetPlayerInterior(playerid, dini_Int(NameToFile(playerid), "LastInt"));
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 :
Код:
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;
}
Re: Respawn Hospital Problem ! -
antonio112 - 22.03.2012
pawn Код:
public OnPlayerSpawn(playerid)
{
PlayerInfo[playerid][gHP] = 100;
if(PlayerInfo[playerid][Logged] == 1)
{
if(GetPVarInt(playerid, "Died") > 0)
{
DeletePVar(playerid, "Died");
SetPlayerPos(playerid, 1176.6880,-1323.2609,14.0337); // CharacterPosOnDeath
}
else SetPlayerPos(playerid, // Coordinates where you want them to spawn if they didn't die. When they logged in.
}
return 1;
}
#pragma unused GunObjects
public OnPlayerDeath(playerid, killerid, reason)
{
if(PlayerInfo[playerid][Logged] == 1)
SetPVarInt(playerid, "Died", 1);
return 1;
}
What I did, was setting a player variable, when player died, so the script knows that the player died and now, when he spawns, checking if he died. If yes, they'll spawn him at some coords and if they didn't die but spawned, spawn them at other coords.
About the spawn after login problem, we need to see
ShowLogin function.
Re: Respawn Hospital Problem ! -
Mikeydoo - 22.03.2012
Thanks a lot buddy ! Really precise and clear

!