suicide - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: suicide (
/showthread.php?tid=270308)
suicide -
cruising - 19.07.2011
is there any way to disable suicide so you cant kill your self with ex: RPG, heatsink, grenades, molotow? but be able if you sitting in a vehicle?
Re: suicide -
=WoR=Varth - 20.07.2011
Maybe you can use "OnPlayerDeath" function.
pawn Код:
new Suicide[MAX_PLAYERS];
public OnPlayerDeath(playerid,killerid,reason);
{
if(playerid == killerid)
{
new Float:Pos[3];
Suicide[playerid] = true;
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
SetSpawnInfo(playerid, team, skin,Pos[0],Pos[1],Pos[2], Float:rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
public OnPlayerSpawn(playerid)
{
if(Suicide[playerid] == true)
{
Suicide[playerid] = false;
SpawnPlayer(playerid);
Re: suicide -
[HiC]TheKiller - 20.07.2011
varthshenon, there is a few issues with that code snippet.
1. If you got killed normally, it would spawn at the same position as you killed yourself last time. Just make it so it sets the players position on spawn.
2. Using SpawnPlayer on OnPlayerSpawn is just silly.
3. You didn't close any of the callbacks or add any returns in them
4. When you kill yourself, the KillerID is INVALID_PLAYER_ID, not your ID.
5. That code makes it so you can kill yourself but re-spawn at the same position.
To answer the topic, you would have to detect if the player was the one shooting the gun, if so, set his health to maximum again. Search around for functions that do these things, there are plenty of them
.