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 |
||
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 or vehicle ''picks'' it up an event is called. [[OnPlayerPickupHit]], [[OnVehiclePickupHit]] }} | ||
{{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}} | ||
__EDIT_ME__ | __EDIT_ME__ |
Revision as of 16:40, 26 September 2019
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
__EDIT_ME__