Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define INVALID_PICKUP_ID 9999
- forward InitiateGifts(); //This function creates giftboxes and resets variables to default.
- forward DestroyGifts(); //This function destroys every giftbox and resets variables to default.
- forward CheckGift(playerid,pickupid); //You must insert this function in your OnPlayerPickUpPickup public from your gamemode.
- forward PlayerGiftReward(playerid,pickupid); //You must use this public in your gamemode in order to set a bonus for the player to receive when he picks up a giftbox.
- //---------- This array contains the positions of the giftboxes {x,y,z} ----------
- new Float:GiftPos[][] = {
- {2044.6616, 1339.3722, 10.6719},
- {2051.0129,1346.4264,10.6719},
- {2046.7195,1352.7656,10.6719},
- {2051.8047,1359.9277,10.6719},
- {2047.4851,1365.3621,10.6719}
- };
- //------------------------------------
- new GiftPickup[sizeof(GiftPos)]; //Contains the id of the pickup
- new bool:GiftPickupStatus[sizeof(GiftPos)]; //Pickup status: used/unused.
- //------------------------------------
- public InitiateGifts()
- {
- for(new i; i < sizeof(GiftPos); i++)
- {
- if(GiftPickup[i] != INVALID_PICKUP_ID && GiftPickupStatus[i] != false) DestroyPickup(GiftPickup[i]);
- GiftPickup[i] = INVALID_PICKUP_ID;
- GiftPickupStatus[i] = false;
- }
- new MaxRandom = 0;
- new RandomNumber = 0;
- for(new i; MaxRandom <= sizeof(GiftPos)/2; i++) //When this public is called, on your map will be spawned just a half(random) from the total coordonates that you set in GiftPos array.
- {
- RandomNumber = random(sizeof(GiftPos));
- if(GiftPickupStatus[RandomNumber] != true)
- {
- GiftPickup[RandomNumber] = CreatePickup(19054, 19, GiftPos[RandomNumber][0], GiftPos[RandomNumber][1], GiftPos[RandomNumber][2], -1);
- GiftPickupStatus[RandomNumber] = true;
- MaxRandom++;
- }
- }
- printf("** GIFTS: %d giftboxes has been created with successfully!",MaxRandom);
- return 1;
- }
- public DestroyGifts()
- {
- for(new i; i < sizeof(GiftPos); i++) { if(GiftPickup[i] != INVALID_PICKUP_ID && GiftPickupStatus[i] != false) DestroyPickup(GiftPickup[i]), GiftPickup[i] = INVALID_PICKUP_ID, GiftPickupStatus[i] = false; }
- print("** GIFTS: The gift boxes has been destroyed!");
- return 1;
- }
- public CheckGift(playerid,pickupid)
- {
- for(new i; i < sizeof(GiftPos); i++) { if(GiftPickup[i] == pickupid && IsPlayerInRangeOfPoint(playerid, 2.0, GiftPos[i][0], GiftPos[i][1], GiftPos[i][2])) DestroyPickup(pickupid), PlayerGiftReward(playerid,pickupid), printf("[**] GIFTS: PlayerID %d pick up GiftID %d!",playerid,pickupid); }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement