I have a big problem with OnPlayerDeath. When I dead, it spawns me at 0.0, but, when I use /respawn, everything is ok.
Код:
public OnPlayerSpawn(playerid) {
#if defined DEBUG
printf("[debug] OnPlayerSpawn(%d)", playerid);
#endif
if(Death[playerid] == 1)
{
OnPlayerSpawn(playerid);
Death[playerid] = 0;
}
TextDrawHideForPlayer(playerid, DMV2[playerid]);
TextDrawHideForPlayer(playerid, DMV1[playerid]);
Weapon[playerid] = 0;
SetPlayerArmour(playerid, 0);
PreloadAnimLib(playerid,"BOMBER");
PreloadAnimLib(playerid,"RAPPING");
PreloadAnimLib(playerid,"SHOP");
PreloadAnimLib(playerid,"BEACH");
PreloadAnimLib(playerid,"SMOKING");
PreloadAnimLib(playerid,"ON_LOOKERS");
PreloadAnimLib(playerid,"DEALER");
PreloadAnimLib(playerid,"CRACK");
PreloadAnimLib(playerid,"CARRY");
PreloadAnimLib(playerid,"COP_AMBIENT");
PreloadAnimLib(playerid,"PARK");
PreloadAnimLib(playerid,"INT_HOUSE");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"GANGS");
PreloadAnimLib(playerid,"PED");
PreloadAnimLib(playerid,"FAT");
TogglePlayerSpectating(playerid, 0);
TextDrawHideForPlayer(playerid, cutie0 );
TextDrawHideForPlayer(playerid, login32 );
TextDrawHideForPlayer(playerid, login33 );
TextDrawHideForPlayer(playerid, login34 );
TextDrawHideForPlayer(playerid, login35 );
playerVariables[playerid][pWeapons][0] = 0;
playerVariables[playerid][pWeapons][1] = 0;
playerVariables[playerid][pWeapons][2] = 0;
playerVariables[playerid][pWeapons][3] = 0;
playerVariables[playerid][pWeapons][4] = 0;
playerVariables[playerid][pWeapons][5] = 0;
playerVariables[playerid][pWeapons][6] = 0;
playerVariables[playerid][pWeapons][7] = 0;
playerVariables[playerid][pWeapons][8] = 0;
playerVariables[playerid][pWeapons][9] = 0;
playerVariables[playerid][pWeapons][10] = 0;
playerVariables[playerid][pWeapons][11] = 0;
playerVariables[playerid][pWeapons][12] = 0;
//SendClientMessage(playerid, COLOR_LIGHTRED, "You have been released from Hospital.");
//SendClientMessage(playerid, COLOR_LIGHTRED, "You have been charged $1,000 for your stay, and any weapons you had have been confiscated.");
//playerVariables[playerid][pMoney] -= 1000;
SetPlayerColor(playerid, COLOR_WHITE);
SetPlayerFightingStyle(playerid, playerVariables[playerid][pFightStyle]);
SetPlayerToTeamColor(playerid);
HUndercover[playerid] = 0;
if(playerVariables[playerid][pPrisonTime] >= 1)
{
switch(playerVariables[playerid][pPrisonID])
{
case 1:
{
ResetPlayerWeapons(playerid);
SetPlayerPos(playerid, -26.8721, 2320.9290, 24.3034);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
}
case 2:
{
ResetPlayerWeapons(playerid);
SetPlayerPos(playerid, 264.58, 77.38, 1001.04);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, 0);
}
case 3:
{
ResetPlayerWeapons(playerid);
SetPlayerInterior(playerid, 10);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+1);
new spawn = random(sizeof(JailSpawns));
SetPlayerPos(playerid, JailSpawns[spawn][0], JailSpawns[spawn][1], JailSpawns[spawn][2]);
SetPlayerFacingAngle(playerid, 0);
}
}
return 1;
}
new rand;
if(PlayerPaintballing[playerid] != 0)
{
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 999);
rand = random(sizeof(PaintballSpawns));
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 10);
SetPlayerPos(playerid, PaintballSpawns[rand][0], PaintballSpawns[rand][1], PaintballSpawns[rand][2]);
return 1;
}
if(playerVariables[playerid][pSpawnChange] == 1)
{
new houseID = getPlayerHouseID(playerid);
new houserented = playerVariables[playerid][pHouseRented];
if(houseID >= 1)
{
SetPlayerInterior(playerid, houseVariables[houseID][hHouseInteriorID]);
SetPlayerVirtualWorld(playerid, HOUSE_VIRTUAL_WORLD+houseID);
SetPlayerPos(playerid, houseVariables[houseID][hHouseInteriorPos][0], houseVariables[houseID][hHouseInteriorPos][1], houseVariables[houseID][hHouseInteriorPos][2]);
InHouse[playerid] = houseID;
}
else
{
if(houserented >= 1)
{
SetPlayerInterior(playerid, houseVariables[houserented][hHouseInteriorID]);
SetPlayerVirtualWorld(playerid, HOUSE_VIRTUAL_WORLD+houserented);
SetPlayerPos(playerid, houseVariables[houserented][hHouseInteriorPos][0], houseVariables[houserented][hHouseInteriorPos][1], houseVariables[houserented][hHouseInteriorPos][2]);
InHouse[playerid] = houserented;
}
else
{
playerVariables[playerid][pSpawnChange] = 0;
}
}
}
if(playerVariables[playerid][pSpawnChange] == 0)
{
if(playerVariables[playerid][pGroup] == 0)
{
SetPlayerSkin(playerid, playerVariables[playerid][pSkin]);
SetPlayerPos(playerid, 1798.9375,-1863.1282,13.5755);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
InHQ[playerid] = 0;
}
if(playerVariables[playerid][pGroup] == 1)
{
SetPlayerPos(playerid, groupVariables[1][gGroupInteriorPos][0], groupVariables[1][gGroupInteriorPos][1], groupVariables[1][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+1);
InHQ[playerid] = 1;
}
if(playerVariables[playerid][pGroup] == 2)
{
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+2);
SetPlayerInterior(playerid, 10);
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
InHQ[playerid] = 2;
}
if(playerVariables[playerid][pGroup] == 3)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+3);
InHQ[playerid] = 3;
}
if(playerVariables[playerid][pGroup] == 4)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+4);
InHQ[playerid] = 4;
}
if(playerVariables[playerid][pGroup] == 5)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+5);
InHQ[playerid] = 5;
}
if(playerVariables[playerid][pGroup] == 6)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 2);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+6);
InHQ[playerid] = 6;
}
if(playerVariables[playerid][pGroup] == 7)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 2);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+7);
InHQ[playerid] = 7;
}
if(playerVariables[playerid][pGroup] == 8)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 2);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+8);
InHQ[playerid] = 8;
}
if(playerVariables[playerid][pGroup] == 9)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 2);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+9);
InHQ[playerid] = 9;
}
if(playerVariables[playerid][pGroup] == 10)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 2);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+10);
InHQ[playerid] = 10;
}
if(playerVariables[playerid][pGroup] == 11)
{
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 2);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+11);
InHQ[playerid] = 11;
}
if(playerVariables[playerid][pGroup] == 12)
{
SetPlayerColor(playerid,COLOR_HITMAN);
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+12);
InHQ[playerid] = 12;
}
if(playerVariables[playerid][pGroup] == 13)
{
SetPlayerColor(playerid,COLOR_SI);
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+13);
InHQ[playerid] = 13;
}
if(playerVariables[playerid][pGroup] == 14)
{
SetPlayerColor(playerid,COLOR_YELLOW);
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 18);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+14);
InHQ[playerid] = 14;
}
if(playerVariables[playerid][pGroup] == 15)
{
SetPlayerColor(playerid,COLOR_NEWS);
SetPlayerPos(playerid, groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][0], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][1], groupVariables[playerVariables[playerid][pGroup]][gGroupInteriorPos][2]);
SetPlayerInterior(playerid, 3);
SetPlayerVirtualWorld(playerid, GROUP_VIRTUAL_WORLD+15);
InHQ[playerid] = 15;
}
}
SetPlayerSkin(playerid, playerVariables[playerid][pSkin]);
SetCameraBehindPlayer(playerid);
ResetPlayerWeapons(playerid);
givePlayerWeapons(playerid);
SetPlayerHealth(playerid, 100);
SetPlayerWeather(playerid, 1);
syncPlayerTime(playerid);
TogglePlayerControllable(playerid, true);
return 1;
}
I tried to fix this problem with "Death" variable. I set the variable to 1 when the player death, and check this thing at OnPlayerSpawn. It didn't work properly. Any ideas?
OnPlayerSpawn only set player pos that you set on SetSpawnInfo.
So if you haven't set it, you can simply use SetPlayerPos player last position while player spawn (OnPlayerSpawn)
Try this.