CreatePickup: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|CreatePickup(modelid, x, y, z)}} {{FuncParameters}} {{FuncParam|modelid|__EDIT_ME__}} {{FuncParam|..." |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Creates an object that spins around its axis. When a player ''picks'' it up an event [[OnPlayerPickupHit]] is called.}} | ||
{{FuncSyntax|CreatePickup(modelid, x, y, z)}} | {{FuncSyntax|CreatePickup(modelid, x, y, z)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|modelid| | {{FuncParam|modelid|See [[Objects]].}} | ||
{{FuncParam|x| | {{FuncParam|x|Coordinate X where to create this pickup.}} | ||
{{FuncParam|y| | {{FuncParam|y|Coordinate Y where to create this pickup.}} | ||
{{FuncParam|z| | {{FuncParam|z|Coordinate Z where to create this pickup.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the identifier to this newly created pickup.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
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) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{Template:PickupFunctions}} |
Latest revision as of 14:41, 27 February 2020
Description
Creates an object that spins around its axis. When a player picks it up an event OnPlayerPickupHit is called.
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
- GetPickupCount
- GetStreamedPickups
- GetPickupLocation
- SetPickupPropertyValue
- GetPickupPropertyValue
- SetPickupVisibleForPlayers
- GetAllPickups
- CreatePickup
- DestroyPickup
- IsValidPickup
- SetPickupScale
- GetPickupScale
- SetPickupDimension
- GetPickupDimension
- SetPickupVisibility
- SetPickupOutline
- IsPickupStreamedIn