Pickup Timer.
#1

Hello I need some help. I just need to know how can i create a pickup which gets spawn on my given coordinates every 5 mins.

For eg:- when the server starts and after 5 mins there spawn an pickup on given coordinates when i picked up the pickup it will give me health 100 and then it will get destroyed. And again after 5 mins the pickup spawns on another place and when i pick it up again it will give me health and then it will get destroyed.
Reply
#2

Код:
new PickupReward;

public OnGameModeInit() {
	SetTimer("PickupTimer", 300000, false);
}

forward PickupTimer();
public PickupTimer() {
		PickupReward = CreatePickup(YOUR_MODEL, 1, COORD_X, COORD_Y, COORD_Z, 0);
}

public OnPlayerPickUpPickup(playerid, pickupid) {
	if(pickupid == PickupReward) {
		DestroyPickup(PickupReward);
		SetTimer("PickupTimer", 300000, false);
		//Give the player money or w/e you wanted.
		GivePlayerMoney(playerid, 1337);
	}
}
Reply
#3

PHP код:
forward PickupTimer();
public 
PickupTimer() {
        
pickup CreatePickup(12422306.426182026.7247316.736620);
        
pickup1 CreatePickup(12422306.426182026.7247316.736620);
        
pickup2 CreatePickup(12422306.426182026.7247316.736620);
        
pickup3 CreatePickup(12422306.426182026.7247316.736620);
        
pickup4 CreatePickup(12422306.426182026.7247316.736620);
        
pickup5 CreatePickup(12422306.426182026.7247316.736620);
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == pickup,pickup1,pickup2,pickup3,pickup4,pickup5) {
       
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,1,0,0,0,0);
    
SetTimerEx("ClearAnim",1500,false,"i",playerid);
    
GivePlayerWeapon(playerid2930);
    
GivePlayerWeapon(playerid2520);
    
SetTimer("PickupTimer"60000false);
       
Delete3DTextLabel(droplabel);
       
DestroyObject(air);
       
DestroyPickup(pickup1);
       
DestroyPickup(pickup2);
       
DestroyPickup(pickup3);
       
DestroyPickup(pickup4);
       
DestroyPickup(pickup5);
       
DestroyPickup(pickup); 
I am using this but not creating more pickup and the anim is not working while pickup
Reply
#4

PHP код:
public OnPlayerPickUpPickup(playeridpickupid){ 
    
//if(pickupid == pickup,pickup1,pickup2,pickup3,pickup4,pickup5) {  //lol ?
    
if(pickupid == pickup || pickupid == pickup1 || pickupid == pickup2 || pickupid == pickup3 || pickupid == pickup4 || pickupid == pickup5){
        
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,1,0,0,0,0); 
        
SetTimerEx("ClearAnim",1500,false,"i",playerid); 
        
GivePlayerWeapon(playerid2930); 
        
GivePlayerWeapon(playerid2520); 
        
SetTimer("PickupTimer"60000false); 
        
Delete3DTextLabel(droplabel); 
        
DestroyObject(air); 
        
DestroyPickup(pickup1); 
        
DestroyPickup(pickup2); 
        
DestroyPickup(pickup3); 
        
DestroyPickup(pickup4); 
        
DestroyPickup(pickup5); 
        
DestroyPickup(pickup);  
    }
    return 
1;

Reply
#5

Regarding the animation; You have to sometimes use the functions twice to actually make it happen.
Use the code of Abyss as he corrected your mistake.
Reply
#6

Quote:
Originally Posted by Luicy.
Посмотреть сообщение
Regarding the animation; You have to sometimes use the functions twice to actually make it happen.
Use the code of Abyss as he corrected your mistake.
No you don't, you have to preload the animation libraries before using an animation (this is a one time thing).
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
No you don't, you have to preload the animation libraries before using an animation (this is a one time thing).
That works too, I usually run the animation twice.
Reply
#8

Thanks all my hittas
Reply
#9

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
PHP код:
public OnPlayerPickUpPickup(playeridpickupid){ 
    
//if(pickupid == pickup,pickup1,pickup2,pickup3,pickup4,pickup5) {  //lol ?
    
if(pickupid == pickup || pickupid == pickup1 || pickupid == pickup2 || pickupid == pickup3 || pickupid == pickup4 || pickupid == pickup5){
        
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,1,0,0,0,0); 
        
SetTimerEx("ClearAnim",1500,false,"i",playerid); 
        
GivePlayerWeapon(playerid2930); 
        
GivePlayerWeapon(playerid2520); 
        
SetTimer("PickupTimer"60000false); 
        
Delete3DTextLabel(droplabel); 
        
DestroyObject(air); 
        
DestroyPickup(pickup1); 
        
DestroyPickup(pickup2); 
        
DestroyPickup(pickup3); 
        
DestroyPickup(pickup4); 
        
DestroyPickup(pickup5); 
        
DestroyPickup(pickup);  
    }
    return 
1;

This code is working fine but when I pickup the first pickup it gets deleted but when i pickup the second pickup its not deleted why?
Reply
#10

Someone help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)