[ Simple ] Deathpos / Diepos!

Started by SHy^, Jul 20, 2020, 03:22 PM

Previous topic - Next topic

SHy^

Hey guys. I'm here sharing a simple deathpos/diepos command made by me(beginner). Hope you all like it :D

[spoiler]
Class(Your main player class):
DP = false;

onScriptLoad:

deathpos <- array( GetMaxPlayers(), null );
onPlayerDeath:
if ( stats[ player.ID ].DP )
{
deathpos[ player.ID ] = player.Pos;
}
onPlayerSpawn:
if ( stats[ player.ID ].DP ) {
player.Pos = deathpos[ player.ID ];
PrivMessage( player, "You have been teleported to the place where you had last died.");
}
onPlayerCommand:
else if ( cmd == "deathpos" )
{
if (!text) PrivMessage( player, "Error: Wrong syntax, Use /"+cmd+" <on/off>.");
else
{
if ( text == "on" )
{
if ( stats[ player.ID ].DP ) PrivMessage( player, "Deathpos already enabled.");
else
{
stats[ player.ID ].DP = true;
MessagePlayer("Deathpos enabled.", player);
}
}
else if ( text == "off" )
{
if ( !stats[ player.ID ].DP ) PrivMessage( player, "You had not enabled deathpos.");
else
{
stats[ player.ID ].DP = false;
PrivMessage( player, "Deathpos has been turned off.");
}
}
}
}
[/spoiler]
Note: It won't save the deathpos details in database.I have used stats as an array for my default player class, you should change it according to your script. Before posting an error, confirm that all the indexes are there and you have pasted it correctly.
Hope someone finds it helpful!

Tested.