20.06.2014, 15:52
Hello!
I have a big problem with OnPlayerDeath. When I dead, it spawns me at 0.0, but, when I use /respawn, everything is ok.
There is the code:
OnPlayerDeath:
OnPlayerSpawn:
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?
ps: sorry if I have a bad English.
I have a big problem with OnPlayerDeath. When I dead, it spawns me at 0.0, but, when I use /respawn, everything is ok.
There is the code:
OnPlayerDeath:
Код:
public OnPlayerDeath(playerid, killerid, reason) { Death[playerid] = 1; new turfkiller, turfplayerid; for(new i = 1; i <= sizeof(TurfInfo); i++) { if(IsPlayerInTurf(playerid, i) == 1) { turfplayerid = i; break; } } for(new i = 1; i <= sizeof(TurfInfo); i++) { if(IsPlayerInTurf(killerid, i) == 1) { turfkiller = i; break; } } if(turfplayerid == turfkiller) { groupVariables[playerVariables[playerid][pGroup]][gScore] -= 1; playerVariables[playerid][pMoney] -= 150; playerVariables[playerid][pWarScore] -= 1; groupVariables[playerVariables[killerid][pGroup]][gScore] += 1; playerVariables[killerid][pMoney] += 150; playerVariables[killerid][pWarScore] += 1; } if(playerVariables[playerid][pHeadValue] > 0) { if(IsPlayerConnected(killerid)) { if(playerVariables[killerid][pGroup] == 12) { if(GoChase[killerid] == playerid) { new killer[MAX_PLAYER_NAME]; new string[256]; new name[MAX_PLAYER_NAME]; GetPlayerName(killerid, killer, sizeof(killer)); GetPlayerName(playerid, name, sizeof(name)); playerVariables[killerid][pMoney] += playerVariables[playerid][pHeadValue]; format(string,128,"Hitman %s has fulfilled the contract on %s and collected $%d.",killer,name,playerVariables[playerid][pHeadValue]); SendToGroup(12, COLOR_YELLOW, string); playerVariables[playerid][pHeadValue] = 0; GotHit[playerid] = 0; GetChased[playerid] = 999; GoChase[killerid] = 999; } } } } return 1; }
Код:
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; }
ps: sorry if I have a bad English.