suicide
#1

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?
Reply
#2

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);
Reply
#3

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 .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)