02.01.2013, 17:14
Hello fellows,
I am creating my own GM, and I've stranded on OnPlayerDeath it's doing really weird.
I'do get the spawn button on death and when I press it I go to the hospital but I dont spawn? =(?
PS: Yes I took vx-rp2's onplayerdeath and stuff but I was going to use this as a base!
I am creating my own GM, and I've stranded on OnPlayerDeath it's doing really weird.
I'do get the spawn button on death and when I press it I go to the hospital but I dont spawn? =(?
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[playerid][pHospitalized] = 1;
return 1;
}
PHP код:
public OnPlayerSpawn(playerid)
{
SetPlayerColor(playerid, COLOR_WHITE);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon0], PlayerInfo[playerid][pAmmo0]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon1], PlayerInfo[playerid][pAmmo1]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]);
if(PlayerInfo[playerid][pHospitalized] >= 1)
return initiateHospital(playerid);
return 1;
}
PHP код:
public globalPlayerLoop() {
foreach(Player, x)
{
if(PlayerInfo[x][pHospitalized] >= 2) {
PlayerInfo[x][pHospitalized]++;
GetPlayerHealth(x, PlayerInfo[x][pHealth]);
SetPlayerHealth(x, PlayerInfo[x][pHealth]+7.5);
if(PlayerInfo[x][pHealth]+10 >= 100) {
SetPlayerHealth(x, 100);
PlayerInfo[x][pHospitalized] = 0;
switch(GetPVarInt(x, "hosp")) {
case 1: {
PlayerInfo[x][pLastX] = 1172.359985;
PlayerInfo[x][pLastY] = -1323.313110;
PlayerInfo[x][pLastZ] = 15.402919;
PlayerInfo[x][pHealth] = 75;
PlayerInfo[x][pArmour] = 0;
TogglePlayerControllable(x, 1);
PlayerInfo[x][pVW] = 0;
PlayerInfo[x][pInt] = 0;
SetSpawnInfo(x, 0, PlayerInfo[x][pSkin], 1172.359985, -1323.313110, 15.402919, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(x);
SendClientMessage(x, COLOR_LIGHTRED, "You have been released from Hospital.");
SendClientMessage(x, COLOR_LIGHTRED, "You have been charged $1,000 for your stay, and any weapons you had have been confiscated.");
PlayerInfo[x][pCash] -= 1000;
DeletePVar(x, "hosp");
TogglePlayerSpectating(x, 0);
}
case 2: {
PlayerInfo[x][pLastX] = 2034.196166;
PlayerInfo[x][pLastY] = -1402.591430;
PlayerInfo[x][pLastZ] = 17.295030;
PlayerInfo[x][pHealth] = 75;
TogglePlayerControllable(x, 1);
PlayerInfo[x][pArmour] = 0;
PlayerInfo[x][pVW] = 0;
PlayerInfo[x][pInt] = 0;
SetSpawnInfo(x, 0, PlayerInfo[x][pSkin], 2034.196166, -1402.591430, 17.295030, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(x);
SendClientMessage(x, COLOR_LIGHTRED, "You have been released from Hospital.");
SendClientMessage(x, COLOR_LIGHTRED, "You have been charged $1,000 for your stay, and any weapons you had have been confiscated.");
PlayerInfo[x][pCash] -= 1000;
SetPlayerPos(x, 2034.196166, -1402.591430, 17.295030);
DeletePVar(x, "hosp");
TogglePlayerSpectating(x, 0);
}
}
}
}
}
return 1;
}
PHP код:
stock initiateHospital(const playerid) {
TogglePlayerControllable(playerid, false);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
if(random(2) == 0) {
SetPlayerPos(playerid, 1188.4574,-1309.2242,10.5625);
SetPlayerCameraPos(playerid,1188.4574,-1309.2242,13.5625+6.0);
SetPlayerCameraLookAt(playerid,1175.5581,-1324.7922,18.1610);
SetPVarInt(playerid, "hosp", 1);
} else {
SetPlayerPos(playerid, 1999.5308,-1449.3281,10.5594);
SetPlayerCameraPos(playerid,1999.5308,-1449.3281,13.5594+6.0);
SetPlayerCameraLookAt(playerid,2036.2179,-1410.3223,17.1641);
SetPVarInt(playerid, "hosp", 2);
}
SendClientMessage(playerid, COLOR_LIGHTRED, "You must spend some time in the Hospital to recover from the injuries you recently sustained.");
SendClientMessage(playerid, COLOR_LIGHTRED, "Before you are discharged, hospital staff will confiscate your weapons and you will be billed for the health care you received.");
PlayerInfo[playerid][pHospitalized] = 2;
SetPlayerHealth(playerid, 10);
return 1;
}