CreatePickup: Difference between revisions

From Onset Developer Wiki
No edit summary
28days (talk | contribs)
No edit summary
Line 38: Line 38:


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{Template:PickupFunctions}}

Revision as of 09:59, 12 December 2019

CreatePickup

Type: Function
Context: Server
Introduced: v1.0

Description

Creates an object that spins around its axis. When a player or vehicle picks it up an event is called. OnPlayerPickupHit, OnVehiclePickupHit

Syntax

CreatePickup(modelid, x, y, z)

Parameters

  • modelid
    See Objects.
  • x
    Coordinate X where to create this pickup.
  • y
    Coordinate Y where to create this pickup.
  • z
    Coordinate Z where to create this pickup.

Return Value

  • Returns the identifier to this newly created pickup.

Example

local WeaponPickups = { }

local function OnPackageStart()
	for i=1,19 do
		WeaponPickups[i] = CreatePickup(i + 3, 129898.9453125, 81860.2421875 - (i * 200.0), 1566.9010009766)
	end
end
AddEvent("OnPackageStart", OnPackageStart)

local function OnPlayerPickupHit(player, pickup)
	--AddPlayerChat(player, "You have hit pickup id "..pickup)
	
	for i, p in pairs(WeaponPickups) do
		if p == pickup then
			SetPlayerWeapon(player, i + 1, 450, true, 1)
			return
		end
	end
end
AddEvent("OnPlayerPickupHit", OnPlayerPickupHit)

See also