Jump to content
RAGE Multiplayer Community

1 Screenshot

About This File

 

Requires RAGE Multiplayer 1.1.0 and above.

This resource adds the ability to create classic GTA style pickups we all love.

 

Installing

  • Put the files you downloaded in their respective places
  • Add require('fake-pickups') to client_packages/index.js
  • All done

 

Serverside API

Global mp object extension:

// Properties
/*
	Returns the amount of existing pickups.
*/
mp.fakePickups.length;

// Functions
/*
	Creates a pickup.
	* model - Model name or hash, such as prop_armour_pickup.
	* position - Position of the pickup, recommended: mp.Vector3 instance
	* pickupRange - Collection range of the pickup.
	* respawnTime - Respawn time of the pickup after collection, values less than 1 will disable respawning of the pickup.
	* dimension - Dimension of the pickup.
*/
mp.fakePickups.new(model, position, pickupRange, respawnTime, dimension = 0);

/*
	Returns the pickup instance with specified ID.
*/
mp.fakePickups.at(id);

/*
	Returns whether a pickup with specified ID exists.
*/
mp.fakePickups.exists(id);

/*
	Returns an array of existing pickups.
*/
mp.fakePickups.toArray();

 

FakePickup class:

// Properties
/*
	ID of the pickup, read only.
*/
instance.id;

/*
	Model hash of the pickup, read only.
*/
instance.model;

/*
	Position of the pickup, read only.
*/
instance.position;

/*
	Collection range of the pickup, read only.
*/
instance.pickupRange;

/*
	Respawn time of the pickup, can be changed.
*/
instance.respawnTime;

/*
	Light data of the pickup, read only.
*/
instance.lightData;

/*
	Whether the pickup is collected, read only.
*/
instance.isCollected;

/*
	Dimension of the pickup, can be changed.
*/
instance.dimension;

// Functions
/*
	Allows you to set light data of the pickup, argument names should be obvious.
	If you want to remove the pickup's light, use resetLightData instead of this function with weird values.
*/
instance.setLightData(red, green, blue, range, intensity, shadow);

/*
	Resets light data of the pickup.
*/
instance.resetLightData();

/*
	Respawns the pickup. (if collected)
*/
instance.respawn();

/*
	Destroys the pickup.
*/
instance.destroy();

 

Events:

/*
	fakePickupSpawn is called when a pickup's prop is created. (Basically when it's created and respawned)
*/
mp.events.add("fakePickupSpawn", (pickup) => {
	// code here
});

/*
	playerCollectFakePickup is called when a player collects a pickup.
	This event is cancelable. (Check example script)
*/
mp.events.add("playerCollectFakePickup", (player, pickup, cancel) => {
	// code here
});

 

Example Script

// setLightData calls are optional and you don't have to use them, just makes the pickups stand out at night time.
const moneyPickup = mp.fakePickups.new("ex_prop_exec_cashpile", new mp.Vector3(1571.681, 3163.909, 40.331), 1.0, 5000);
moneyPickup.setLightData(114, 204, 114, 2.0, 2.5, 15.0);

const healthPickup = mp.fakePickups.new("prop_ld_health_pack", new mp.Vector3(1568.648, 3166.397, 40.331), 1.0, 5000);
healthPickup.setLightData(53, 154, 71, 2.0, 2.5, 15.0);

const armorPickup = mp.fakePickups.new("prop_armour_pickup", new mp.Vector3(1567.359, 3169.639, 40.331), 1.0, 5000);
armorPickup.setLightData(93, 182, 229, 2.0, 2.5, 15.0);

const weaponPickup = mp.fakePickups.new("w_mg_combatmg", new mp.Vector3(1569.465, 3172.773, 40.331), 1.0, 5000);
weaponPickup.setLightData(255, 133, 85, 2.0, 2.5, 15.0);

// You're better off using custom properties with your pickup instance, this code is for testing purposes.
mp.events.add("playerCollectFakePickup", (player, pickup, cancel) => {
    if (pickup === moneyPickup) {
        player.outputChatBox("You picked up some money.");
    } else if (pickup === healthPickup) {
        if (player.health >= 75) {
            player.outputChatBox("You're just fine, no need to waste a health pack.");
          
            // Doing cancel.cancel = true; prevents the pickup from being marked as collected.
            cancel.cancel = true;
            return;
        }

        player.health = 100;
        player.outputChatBox("Health refilled.");
    } else if (pickup === armorPickup) {
        if (player.armour > 0) {
            player.outputChatBox("You already have armor.");
          
            // Doing cancel.cancel = true; prevents the pickup from being marked as collected.
            cancel.cancel = true;
            return;
        }

        player.armour = 100;
        player.outputChatBox("You picked up some armor.");
    } else if (pickup === weaponPickup) {
        player.giveWeapon(mp.joaat("weapon_combatmg"), 9999);
        player.outputChatBox("You picked up Combat MG.");
    }
});

mp.events.add("fakePickupSpawn", (pickup) => {
    switch (pickup.model) {
        case mp.joaat("ex_prop_exec_cashpile"):
            mp.players.broadcast("The money pickup has respawned.");
        break;

        case mp.joaat("prop_ld_health_pack"):
            mp.players.broadcast("The health pickup has respawned.");
        break;

        case mp.joaat("prop_armour_pickup"):
            mp.players.broadcast("The body armor pickup has respawned.");
        break;

        case mp.joaat("w_mg_combatmg"):
            mp.players.broadcast("The Combat MG pickup has respawned.");
        break;
    }
});

 

Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-fake-pickups

  • Like 4
  • Mask 1

User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

Captien

   1 of 1 member found this review helpful 1 / 1 member

Thanks, i picked up my dropped money from the last death)

  • Like 1
Link to comment
×
×
  • Create New...