Player dont get cancer
#1

Hi, ive made it so when you smoke more than the choosen ammount (i put it on 2 for test) you get cancer. Now.. my problem is that i dont know if the player have cancer... This is the smoke code
pawn Код:
if(strcmp(cmd, "/smoke", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pLighter] > 0)
            {
                if(PlayerInfo[playerid][pCigarettes] > 0)
                {
                    IsSmoking[playerid] = 1;
                    PlayerInfo[playerid][pCigarettes] --;
                    PlayerInfo[playerid][pLighter] --;
                    if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* Stranger takes out his lighter and cigarette and lights it up."); }
                    else { format(string, sizeof(string), "* Stranger takes out her lighter and cigarette and lights it up."); }
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_SMOKE_CIGGY);
                    PlayerInfo[playerid][pTimesSmoked] ++;
                    if(PlayerInfo[playerid][pTimesSmoked] > 2)
                    {
                        PlayerInfo[playerid][pCancer] = 1;
                    }
                    if(PlayerInfo[playerid][pCancer])
                    {
                        new Float: HP;
                        GetPlayerHealth(playerid, HP);
                        SetPlayerHealth(playerid, HP-5);
                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"You dont have any ciggarettes left,Go buy some more!");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You dont have a lighter!");
            }
        }
        return 1;
     }
and if the player have cancer this is supose to come
pawn Код:
if(PlayerInfo[playerid][pCancer] == 1)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You're having trouble breathing... (( Lung Cancer ))");
        SetTimerEx("Cough", 6000, 1, "d", playerid);
    }
    return 1;
}

forward Cough(playerid);
public Cough(playerid)
{
    if(PlayerInfo[playerid][pCancer] == 1)
    {
        new string[256];
        format(string, sizeof(string), "%s is coughing really hard...", playerid);
        ProxDetector(20.0, playerid, string,COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
        new Float:HP;
        GetPlayerHealth(playerid, HP);
        SetPlayerHealth(playerid, HP-4);
    }
}
But it dont, i have been waiting longer than the timer is supose to be and still nothing
Reply
#2

Where do you put this in your gamemode?

pawn Код:
if(PlayerInfo[playerid][pCancer] == 1)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You're having trouble breathing... (( Lung Cancer ))");
        SetTimerEx("Cough", 6000, 1, "d", playerid);
    }
    return 1;
}
Reply
#3

OnPlayerSpawn
Reply
#4


Is PlayerInfo[playerid][pCancer] saves in some kind of file or mysql?
Reply
#5

Dammit.. Thanks forgot about that lol. Sorry,will make it save in file and come back with if it works or not
Reply
#6

And one more thing in the timerex,
SetTimerEx("Cough", 6000, 1, "d", playerid);

1, change to 0.
or else it will keep calling the function

Reply
#7

I want it to keep calling the function every 1 hour (6 seconds for test now) so shouldnt it be on 1 then?
Reply
#8

Oh so if you wan't to call it every hour, change it to 1.

1 hour = 3600000
Reply
#9

Ok then i did something good haha. Anyway i tried it again now after making it save in file and nothing have changed, still comes nothing even after 2 smokes
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)