problem with /accept death
#1

Hello guys. So I am currently working on to get players able to do /accept death when EMS is off duty and when EMS is on duty /accept death wont work.

So this is my current code.

pawn Код:
stock EMSOnline()
{
    new dutycount = 0;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pDuty] == 1)
            {
                dutycount++;
            }
        }
    }
    if(dutycount > 0)
    {
        return 1;
    }
    return 0;
}
pawn Код:
if(strcmp(params,"death",true) == 0) {
        if(EMSOnline())
        return SendClientMessageEx(playerid, COLOR_RED, "You cant accept death when EMS is available");
        }
        else
        {
            if(GetPVarInt(playerid, "Injured") == 1) {
                SendClientMessageEx(playerid, COLOR_WHITE, "You gave up hope and fell unconscious, you were immediately sent to the hospital.");
                KillEMSQueue(playerid);
                ResetPlayerWeaponsEx(playerid);
                SpawnPlayer(playerid);
                format(string, sizeof(string), "(( %s Has just accepted death, if this was done to AVOID, F8 and make a Complaint ))",  GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                format(string, sizeof(string), "AdmWarning: %s has just Accepted Death",GetPlayerNameEx(playerid));
                ABroadCast(COLOR_LIGHTRED, string, 1);
            }
            else {  SendClientMessageEx(playerid, COLOR_GREY, "   You are not injured, you can't do this right now !"); }
        }
But when EMS is on duty and a player types /accept death it says "You cant accept death when EMS is online" but when EMS is off duty and a player types /accept death nothing happens. Nothing pops up in the chat and just nothing happens. So my question is, what should I change to make the player able to do /accept death when EMS is off duty? Thanks for helping me out.
Reply
#2

Are you sure variable "injured" is set correctly? and why use PVars? you can use regular variables for this.
pawn Код:
new Injured[MAX_PLAYERS];

Injured[playerid] = 1;
And if I were you i'd use compound blocks instead of those lines, example:
pawn Код:
if(EMSOnline())
{
    SendClientMessageEx(playerid, COLOR_RED, "You cant accept death when EMS is available");
}
else
{
    if(GetPVarInt(playerid, "Injured") == 1)
    {                
        SendClientMessageEx(playerid, COLOR_WHITE, "You gave up hope and fell unconscious, you were immediately sent to the hospital.");
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "   You are not injured, you can't do this right now !");        
    }
}
This way its much more easier to look over { and }. You should probably set the players health to 0 aswell and move the code to OnPlayerDeath.
Reply
#3

I will test this, thanks.
Reply
#4

bracket too much...
try this:
pawn Код:
if(strcmp(params,"death",true) == 0) {
        if(EMSOnline())
        return SendClientMessageEx(playerid, COLOR_RED, "You cant accept death when EMS is available");
        else
        {
            if(GetPVarInt(playerid, "Injured") == 1) {
                SendClientMessageEx(playerid, COLOR_WHITE, "You gave up hope and fell unconscious, you were immediately sent to the hospital.");
                KillEMSQueue(playerid);
                ResetPlayerWeaponsEx(playerid);
                SpawnPlayer(playerid);
                format(string, sizeof(string), "(( %s Has just accepted death, if this was done to AVOID, F8 and make a Complaint ))",  GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                format(string, sizeof(string), "AdmWarning: %s has just Accepted Death",GetPlayerNameEx(playerid));
                ABroadCast(COLOR_LIGHTRED, string, 1);
            }
            else {  SendClientMessageEx(playerid, COLOR_GREY, "   You are not injured, you can't do this right now !"); }
        }

shouldn't matter if you use a PVar or a normal variable, both should work.
Reply
#5

pawn Код:
if(strcmp(params,"death",true) == 0) {
            if(GetPVarInt(playerid, "Injured") == 1) {
                SendClientMessage(playerid, COLOR_WHITE, "You gave up hope and fell unconscious, you were immediately sent to the hospital.");
                KillEMSQueue(playerid);
                ResetPlayerWeaponsEx(playerid);
                SpawnPlayer(playerid);
            }
            else {  SendClientMessage(playerid, COLOR_GREY, "   You're not injured, you can't do this right now!"); }
        }
Is what I use maybe it helps?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)