Death system not working & Randomly dying
#1

First Issue

It's showing the "Spawn" button with the arrows when a player dies, but I don't want it too. What's the issue?

I've tried with
pawn Код:
TogglePlayerSpectating(playerid, true);
and with it false, but nothing's working. Here's the system.

pawn Код:
new string[128], weapon[24];
    GetWeaponName(reason, weapon, sizeof(weapon));
   
    JustDied[playerid] = true;
    ResetPlayerWeapons(playerid);
    SaveWeapons(playerid);
   
    SetPlayerHealth(playerid, 100);
    TogglePlayerControllable(playerid, false);
   
    Player[playerid][TotalDeaths] ++;

    if(killerid != INVALID_PLAYER_ID)
    {
        format(string, sizeof(string), "AdmWrn: %s has been killed by %s. (%s)", RemoveUnderScore(playerid), RemoveUnderScore(killerid), weapon);
        Player[killerid][TotalKills] ++;
        SaveLog(GetName(playerid), "OnPlayerDeath", string);
        JustDied[playerid] = true;
    }
    else
    {
        format(string, sizeof(string), "AdmWrn: %s has been killed.", RemoveUnderScore(playerid));
        SaveLog(GetName(playerid), "OnPlayerDeath", string);
        JustDied[playerid] = true;
    }
    AdminMessage(1, RED, string);
   
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 0);
    TogglePlayerControllable(playerid, false);
    return 1;
Here is OnPlayerSpawn:

pawn Код:
public OnPlayerSpawn(playerid)
{
    new string[128];
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 0);
    if(JustDied[playerid] == true)
    {
        new bill = Player[playerid][Level] * 75 + Player[playerid][Level] + random(100), dn[24], nra = random(4);
     
        Player[playerid][Money] -= bill;
       
        SetTimerEx("ReleaseTimer", 25000, false, "i", playerid);
   
        Hospitalized[playerid] = true;
   
        Player[playerid][Health] = 100;
        Player[playerid][Armour] = 0;
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 0);
       
        SetPlayerPos(playerid, -317.8539,1060.5267,19.7422);
        SetPlayerFacingAngle(playerid, 321.2364);
        SetPlayerCameraPos(playerid, -305.4138,1075.1143,24.3368);
        SetPlayerCameraLookAt(playerid, -323.5710,1052.5018,20.3403);
       
        SetPlayerHealth(playerid, 100);
        SetPlayerSkin(playerid, Player[playerid][Skin]);
        SetPlayerArmedWeapon(playerid, 0);
        for(new i = 0; i < 10; i++)
            SetPlayerSkillLevel(playerid, i, Player[playerid][WeaponSkill]);
    }
    else
    {
        LoadPlayerWeapons(playerid);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmedWeapon(playerid, 0);
        TogglePlayerControllable(playerid, true);
        SetPlayerSkin(playerid, Player[playerid][Skin]);
        for(new i = 0; i < 10; i++)
            SetPlayerSkillLevel(playerid, i, Player[playerid][WeaponSkill]);
    }
       
    if(Player[playerid][Jailed] == 1)
    {
        TogglePlayerControllable(playerid, false);
    }
   
    if(JustDied[playerid] == true)
    {
        TogglePlayerControllable(playerid, false);
    }
    JustDied[playerid] = false;
    return 1;
}
Second
I keep randomly dying for no reason, what's the issue?
Reply
#2

Here is your issue I think.

Why do you have this in OnPlayerSpawn under conditional statement where it checks if player is died.

pawn Код:
SetPlayerFacingAngle(playerid, 321.2364);
SetPlayerCameraPos(playerid, -305.4138,1075.1143,24.3368);
SetPlayerCameraLookAt(playerid, -323.5710,1052.5018,20.3403);
Remove that and try!
Reply
#3

Because, it's checking to see if a player is in hospital. If they are, then it will set the camera to the hospital.

Without that, it's useless and the whole hospital system won't work.
Reply
#4

Anyone?

Also, I found the issue about dying randomly.
Reply
#5

Check OnPlayerRequestSpawn and OnPlayerRequestClass. Add them in if you haven't got it and then call SpawnPlayer inside of them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)