Timer Problem
#1

hi, i wanted that my timer works but it doesnt.
My idea was that if someone pick up the pickup and get some cash it takes a while till the next one spawns?
I tried it again and again but without success i hope some of u can help me

pawn Код:
forward PickupRandomSpawn();
forward TEST();
pawn Код:
new pick1;
new pick2;
new pick3;
new Float:RandomSpawn[][3] =
 {
  {1945.9650,152.9478,37.0099},
 {1880.4320,247.6804,27.2093},
 {2019.9969,274.9753,28.5537}
};
pawn Код:
public OnGameModeInit()
{
    PickupRandomSpawn();
    TEST();
}
pawn Код:
public PickupRandomSpawn()
{
new iRandom = random(sizeof(RandomSpawn));
if(iRandom == 0)
{
pick1=CreatePickup(1550,3,RandomSpawn[iRandom][0],RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
}
else if(iRandom == 1)
{
pick2=CreatePickup(1550,3,RandomSpawn[iRandom][0],RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
}
else if(iRandom == 2)
{
pick3=CreatePickup(1550,3,RandomSpawn[iRandom][0],RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
}
return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{

    if(pickupid == pick1 || pickupid == pick2 || pickupid == pick3)
    {
    GivePlayerMoney(playerid,12500);
    SetTimer("PickupRandomSpawn",30000,true); // 30sec. PickupRandomSpawn();
    }
   
 return 1;

}
pawn Код:
public TEST()
{
 SetTimer("PickupRandomSpawn",30000,true); // 30sec.
 return 1;
}
I changed everything but it had any effect. First it runs but after 30sec two moneybags respawn why? i dont know please help me

Reply
#2

Why have u got PickupRandomSpawn and TEST in OnGameModeInit?, If i understood correctly then you are basicly setting 2 timers with the same function
Reply
#3

pawn Код:
new Float:RandomSpawn[][] =
{
    {1945.9650, 152.9478, 37.0099},
    {1880.4320, 247.6804, 27.2093},
    {2019.9969, 274.9753, 28.5537}
}, RandomPickupid;
pawn Код:
//OnGameModeInit
    CreatePickupAtRandPos(1242);
pawn Код:
//OnPlayerPickUpPickup(playerid, pickupid)
    if(pickupid == RandomPickupid)
    {
        DestroyPickup(RandomPickupid);
        GivePlayerMoney(playerid, 12_500);
        SetTimerEx("CreatePickupAtRandPos", 30_000, false, "i", 1242);
    }
pawn Код:
forward CreatePickupAtRandPos(modelid);
public CreatePickupAtRandPos(modelid)
{
    new rand = random(sizeof RandomSpawn);
    RandomPickupid = CreatePickup(modelid, 3, RandomSpawn[rand][0], RandomSpawn[rand][1], RandomSpawn[rand][2]);
}
Reply
#4

Wow it works! Just as I had wished me! You are awesome!
Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)