Code not working properly
#1

Hello I have this at my command:

pawn Код:
if(Health < 1)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
It doesn't want to send msg when player dies..?
Reply
#2

try this
pawn Код:
new Float:Health;
if(Health < 1)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
Reply
#3

new Float:Health;

Post it at the top and it should work fine for you.
Reply
#4

Where did you put this code?
Reply
#5

Код:
new Float:Health;
if(Health < 0)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
Reply
#6

Quote:
Originally Posted by Dragon2
Посмотреть сообщение
Код:
new Float:Health;
if(Health < 0)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
What makes you think this would work?
Reply
#7

Quote:
Originally Posted by Namer
Посмотреть сообщение
try this
pawn Код:
new Float:Health;
if(Health < 1)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
Quote:
Originally Posted by Dragon2
Посмотреть сообщение
Код:
new Float:Health;
if(Health < 0)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
Declaring a variable without any value and checking its value right away makes absolutely no sense. Health will always be 0.0

You must get the player's health first and then check for it.
Reply
#8

pawn Код:
else if(strcmp(x_nr,"heroin",true) == 0)
        {
            new Float:Health;
            GetPlayerHealth(playerid, Health);

            new Float:Armour;
            GetPlayerArmour(playerid, Armour);
           
            if(Pdrug[playerid][Needle] >= 1)
            {
                if(Pdrug[playerid][Heroin] >= 1)
                {
                    if(Pdrug[playerid][Addiction] >= 30)
                    {
                        Pdrug[playerid][Addiction] = 0;
                        Pdrug[playerid][AddictionLv] += 1;
                        SendClientMessage(playerid, -1, "{FFFFFF}Your addiction level has raised, write /addiction to read about drug addiciton levels.");
                    }
                    Pdrug[playerid][Heroin] -= 1;
                    Pdrug[playerid][Addiction] += 10;
                    SetPlayerDrunkLevel (playerid, 50000);
                    SetPlayerWeather(playerid, 9); // foggy - cold..
                    SendClientMessage(playerid, -1, "{FFFFFF}You've used 1 gram of heroin your health points decreased by -40 and armour points raised by +25.");
                    TextDrawShowForPlayer(playerid,Text:Textdraw0);
                    // Animation

                    if(Health < 1)
                    {
                        SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You have died because of drug overdose.");
                    }
                    else if(Health >= 1)
                    {
                        SetPlayerHealth(playerid, Health -40);
                    }
This is almost full code... That part where it says "you have died becaouse of drug overdose.." it's not working.
Reply
#9

Maybe you have to use the onplayerdead callback instead of if(Health < 1) I dont know
Reply
#10

So where is the problem? Anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)