Reseting a Timer.Would this work?
#4

I still have the problem,I'll just post de code here.

pawn Код:
public OnPlayerLogin
{
if(PlayerInfo[playerid][pAddicted] == 1)
        {
           drugtime = SetTimerEx("AddictionKickIn", 1800000, 0, "d", playerid);
        }
}
--------------------------------------------------------------------------------------------

public OnPlayerCommandText
{
if(strcmp(cmd,"/usedrugs",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
           new x_job[256];
           x_job = strtok(cmdtext, idx);
           GetPlayerName(playerid, sendername, sizeof(sendername));
           if(!strlen(x_job))
           {
             SendClientMessage(playerid,COLOR_GREY,"Correct Usage: /usedrugs [drugname]");
             SendClientMessage(playerid,COLOR_WHITE,"|_________ Available Names __________|");
             SendClientMessage(playerid,COLOR_GREY,"Weed(25HP),LSD(50HP),PCP(60HP),Methamphetamine(75HP),Cocaine(100HP)");
             return 1;
           }
           if(strcmp(x_job,"Weed",true) == 0)
           {
             if(PlayerInfo[playerid][pDrugs] >= 1)
             {
                if(High[playerid] == 0)
                {
                GameTextForPlayer(playerid, "~w~You are now~n~~p~High !", 4000, 1);
                new Float:health;
                GetPlayerHealth(playerid, health);
                if(PlayerInfo[playerid][pDrugPerk] > 0)
                {
                  if(health >= 125)
                  {
                    new hp = 2 * PlayerInfo[playerid][pDrugPerk]; hp += 125;
                    SetPlayerHealth(playerid, 150);
                  }
                  else
                  {
                    new hp = 2 * PlayerInfo[playerid][pDrugPerk]; hp += 125;
                    SetPlayerHealth(playerid, health + hp);
                  }
                }
                else
                {
                  if(health >= 125)
                  {
                    SetPlayerHealth(playerid, 150);
                  }
                  else
                  {
                    SetPlayerHealth(playerid, health + 25);
                  }
                }
                GameTextForPlayer(playerid,"~w~ You are now ~p~~h~ High ",3000,1);
                SendClientMessage(playerid, COLOR_GREY, " 1 Drug Grams used !");
                if(AddictTime[playerid] > 0 )
                {
                 SendClientMessage(playerid,COLOR_YELLOW,"You used drugs to calm your drug addiction !");
                 AddictTime[playerid] = 0;
                }
                KillTimer(drugtime);
                drugtime = SetTimerEx("AddictionKickIn", 50000, 0, "d", playerid);
                PlayerInfo[playerid][pAddicted] = 1;
                PlayerInfo[playerid][pPassAddiction] = 5;
                PlayerInfo[playerid][pDrugs] -= 1;
                High[playerid] = 1;
                SetPlayerWeather(playerid,2009);
                SetTimerEx("ResetWeather", 45000, 0, "d", playerid);
                format(string, sizeof(string), "* %s rolls up some weed and starts to smoke it.", sendername);
                ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                ApplyAnimation(playerid,"SMOKING","M_smk_out", 4.0, 0, 0, 0, 0, 0);
                return 1;
                }
                else
                {
                   SendClientMessage(playerid,COLOR_GREY,"You can not use drugs right now !");
                }
              }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   You need 1 gram of drugs for that drug !");
            }
          }
}
--------------------------------------------------------------------------------------------------------
public AddictionKickIn(playerid)
{
 if(PlayerInfo[playerid][pPassAddiction] <= 5 && PlayerInfo[playerid][pPassAddiction] != 0)
 {
  if(AddictTime[playerid] < 10)
  {
   new string[256];
   new HP = random(9)+1;
   SetPlayerHealth(playerid, -HP);
   SendClientMessage(playerid,COLOR_YELLOW,"Your drug addiction has kicked in !");
   format(string, sizeof(string), "* %s are ochii rosii si incepe sa tremure.", sendername);
   ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
   format(string, sizeof(string), "* You lost %d HP because of your drug addiction",HP);
   SendClientMessage(playerid,COLOR_YELLOW,string);
   SendClientMessage(playerid,COLOR_YELLOW," You can /usedrugs or wait for the addiction to go ");
   drugtime = SetTimerEx("AddictionKickIn", 60000, 0, "d", playerid);
   AddictTime[playerid] += 1;
  }
  else if(AddictTime[playerid] == 10)
  {
    SendClientMessage(playerid,COLOR_YELLOW," Your addiction passed and you didn't used drugs ! Good Job !");
    AddictTime[playerid] = 0;
    PlayerInfo[playerid][pPassAddiction] -= 1;
    if(PlayerInfo[playerid][pPassAddiction] == 0)
    {
      SendClientMessage(playerid,COLOR_YELLOW," Congratulations ! You are not addicted to drugs anymore !");
      PlayerInfo[playerid][pAddicted] = 0;
    }
    return 1;
  }
 }
 return 1;
}
What may be the problem? I've tried anything,nothing happens when I do /usedrugs,the AddictionKickIn just doesn't show up.

EDIT: I also tried to replace
Quote:

if(PlayerInfo[playerid][pPassAddiction] <= 5 && PlayerInfo[playerid][pPassAddiction] != 0)

with
Quote:

if(PlayerInfo[playerid][pAddicted] == 1)

Reply


Messages In This Thread
Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 14:27
Re: Reseting a Timer.Would this work? - by Madd Kat - 18.02.2012, 14:30
Re: Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 14:31
Re: Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 15:37
Re: Reseting a Timer.Would this work? - by Hoborific - 18.02.2012, 15:39
Re: Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 15:41
Re: Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 15:44
Re: Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 16:07
Re: Reseting a Timer.Would this work? - by FreeSoul - 18.02.2012, 16:21
Re: Reseting a Timer.Would this work? - by Madd Kat - 18.02.2012, 17:39

Forum Jump:


Users browsing this thread: 1 Guest(s)