Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Simple Death and Corpse System by Cs_Waller for the http://forum.sa-mp.com/ community.
- //Use the script however you like, just please, don't remove the credits on the top. I can't stop you, it's just a request
- #define FILTERSCRIPT
- #include <a_samp>
- #include <a_actor>
- //Corpse and death system
- new aspam[MAX_PLAYERS]; //prevents player from spamming /acceptdeath and bugging the hell out of the script.
- new dead[MAX_PLAYERS]; //Injured state of a player once he gets downed, pre /acceptdeath phase.
- new respawn[MAX_PLAYERS]; //Prevents people from speaking while being in the afterlife
- new timer69[MAX_PLAYERS]; //Countdown until a player leaves the afterlife stage and returns back to normal.
- new timer420[MAX_PLAYERS]; //Countdown to prevent a player from staying downed forever, forced afterlife stage.
- new Float:X, Float:Y, Float:Z, Float:A; //Storing the coordinates and angle when a player dies.
- new pskin; //The skin of the downed player is stored here.
- new interior; //The interior of the downed player is stored here.
- new Text3D:LabelID[MAX_PLAYERS]; //3d text label with the name of the player who died
- new actors[MAX_PLAYERS]; //actor spawned in the same position of the player who died.
- //Afterlife random heights to avoid many people in one place
- new Float:height[][] = {
- {0.0, 0.0, 42069.0},
- {0.0, 0.0, 6969.0},
- {0.0, 0.0, 4269.0},
- {0.0, 0.0, 1337.0},
- {0.0, 0.0, 69123.0},
- {0.0, 0.0, 42420.0},
- {0.0, 0.0, 69420.0},
- {0.0, 0.0, 66699.0},
- {0.0, 0.0, 42690.0},
- {0.0, 0.0, 1234.0},
- {0.0, 0.0, 5678.0},
- {0.0, 0.0, 6699.0},
- {0.0, 0.0, 4242.0},
- {0.0, 0.0, 42042.0},
- {0.0, 0.0, 42420.0}
- };
- //colors
- #define COLOR_BLUE 0xF0F8FFFF
- #define COLOR_RED 0xAA3333AA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_SPAWN 0xFF8C55FF
- #define COLOR_LIGHTBLUE 0x6DC5F3FF
- #define COLOR_ADMIN 0xFF0000FF
- #define COLOR_SAY 0x2986CEFF
- #define COLOR_SYSGREY 0xC6BEBDFF
- #define COLOR_BLACK 0x000000FF
- #define COLOR_JOIN 0x74E80099
- #define COLOR_WARN 0xBE615099
- #define COLOR_RACE 0x00BBBB99
- #define COLOR_KRED 0xFF0000FF
- //End
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n----------------------------------------------------------");
- print(" Simple Death and Corpse System has been loaded successfuly");
- print("----------------------------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("Simple death and Corpse System has been unloaded successfuly");
- return 1;
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- aspam[playerid] = 0; //Once a player connects, this is automatically set to 0 in case of any bugs.
- KillTimer(timer69[playerid]); //The timer for the afterlife phase is killed just to make sure.
- KillTimer(timer420[playerid]); //The timer for the auto death is killed just to makeke sure
- dead[playerid] = 0; //The player just connected to the server, no way for it to be anything else than 0.
- respawn[playerid] = 0; //Same like above.
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- aspam[playerid] = 0; //To prevent bugs this is set to 0 if the player leaves while being in the afterlife.
- KillTimer(timer69[playerid]); //The timer is killed so the filterscript won't continue using the timer if a player disconnects.
- KillTimer(timer420[playerid]); //Same as above.
- dead[playerid] = 0; //In case a player gets downed and quits the game, this is set to 0.
- respawn[playerid] = 0; //Same as above.
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- respawn[playerid] = 0; //After player spawns, be it from death or after joining the game, it's set to 0 so he can chat.
- aspam[playerid] = 0; //Turns off after a player spawns from the afterlife or joins the game, allows them to speak.
- KillTimer(timer69[playerid]); //Kills the timer as the player is no longer in the afterlife (or never was).
- if(dead[playerid] == 1) //Checks if the player is downed, if yes the script bellow starts.
- {
- dead[playerid] = 1; //Set to 1 just to make sure.
- SetPlayerInterior(playerid, interior); //Sets the interior where the player got downed.
- SetPlayerSkin(playerid, pskin); //Sets the same skin the player had from when he was downed.
- SetPlayerPos(playerid, X, Y, Z); //Sets the saved coordinates from when the player died.
- SetPlayerFacingAngle(playerid, A); //Sets the angle the player faced when he died.
- TogglePlayerControllable(playerid, 0); //Freezes the player so he can't use anything.
- ApplyAnimation(playerid,"PARACHUTE","FALL_skyDive_DIE", 4.0, 0, 0, 0, 1, 0); //Applies a downed animation for more realism.
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- dead[playerid] = 1; //Sets to 1 and makes the player enter the downed phase.
- timer420[playerid] = SetTimerEx("autodeath",60000,false,"i",playerid); //1 minute timer starts after the player dying to avoid any bugs, forced afterlife.
- GetPlayerSkin(pskin); //Saves the player's skin for the corpse actor and the player themself.
- GetPlayerInterior(interior); //Saves the player's interior in case he died in one
- GetPlayerFacingAngle(playerid, A);//Saves the player's angle so the actor could be used to it's full potential.
- GetPlayerPos(playerid, X, Y, Z); //Stores the player's coordinates to be used later when he spawns.
- SendClientMessage(playerid, COLOR_ORANGE, "You have been downed, accept your fate like a man."); //Message.
- SendClientMessage(playerid, COLOR_WHITE, "To accept death, type /acceptdeath in the chat."); //Message N2.
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(respawn[playerid] != 0) //If the player is waiting for the respawn and tries chatting, the message below is shown.
- {
- SendClientMessage(playerid, COLOR_SPAWN, "You are in the afterlife, you shall not speak unless spoken to!"); //Message
- return 0;
- }
- return 1;
- }
- //forwards
- forward autodeath(playerid); //Forwards the auto death script if a player refuses to accept their death.
- public autodeath(playerid) //The script is called if the player stays in the downed phase for over a minute.
- {
- switch (random(5)) //Points out how many random cases we have.
- {
- case 0: //The first case is picked randomly and the player in question gets the message below.
- {
- SendClientMessage(playerid, COLOR_RED, "Everything has it's end.");
- }
- case 1: //The second case is picked randomly and the player in question gets the message below.
- {
- SendClientMessage(playerid, COLOR_RED, "You have died and are to be send in the outer world");
- }
- case 2: //The third case is picked randomly and the player in question gets the message below.
- {
- SendClientMessage(playerid, COLOR_RED, "Your time has come.");
- }
- case 3: //The fourth case is picked randomly and the player in question gets the message below.
- {
- SendClientMessage(playerid, COLOR_RED, "You have been forced into the afterlife phase as your body bled out.");
- }
- case 4: //The fifth case is picked randomly and the player in question gets the message below.
- {
- SendClientMessage(playerid, COLOR_RED, "Your soul has left your body.");
- }
- }
- new rand = random(15);
- new skinning; //Stores the skin of the player before using the command.
- new name5[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME]; //Stores the name of the player.
- new Float:XD, Float:YD, Float:ZD, Float:Rotation; //X Y Z coordinates for the label and angel for the actor.
- GetPlayerPos(playerid, Float:XD, Float:YD, Float:ZD); //Stores the X Y Z coordinates and the angle for the actor.
- GetPlayerName(playerid, name5, sizeof(name5)); //Gets the name of the player.
- format(string, sizeof(string), "Corpse of %s.", name5); //String used for the 3Dtext on the corpse.
- LabelID[playerid] = Create3DTextLabel(string, COLOR_ORANGE,Float:XD, Float:YD, Float:ZD-0.5 , 10, 0, 0); //3D text showing the name of the player who died.
- aspam[playerid] = 1; //Activates the anti spam feature.
- respawn[playerid] = 1; //Actvates the anti talking feature.
- dead[playerid] = 0; //Removes the player from the downed state as he's no longer alive.
- SendClientMessage(playerid, COLOR_BLUE, "Your soul has been sucked out of you as you were laying motionlessly for over a minute"); //Message.
- SetPlayerHealth(playerid, 10); //Set's the player's health for the duration of the afterlife phase.
- SetPlayerPos(playerid,height[rand][0],height[rand][1],height[rand][2]); //Because 1337 is too mainstream ;p
- TogglePlayerControllable(playerid, 0); //Freezes the player as he's in the air.
- ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 1, 0, 1); //Applies the downed animation as the player is in the afterlife phase.
- timer69[playerid] = SetTimerEx("respawntimer", 30000, true, "f", playerid); //30 seconds timer starts.
- skinning = GetPlayerSkin(playerid); //Checks for the player's skin so the actor can have the same one.
- actors[playerid] = CreateActor(skinning, Float:X, Float:Y, Float:Z, Float:Rotation); //Spawning the actor itself.
- ApplyActorAnimation(actors[playerid], "WUZI", "CS_Dead_Guy", 4.1, 1, 0, 0, 1, 0); //Applying the animation to the actor.
- KillTimer(timer420[playerid]); //Kills the timer as the player accepted death
- return 1;
- }
- forward respawntimer(playerid); //Forwards the script below.
- public respawntimer(playerid) //The script is called once a player leaves the afterlife phase, deletes the 3D text labels, the corpse and respawns the player.
- {
- Delete3DTextLabel(LabelID[playerid]); //The 3D text is removed from the server once the player gets out of the afterlife phase.
- DestroyActor(actors[playerid]); //The corpse(actor) is removed from the server once the player gets out of the afterlife phase.
- respawn[playerid] = 0; //Allows the player to speak as he's no longer in the afterlife phase.
- SpawnPlayer(playerid); //Spawns the player. (Note: If changed to SetPlayerHealth(playerid, 0); the FS bugs out and the player is stuck in an endless cycle!)
- SetPlayerHealth(playerid, 100); //Spawns the player with his normal health as it was 10 in the afterlife phase.
- SendClientMessage(playerid, COLOR_RED, "Your soul has entered your body and you have been sent back on earth, enjoy your time here"); //Message to tell the player he's out of the afterlife phase.
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/kill", cmdtext, true, 10) == 0) //Used it to test the script, remove it if needed.
- {
- SetPlayerHealth(playerid, 0);
- return 1;
- }
- if (strcmp("/acceptdeath", cmdtext, true, 10) == 0) //The command itself.
- {
- if(dead[playerid] == 1) //Checks if the player is in downed state, prevents people from using the command if they are not downed.
- {
- new rand = random(15);
- new skinning; //Stores the skin of the player before using the command.
- new name5[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME]; //Stores the name of the player.
- new Float:XD, Float:YD, Float:ZD, Float:Rotation; //X Y Z coordinates for the label and angel for the actor.
- GetPlayerPos(playerid, Float:XD, Float:YD, Float:ZD); //Stores the X Y Z coordinates and the angle for the actor.
- GetPlayerName(playerid, name5, sizeof(name5)); //Gets the name of the player.
- format(string, sizeof(string), "Corpse of %s.", name5); //String used for the 3Dtext on the corpse.
- LabelID[playerid] = Create3DTextLabel(string, COLOR_ORANGE,Float:XD, Float:YD, Float:ZD-0.5 , 10, 0, 0); //3D text showing the name of the player who died.
- aspam[playerid] = 1; //Activates the anti spam feature.
- respawn[playerid] = 1; //Actvates the anti talking feature.
- dead[playerid] = 0; //Removes the player from the downed state as he's no longer alive.
- SendClientMessage(playerid, COLOR_BLUE, "You have accepted your death, now you shall wait 30 seconds as your soul comes back to your body"); //Message.
- SetPlayerHealth(playerid, 10); //Set's the player's health for the duration of the afterlife phase.
- SetPlayerPos(playerid,height[rand][0],height[rand][1],height[rand][2]); //Because 1337 is too mainstream ;p
- TogglePlayerControllable(playerid, 0); //Freezes the player as he's in the air.
- ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 1, 0, 1); //Applies the downed animation as the player is in the afterlife phase.
- timer69[playerid] = SetTimerEx("respawntimer", 30000, true, "f", playerid); //30 seconds timer starts.
- skinning = GetPlayerSkin(playerid); //Checks for the player's skin so the actor can have the same one.
- actors[playerid] = CreateActor(skinning, Float:X, Float:Y, Float:Z, Float:Rotation); //Spawning the actor itself.
- ApplyActorAnimation(actors[playerid], "WUZI", "CS_Dead_Guy", 4.1, 1, 0, 0, 1, 0); //Applying the animation to the actor.
- KillTimer(timer420[playerid]); //Kills the timer as the player accepted death
- return 1;
- }
- if(aspam[playerid] == 1) //If the player has already accepted death, he can't use the command again.
- {
- SendClientMessage(playerid, COLOR_WHITE, "Don't spam this, you have already accepted it!"); //Message.
- return 1;
- }
- else if(dead[playerid] == 0) //If the player is not downed, he can not use the command to accept death.
- {
- SendClientMessage(playerid, COLOR_RED, "You are not dead, don't try using this sacred command!"); //Message
- return 1;
- }
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement