Need a little help with this please ! :)
#1

I made in my script that when player is dead money pickup creates at there where
he was killed, but I need a litlle help with creating a timer so after 5 seconds that
pickup will be gone.

Please help me !
Reply
#2

You have to assign an ID to the pickup and then in the function you run with the timer just use DestroyTImer for that timer ID.
Reply
#3

Quote:
Originally Posted by LOLlolLOL
Посмотреть сообщение
You have to assign an ID to the pickup and then in the function you run with the timer just use DestroyTImer for that timer ID.
I created a pickup & other stuff, I just need a help creating a timer.
Where I need to put it & can you give me a example please ?
Reply
#4

All you need to do is create DestroyPickup(pickupid); function, and add this timer under on player death.

Код:
SetTimerEx("DestroyPickup", 5000, false, "u", pickupid);
Reply
#5

Quote:
Originally Posted by Ironboy500[TW]
Посмотреть сообщение
All you need to do is create DestroyPickup(pickupid); function, and add this timer under on player death.

Код:
SetTimerEx("DestroyPickup", 5000, false, "u", pickupid);
ok thanks !
But what is it there at "u" do I need to change that or just leave it ?
Reply
#6

It doesnt work, pickup is not gone after 5 seconds. !
Reply
#7

pawn Код:
new moneypickup[MAX_PICKUPS][2] = {-1, -1, ...};
public OnPlayerDeath(playerid, killerid, reason)
{
  new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);

  new pickup = CreatePickup(1550, 23, pos[0], pos[1], pos[2]); //Might fuck around a bit with the '23'
  moneypickup[pickup][0] = GetPlayerMoney(playerid); //The player loses all his money. Change this to whatever value the pickup must contain.
  ResetPlayerMoney(playerid); //Resets the player's money, use GivePlayerMoney(playerid, -amount) to remove a specific amount.
  moneypickup[p][1] = SetTimerEx("DeletePickupEx", 5*1000, 0, "d", pickup);
  return 1;
}

forward DeletePickupEx(pickupid);
public DeletePickupEx(pickupid)
{
  DestroyPickup(pickupid);
  moneypickup[pickupid][0] = -1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
  for(new p; p < MAX_PICKUPS; p++)
  {
    if(moneypickup[p][0] != -1)
    {
      KillTimer(moneypickup[p][1]);
      GivePlayerMoney(playerid, moneypickup[p][0]);
      DestroyPickup(p);
    }
  }
  return 1;
}
Didn't tested anything, and the typing box is a li'l small (Quick reply). Hope it works.
Reply
#8

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
new moneypickup[MAX_PICKUPS][2] = {-1, -1, ...};
public OnPlayerDeath(playerid, killerid, reason)
{
  new Float:pos[3]; GetPlayerPos(playerid, pos[0], pos[1], pos[2]);

  new pickup = CreatePickup(1550, 23, pos[0], pos[1], pos[2]); //Might fuck around a bit with the '23'
  moneypickup[pickup][0] = GetPlayerMoney(playerid); //The player loses all his money. Change this to whatever value the pickup must contain.
  ResetPlayerMoney(playerid); //Resets the player's money, use GivePlayerMoney(playerid, -amount) to remove a specific amount.
  moneypickup[p][1] = SetTimerEx("DeletePickupEx", 5*1000, 0, "d", pickup);
  return 1;
}

forward DeletePickupEx(pickupid);
public DeletePickupEx(pickupid)
{
  DestroyPickup(pickupid);
  moneypickup[pickupid][0] = -1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
  for(new p; p < MAX_PICKUPS; p++)
  {
    if(moneypickup[p][0] != -1)
    {
      KillTimer(moneypickup[p][1]);
      GivePlayerMoney(playerid, moneypickup[p][0]);
      DestroyPickup(p);
    }
  }
  return 1;
}
Didn't tested anything, and the typing box is a li'l small (Quick reply). Hope it works.
I just get a lot of errors !
Reply
#9

Quote:
Originally Posted by Matej_
Посмотреть сообщение
I just get a lot of errors !
Can you post em? I'll try to fix XD
Reply
#10

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Can you post em? I'll try to fix XD
To much errors ! :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)