18.03.2011, 11:18
Ok, i'v been working on the script, and now when people die they respawn where they died, but they just frozen and not in the animation, also when 20 seconds pass they spawn in front of hosptial. What im trying to do is When a player dies, they respawn where they died with 100 hp and stuck in an animation before being sent to hosptial. While in that animation they have a option to /accept death (to die and go to hosptial and wait 20seconds there, or do /service ems (Lets anybody in the LSPD faction know they are injured and need to be rescued.
This is my Script:
public OnPlayerDeath(playerid, killerid, reason)
{
GetPlayerPos(playerid, rX, rY, rZ);
Hspawn[playerid] = 1;
return 1;
}
public OnPlayerSpawn(playerid)
{
if (Hspawn[playerid] == 1)
{
SetPlayerPos(playerid, rX, rY, rZ);
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid, "BEACH", "bather", 0.1, 0, 1, 1, 1, 20000);
SetTimerEx("SpawnPlayerToHospital", 20000, false, "i", playerid);
}
return 1;
}
forward SpawnPlayerToHospital(playerid);
public SpawnPlayerToHospital(playerid)
{
Hspawn[playerid] = 0;
SetPlayerHealth(playerid, 100.5);
SendClientMessage(playerid,0xDD000096,"You Passed Out, and was rush to Los Santos hospital.");
SendClientMessage(playerid,0xFFFFFF96,"|-----------------------------------|");
SendClientMessage(playerid,0xDD000096,"Your medical bill cost: 100$");
GivePlayerMoney(playerid, -100);
SetPlayerPos(playerid,1176.6060,-1323.7875,14.0296);
TogglePlayerControllable(playerid, 1);
SetCameraBehindPlayer(playerid);
ClearAnimations(playerid);
}
This is my Script:
public OnPlayerDeath(playerid, killerid, reason)
{
GetPlayerPos(playerid, rX, rY, rZ);
Hspawn[playerid] = 1;
return 1;
}
public OnPlayerSpawn(playerid)
{
if (Hspawn[playerid] == 1)
{
SetPlayerPos(playerid, rX, rY, rZ);
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid, "BEACH", "bather", 0.1, 0, 1, 1, 1, 20000);
SetTimerEx("SpawnPlayerToHospital", 20000, false, "i", playerid);
}
return 1;
}
forward SpawnPlayerToHospital(playerid);
public SpawnPlayerToHospital(playerid)
{
Hspawn[playerid] = 0;
SetPlayerHealth(playerid, 100.5);
SendClientMessage(playerid,0xDD000096,"You Passed Out, and was rush to Los Santos hospital.");
SendClientMessage(playerid,0xFFFFFF96,"|-----------------------------------|");
SendClientMessage(playerid,0xDD000096,"Your medical bill cost: 100$");
GivePlayerMoney(playerid, -100);
SetPlayerPos(playerid,1176.6060,-1323.7875,14.0296);
TogglePlayerControllable(playerid, 1);
SetCameraBehindPlayer(playerid);
ClearAnimations(playerid);
}