Problem with SetTimerEx
#1

I Have Trucker job.. And i put SetTimerEx for 1 hour.But dont work i dont know why ?? This is code plz help me.

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 455)
     {
         GivePlayerMoney(playerid, 500);
         GameTextForPlayer(playerid, "~g~Example", 3000, 3);
         SendClientMessage(playerid, 0x07C85CFF,"Example");
         SetTimerEx("Job", 3600000, false, "i", playerid);
         SetVehicleToRespawn(513);
         DisablePlayerCheckpoint(playerid);
         truckjobrunning = 0;
     }
Reply
#2

From that code it looks like you're assuming that a timer works a bit like a sleep function in other languages; well, it doesn't, it calls its own public function so:

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 455)
    {
        GivePlayerMoney(playerid, 500);
        GameTextForPlayer(playerid, "~g~Example", 3000, 3);
        SendClientMessage(playerid, 0x07C85CFF,"Example");
        SetTimerEx("Job", 3600000, false, "i", playerid);    
    }
    return 1;
}

forward Job(playerid);
public Job(playerid)
{
    SetVehicleToRespawn(513);
    DisablePlayerCheckpoint(playerid);
    truckjobrunning = 0;
    return 1;
}
Something like that would do, but that's only from what I can assume you're asking, there are a fair number of other issues with that code which probably need addressing too, such as this:

pawn Код:
SetVehicleToRespawn(513);
How do you know that the specific vehicle you want is going to have vehicleid 513?

Also your variable "truckjobrunning" does not apply on a per player basis....

I have no idea of your requirements so I am unable to help further.
Reply
#3

Ohh but all is not only truckjob This is all code

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 455)
     {
         GivePlayerMoney(playerid, 500);
         GameTextForPlayer(playerid, "~g~Вие свършихте работата,Ще можете отново след 1 час!", 3000, 3);
         SendClientMessage(playerid, 0x07C85CFF,"Вие свършихте работата и получихте 500$ за нея,Ще можете отново след 1 час");
         SetTimerEx("Job", 3600000, false, "i", playerid);
         SetVehicleToRespawn(513);
         DisablePlayerCheckpoint(playerid);
         truckjobrunning = 0;
     }
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 519)
     {
         GivePlayerMoney(playerid, 300);
         GameTextForPlayer(playerid, "~g~Вие свършихте работата,Ще можете отново след 1 час!", 3000, 3);
         SendClientMessage(playerid, 0x07C85CFF,"Вие свършихте работата и получихте 300$ за нея,Ще можете отново след 1 час");
         SetTimerEx("Job", 3600000, false, "i", playerid);
         SetVehicleToRespawn(1);
         DisablePlayerCheckpoint(playerid);
         flyjobrunning = 0;
         SetPlayerPos(playerid, 1729.8932,-2415.7798,14.4727);
     }
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 532)
   {
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint1))
     {
          SetPlayerCheckpoint(playerid, Checkpoint2, 7.0);
          CreateObject(823,-231.8289,-1467.9810,4.9421,0,0,0);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint2))
     {
          SetPlayerCheckpoint(playerid, Checkpoint3, 7.0);
          CreateObject(823,-193.9747,-1375.2502,4.7856,0,0,0);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint3))
     {
          SetPlayerCheckpoint(playerid, Checkpoint4, 7.0);
          CreateObject(823,-246.0348,-1326.1063,8.9300,0,0,0);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint4))
     {
          SetPlayerCheckpoint(playerid, Checkpoint5, 7.0);
          CreateObject(823,-407.1459,-1371.5518,23.6588,0,0,0);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint5))
     {
          SetPlayerCheckpoint(playerid, Checkpoint6, 7.0);
          CreateObject(823,-564.7697,-1302.4977,22.5511,0,0,0);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint6))
     {
          SetPlayerCheckpoint(playerid, Checkpoint7, 7.0);
         }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Checkpoint7))
     {
          GivePlayerMoney(playerid, 300);
          GameTextForPlayer(playerid, "~g~Вие свършихте работата и получихте 300$ за нея,Ще можете отново след 1 час!", 3000, 3);
          SendClientMessage(playerid, 0x07C85CFF,"Вие свършихте работата и получихте 300$ за нея,Ще можете отново след 1 час");
          SetTimerEx("Job", 3600000, false, "i", playerid);
          SetVehicleToRespawn(2);
          combinejobrunning = 0;
          DisablePlayerCheckpoint(playerid);
     }
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 588)
     {
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint1))
     {
          SetPlayerCheckpoint(playerid, HotPoint2, 7.0);
          GameTextForPlayer(playerid, "~g~1 House done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint2))
     {
          SetPlayerCheckpoint(playerid, HotPoint3, 7.0);
          GameTextForPlayer(playerid, "~g~2 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint3))
     {
          SetPlayerCheckpoint(playerid, HotPoint4, 7.0);
          GameTextForPlayer(playerid, "~g~3 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint4))
     {
          SetPlayerCheckpoint(playerid, HotPoint5, 7.0);
          GameTextForPlayer(playerid, "~g~4 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint5))
     {
          SetPlayerCheckpoint(playerid, Refillpoint, 7.0);
          GameTextForPlayer(playerid, "~g~5 Houses done, refill your hotdogs at the marker!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,Refillpoint))
     {
          SetPlayerCheckpoint(playerid, HotPoint6, 7.0);
          GameTextForPlayer(playerid, "~g~Hotdogs refilled!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint6))
     {
          SetPlayerCheckpoint(playerid, HotPoint7, 7.0);
          GameTextForPlayer(playerid, "~g~6 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint7))
     {
          SetPlayerCheckpoint(playerid, HotPoint8, 7.0);
          GameTextForPlayer(playerid, "~g~7 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint8))
     {
          SetPlayerCheckpoint(playerid, HotPoint9, 7.0);
          GameTextForPlayer(playerid, "~g~8 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint9))
     {
          SetPlayerCheckpoint(playerid, HotPoint10, 7.0);
          GameTextForPlayer(playerid, "~g~9 Houses done!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint10))
     {
          SetPlayerCheckpoint(playerid, HotPoint11, 7.0);
          GameTextForPlayer(playerid, "~g~10 Houses done, get back to the startpoint!", 3000, 3);
     }
     if (IsPlayerInRangeOfPoint(playerid, 7.0,HotPoint11))
     {
         GivePlayerMoney(playerid, 300);
         GameTextForPlayer(playerid, "~g~You collected a total of $800,-!", 3000, 3);
         SendClientMessage(playerid, 0x07C85CFF,"Вие свършихте работата и получихте 300$ за нея,Ще можете отново след 1 час");
         SetTimerEx("Job", 3600000, false, "i", playerid);
         new veh;
         veh = GetPlayerVehicleID(playerid);
         SetVehicleToRespawn(veh);
         DisablePlayerCheckpoint(playerid);
         hotdog = 0;
     }
   }
}
     return 1;}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)