Advertisement
hhjfdgdfgdfg

VORP Utils Docs

Mar 22nd, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.88 KB | None | 0 0
  1. VORP Utils
  2. A Vorp Utility Script that allows you to easily interact with RedM Natives and VorpCore in a Vorp standardized way. The goal of this is to make it easier to use some of the more complicated, or heavily lined natives.
  3.  
  4. API Docs
  5. Blips
  6. You can leverage Vorps built in function for map blips.
  7.  
  8. Create a Blip
  9. Client Side Only
  10. Create a marker (blip) on the players map
  11.  
  12. Parameter Description
  13. text What the blip will display on the map
  14. blipash The hashname of the blip (found here)
  15. scale How big the blip is
  16. x The x coordinate in the game world
  17. and The y coordinate in the game world
  18. With The z coordinate in the game world
  19. vector3 instead of params send whole vector3 just add nil to x y z
  20. Example Usage:
  21.  
  22. two
  23. -- client side only
  24.  
  25. local VORPutils = {}
  26.  
  27. TriggerEvent("getUtils", function(utils)
  28. VORPutils = utils
  29. end)
  30.  
  31. Citizen.CreateThread(function()
  32.  
  33. local blip = VORPutils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z, vector3 or nil)
  34. end)
  35. Get Raw Blip
  36. Client Side Only
  37. If you want to use any natives that are not yet included, you can utilize the raw blip.
  38.  
  39. two
  40. -- client side only
  41. local VORPutils = {}
  42.  
  43. TriggerEvent("getUtils", function(utils)
  44. VORPutils = utils
  45. end)
  46.  
  47. Citizen.CreateThread(function()
  48. local blip = VORPutils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z,vector3 or nil)
  49.  
  50. local rawblip = blip.rawblip
  51. -- OR
  52. -- local rawblip = blip:Get()
  53.  
  54. -- use rawblip with any other native.
  55. end)
  56. Delete a Blip
  57. Client Side Only
  58. Delete a marker (blip) on the players map
  59.  
  60. two
  61. -- client side only
  62. local VORPutils = {}
  63.  
  64. TriggerEvent("getUtils", function(utils)
  65. VORPutils = utils
  66. end)
  67.  
  68. Citizen.CreateThread(function()
  69. local blip = VORPutils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z,vecotr3 or nil)
  70.  
  71. blip:Remove()
  72. -- OR
  73. --- VORPutils.Blips:RemoveBlip(blip.rawblip)
  74. end)
  75. Add Radius to Blip
  76. Client Side Only
  77. Create a Radius blip
  78.  
  79. Parameter Description
  80. radius A decimal radius
  81. bliphahashsh The hashname of the blip (found here) [Optional, will default to -1282792512]
  82. Example Usage:
  83.  
  84. two
  85. -- client side only
  86.  
  87. local VORPutils = {}
  88.  
  89. TriggerEvent("getUtils", function(utils)
  90. VORPutils = utils
  91. end)
  92.  
  93. Citizen.CreateThread(function()
  94. local blip = VORPutils.Blips:SetBlip('Gift', 'blip_special_series_1', 0.2, x, y, z,vector3 or nil)
  95.  
  96. blip:AddRadius(64.0, -1282792512)
  97. -- OR
  98. -- VorpUtils.Blips:AddRadius(64.0, x, y, z, -1282792512)
  99. end)
  100. Prompts
  101. You can leverage Vorps built in function for easy in-game prompts.
  102.  
  103. Setup a Prompt Group
  104. Client Side Only
  105. This sets up the Prompt Group, which will allow you to attach future prompts to this group so that they can be displayed. This is required.
  106.  
  107. Example Usage:
  108.  
  109. two
  110. -- client side only
  111. local VORPutils = {}
  112.  
  113. TriggerEvent("getUtils", function(utils)
  114. VORPutils = utils
  115. end)
  116.  
  117. Citizen.CreateThread(function()
  118. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  119. end)
  120. Register Prompt
  121. Client Side Only
  122. Once you have the Prompt Group setup, you can now register a prompt to display within the group.
  123.  
  124. Parameter Description
  125. title What the Prompt group will display next to the press button
  126. button The hash key (found here)
  127. enabled If 0 you cannot click, if 1 you can click
  128. visible If 0 you cannot see the prompt, if 1 you can see the group
  129. pulsing If true prompt will urgently pulse, if false it will not
  130. mode What kind of prompt. (Options: click, hold, customhold, mash, timed)
  131. options Extra Options for the Mode you select. (See Mode Options below)
  132. Modes Options
  133.  
  134. Mode Key Options example
  135. click None None None
  136. hold timedeventhash SHORT_TIMED_EVENT_MP, SHORT_TIMED_EVENT, MEDIUM_TIMED_EVENT, LONG_TIMED_EVENT, RUSTLING_CALM_TIMING, PLAYER_FOCUS_TIMING, PLAYER_REACTION_TIMING
  137. customhold holdtime Miliseconds
  138. mash mashamount > 0
  139. timed depletiontime Miliseconds
  140. PromptGroup:RegisterPrompt(title, button, enabled, visible, pulsing, mode, options)
  141.  
  142. Example Usage:
  143.  
  144. two
  145. -- client side only
  146.  
  147. local VORPutils = {}
  148.  
  149. TriggerEvent("getUtils", function(utils)
  150. VORPutils = utils
  151. end)
  152.  
  153. Citizen.CreateThread(function()
  154. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  155.  
  156. local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
  157.  
  158. while true do
  159. Citizen.Wait(0)
  160. end
  161. end)
  162. Display Prompt Group
  163. Client Side Only
  164. Now that you have a Group setup and a registered Prompt, you can now display the group!
  165.  
  166. Parameter Description
  167. text Text to display under all the prompts
  168. PromptGroup:ShowGroup(text)
  169.  
  170. Example Usage:
  171.  
  172. two
  173. -- client side only
  174.  
  175. local VORPutils = {}
  176.  
  177. TriggerEvent("getUtils", function(utils)
  178. VORPutils = utils
  179. end)
  180.  
  181. Citizen.CreateThread(function()
  182. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  183.  
  184. local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
  185.  
  186. while true do
  187. Citizen.Wait(0)
  188. PromptGroup:ShowGroup("My first prompt group") --Show your prompt group
  189. end
  190. end)
  191. Handle Prompt Completion Events
  192. Client Side Only
  193. You can trigger code when a prompt has a completion event triggered (Example: clicked, held, etc)
  194.  
  195. Parameter Description
  196. hideoncomplete Some Options may hide or disapear when completed, Set this to false to not hide. This will default to true if nothing is entered
  197. firstprompt:HasCompleted()
  198.  
  199. Example Usage:
  200.  
  201. two
  202. -- client side only
  203.  
  204. local VORPutils = {}
  205.  
  206. TriggerEvent("getUtils", function(utils)
  207. VORPutils = utils
  208. end)
  209.  
  210. Citizen.CreateThread(function()
  211. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  212.  
  213. local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
  214.  
  215. while true do
  216. Citizen.Wait(0)
  217.  
  218. --Show your prompt group
  219. PromptGroup:ShowGroup("My first prompt group")
  220.  
  221. -- Lets listed for the prompt click and enact some code!
  222. if firstprompt:HasCompleted() then
  223. print("First Prompt Completed!")
  224. end
  225. end
  226. end)
  227. Handle Prompt Failure Events
  228. Client Side Only
  229. You can trigger code when a prompt has a failure event triggered (Example: timed, mashed)
  230.  
  231. Parameter Description
  232. hideoncomplete Some Options may hide or disapear when completed, Set this to false to not hide. This will default to true if nothing is entered
  233. firstprompt:HasFailed()
  234.  
  235. Example Usage:
  236.  
  237. two
  238. -- client side only
  239.  
  240. local VORPutils = {}
  241.  
  242. TriggerEvent("getUtils", function(utils)
  243. VORPutils = utils
  244. end)
  245.  
  246. Citizen.CreateThread(function()
  247. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  248.  
  249. local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
  250.  
  251. while true do
  252. Citizen.Wait(0)
  253.  
  254. --Show your prompt group
  255. PromptGroup:ShowGroup("My first prompt group")
  256.  
  257. -- Lets listed for the prompt click and enact some code!
  258. if firstprompt:HasCompleted() then
  259. print("First Prompt Completed!")
  260. end
  261.  
  262. if firstprompt:HasFailed() then
  263. print("First Prompt Failed!")
  264. end
  265. end
  266. end)
  267. Delete Prompt
  268. Client Side Only
  269. Remove a prompt completely
  270.  
  271. firstprompt:DeletePrompt()
  272.  
  273. Example Usage:
  274.  
  275. two
  276. -- client side only
  277.  
  278. local VORPutils = {}
  279.  
  280. TriggerEvent("getUtils", function(utils)
  281. VORPutils = utils
  282. end)
  283.  
  284. Citizen.CreateThread(function()
  285. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  286.  
  287. local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
  288.  
  289. while true do
  290. Citizen.Wait(0)
  291.  
  292. --Show your prompt group
  293. PromptGroup:ShowGroup("My first prompt group")
  294.  
  295. Wait(3000)
  296.  
  297. firstprompt:DeletePrompt()
  298. end
  299. end)
  300. Toggle Prompt Visibility
  301. Client Side Only
  302. Make a prompt visible or hidden
  303.  
  304. Parameter Description
  305. toggle true or false; true = visible, false = hidden
  306. firstprompt:TogglePrompt(toggle)
  307.  
  308. Example Usage:
  309.  
  310. two
  311. -- client side only
  312.  
  313. local VORPutils = {}
  314.  
  315. TriggerEvent("getUtils", function(utils)
  316. VORPutils = utils
  317. end)
  318.  
  319. Citizen.CreateThread(function()
  320. local PromptGroup = VORPutils.Prompts:SetupPromptGroup() --Setup Prompt Group
  321.  
  322. local firstprompt = PromptGroup:RegisterPrompt("Press Me", 0x4CC0E2FE, 1, 1, true, 'hold', {timedeventhash = "MEDIUM_TIMED_EVENT"}) --Register your first prompt
  323.  
  324. while true do
  325. Citizen.Wait(0)
  326.  
  327. --Show your prompt group
  328. PromptGroup:ShowGroup("My first prompt group")
  329.  
  330. Wait(3000)
  331.  
  332. firstprompt:TogglePrompt(false)
  333. end
  334. end)
  335. Pedestrians (Peds)
  336. You can leverage Vorps built in function for easy spawn and manipulate in-game pedestrian entities.
  337.  
  338. Create Ped
  339. Client Side Only
  340. This will spawn a pedestrian in your game world
  341.  
  342. Parameter Description
  343. modelhash The hash of the model you want the ped to be
  344. x x world position coordinate
  345. and y world position coordinate
  346. With z world position coordinate
  347. heading The heading of the ped (Which way it is facing)
  348. location Where to spawn ped. (world, vehicle, mount)
  349. safeground Should the ped spawn in a known ok location (default true, disable for more dine accuracy of ped placement)
  350. options Extra Options for the Location you select. (See Mode Options below)
  351. Modes Options
  352.  
  353. Location Key Options example
  354. world None None None
  355. vehicle vehicle vehicle entity
  356. vehicle seat VS_ANY_PASSENGER, VS_DRIVER, VS_FRONT_RIGHT, VS_BACK_LEFT, VS_BACK_RIGHT, VS_EXTRA_LEFT_1, VS_EXTRA_RIGHT_1, VS_EXTRA_LEFT_2, VS_EXTRA_RIGHT_2, VS_EXTRA_LEFT_3, VS_EXTRA_RIGHT_3, VS_NUM_SEATS
  357. mount mount mount entity
  358. VORPutils.Peds:Create()
  359.  
  360. Example Usage:
  361.  
  362. two
  363. -- client side only
  364.  
  365. local VORPutils = {}
  366.  
  367. TriggerEvent("getUtils", function(utils)
  368. VORPutils = utils
  369. end)
  370.  
  371. Citizen.CreateThread(function()
  372. local coords = {
  373. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  374. }
  375.  
  376. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false, isnetwork or false)
  377. end)
  378. Freeze Ped
  379. Client Side Only
  380. Freeze a ped where they stand
  381.  
  382. Parameter Description
  383. state freeze or unfreeze (true/false), default true
  384. ped:Freeze()
  385.  
  386. Example Usage:
  387.  
  388. two
  389. -- client side only
  390.  
  391. local VORPutils = {}
  392.  
  393. TriggerEvent("getUtils", function(utils)
  394. VORPutils = utils
  395. end)
  396.  
  397. Citizen.CreateThread(function()
  398. local coords = {
  399. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  400. }
  401.  
  402. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  403.  
  404. ped:Freeze()
  405. end)
  406. Invincible Ped
  407. Client Side Only
  408. Make a ped Invincible
  409.  
  410. Parameter Description
  411. state Invincible (true/false), default true
  412. ped:Invincible()
  413.  
  414. Example Usage:
  415.  
  416. two
  417. -- client side only
  418.  
  419. local VORPutils = {}
  420.  
  421. TriggerEvent("getUtils", function(utils)
  422. VORPutils = utils
  423. end)
  424.  
  425. Citizen.CreateThread(function()
  426. local coords = {
  427. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  428. }
  429.  
  430. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  431.  
  432. ped:Invincible()
  433. end)
  434. Ped CanBeDamaged
  435. Client Side Only
  436. Make a ped not take damage
  437.  
  438. Parameter Description
  439. state CanBeDamaged (true/false), default true
  440. ped:CanBeDamaged()
  441.  
  442. Example Usage:
  443.  
  444. two
  445. -- client side only
  446.  
  447. local VORPutils = {}
  448.  
  449. TriggerEvent("getUtils", function(utils)
  450. VORPutils = utils
  451. end)
  452.  
  453. Citizen.CreateThread(function()
  454. local coords = {
  455. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  456. }
  457.  
  458. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  459.  
  460. ped:CanBeDamaged()
  461. end)
  462. Set Ped Heading
  463. Client Side Only
  464. change the directon a ped is facing
  465.  
  466. Parameter Description
  467. head the game world direction to face
  468. ped:SetHeading()
  469.  
  470. Example Usage:
  471.  
  472. two
  473. -- client side only
  474.  
  475. local VORPutils = {}
  476.  
  477. TriggerEvent("getUtils", function(utils)
  478. VORPutils = utils
  479. end)
  480.  
  481. Citizen.CreateThread(function()
  482. local coords = {
  483. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  484. }
  485.  
  486. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  487.  
  488. ped:SetHeading(0)
  489. end)
  490. Set Ped Seeing Range
  491. Client Side Only
  492. Change how far the ped can see
  493.  
  494. Parameter Description
  495. range 0.0 - 100.0
  496. ped:SeeingRange()
  497.  
  498. Example Usage:
  499.  
  500. two
  501. -- client side only
  502.  
  503. local VORPutils = {}
  504.  
  505. TriggerEvent("getUtils", function(utils)
  506. VORPutils = utils
  507. end)
  508.  
  509. Citizen.CreateThread(function()
  510. local coords = {
  511. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  512. }
  513.  
  514. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  515.  
  516. ped:SeeingRange(70.0)
  517. end)
  518. Set Ped Hearing Range
  519. Client Side Only
  520. Change how far the ped can hear
  521.  
  522. Parameter Description
  523. range 0.0 - 100.0
  524. ped:HearingRange()
  525.  
  526. Example Usage:
  527.  
  528. two
  529. -- client side only
  530.  
  531. local VORPutils = {}
  532.  
  533. TriggerEvent("getUtils", function(utils)
  534. VORPutils = utils
  535. end)
  536.  
  537. Citizen.CreateThread(function()
  538. local coords = {
  539. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  540. }
  541.  
  542. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  543.  
  544. ped:HearingRange(80.0)
  545. end)
  546. Set Ped Can Mount
  547. Client Side Only
  548. Change if a ped can mount something.
  549.  
  550. Parameter Description
  551. state true/false
  552. ped:CanBeMounted(true)
  553.  
  554. Example Usage:
  555.  
  556. two
  557. -- client side only
  558.  
  559. local VORPutils = {}
  560.  
  561. TriggerEvent("getUtils", function(utils)
  562. VORPutils = utils
  563. end)
  564.  
  565. Citizen.CreateThread(function()
  566. local coords = {
  567. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  568. }
  569.  
  570. local ped = VORPutils.Peds:Create('u_f_m_tumgeneralstoreowner_01', coords.x, coords.y, coords.z, 0, 'world', false)
  571.  
  572. ped:CanBeMounted(true)
  573. end)
  574. Add Ped to Group
  575. Client Side Only
  576. Add ped to a group
  577.  
  578. Parameter Description
  579. group index of the group to add to
  580. ped:AddPedToGroup(group)
  581.  
  582. Example Usage:
  583.  
  584. two
  585. -- client side only
  586.  
  587. local VORPutils = {}
  588.  
  589. TriggerEvent("getUtils", function(utils)
  590. VORPutils = utils
  591. end)
  592.  
  593. Citizen.CreateThread(function()
  594. local coords = {
  595. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  596. }
  597.  
  598. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  599.  
  600. ped:AddPedToGroup(GetPedGroupIndex(PlayerPedId()))
  601.  
  602. end)
  603. Clear a ped task
  604. Client Side Only
  605. Clear any active tasks
  606.  
  607. ped:ClearTasks()
  608.  
  609. Example Usage:
  610.  
  611. two
  612. -- client side only
  613.  
  614. local VORPutils = {}
  615.  
  616. TriggerEvent("getUtils", function(utils)
  617. VORPutils = utils
  618. end)
  619.  
  620. Citizen.CreateThread(function()
  621. local coords = {
  622. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  623. }
  624.  
  625. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  626.  
  627. ped:ClearTasks()
  628.  
  629. end)
  630. Get Task Status
  631. Client Side Only
  632. Check the status of a ped task
  633.  
  634. ped:GetTaskStatus(taskid)
  635.  
  636. Example Usage:
  637.  
  638. two
  639. -- client side only
  640.  
  641. local VORPutils = {}
  642.  
  643. TriggerEvent("getUtils", function(utils)
  644. VORPutils = utils
  645. end)
  646.  
  647. Citizen.CreateThread(function()
  648. local coords = {
  649. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  650. }
  651.  
  652. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  653.  
  654. while (ped:GetTaskStatus(0x4924437d) ~= 8) do
  655. Wait(1000)
  656. end
  657.  
  658. print("Ped task done!")
  659.  
  660. end)
  661. Follow to offset
  662. Client Side Only
  663. Add ped to a group
  664.  
  665. Parameter Description
  666. ask id of ped to follow
  667. ped:FollowToOffsetOfEntity(pedid)
  668.  
  669. Example Usage:
  670.  
  671. two
  672. -- client side only
  673.  
  674. local VORPutils = {}
  675.  
  676. TriggerEvent("getUtils", function(utils)
  677. VORPutils = utils
  678. end)
  679.  
  680. Citizen.CreateThread(function()
  681. local coords = {
  682. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  683. }
  684.  
  685. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  686.  
  687. ped:FollowToOffsetOfEntity(PlayerPedId(), 0.0, -1.5, 0.0, 1.0, -1, 10, 1, 1)
  688.  
  689. end)
  690. Follow to offset
  691. Client Side Only
  692. Add ped to a group
  693.  
  694. Parameter Description
  695. skinhash hash of skin meta cloth
  696. ped:ChangeOutfit(skinhash)
  697.  
  698. Example Usage:
  699.  
  700. two
  701. -- client side only
  702.  
  703. local VORPutils = {}
  704.  
  705. TriggerEvent("getUtils", function(utils)
  706. VORPutils = utils
  707. end)
  708.  
  709. Citizen.CreateThread(function()
  710. local coords = {
  711. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  712. }
  713.  
  714. local ped = VORPutils.Peds:Create('A_C_DogBluetickCoonhound_01', coords.x, coords.y, coords.z, 0, 'world', false)
  715.  
  716. ped:ChangeOutfit(0xDC567AF8)
  717.  
  718. end)
  719. Set Ped Blip
  720. Client Side Only
  721. Set a blip on ped that follows
  722.  
  723. Parameter Description
  724. blipash What the blip should show on the map
  725. title What the blip should say
  726. ped:SetBlip(bliphash, title)
  727.  
  728. Example Usage:
  729.  
  730. two
  731. -- client side only
  732.  
  733. local VORPutils = {}
  734.  
  735. TriggerEvent("getUtils", function(utils)
  736. VORPutils = utils
  737. end)
  738.  
  739. Citizen.CreateThread(function()
  740. local coords = {
  741. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  742. }
  743.  
  744. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  745.  
  746. ped:SetBlip(953018525, 'Person')
  747. end)
  748. Give Ped Weapon
  749. Client Side Only
  750. Give a ped a weapon (they will only use it if they are set to be agro)
  751.  
  752. Parameter Description
  753. weaponhash What the weapon will be
  754. ammocount how much ammo
  755. forceinhand Force the weapon to be held
  756. forceinholster Force the weapon to be holstered
  757. attachpoint Where to attach to the body
  758. allowmultiplecopies How many of this gun can the ped have
  759. ignoreunlocks Ingore unlockables
  760. permanentdegredation permanent degredation
  761. ped:GiveWeapon(weaponhash, ammocount, forceinhand, forceinholster, attachpoint, allowmultiplecopies, ignoreunlocks, permanentdegredation)
  762.  
  763. Example Usage:
  764.  
  765. two
  766. -- client side only
  767.  
  768. local VORPutils = {}
  769.  
  770. TriggerEvent("getUtils", function(utils)
  771. VORPutils = utils
  772. end)
  773.  
  774. Citizen.CreateThread(function()
  775. local coords = {
  776. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  777. }
  778.  
  779. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  780. ped:AttackTarget(PlayerPedId())
  781.  
  782. ped:GiveWeapon(0x64356159, 500, true, true, 3, false, true, true)
  783. end)
  784. Set Ped Flee Attribute
  785. Client Side Only
  786. Enable or disable pedestrian flee attributes
  787.  
  788. Parameter Description
  789. flag What flee attribute to enable/disable
  790. enabled is active of not (true/false)
  791. ped:FleeAtribute(flag, enabled)
  792.  
  793. Example Usage:
  794.  
  795. two
  796. -- client side only
  797.  
  798. local VORPutils = {}
  799.  
  800. TriggerEvent("getUtils", function(utils)
  801. VORPutils = utils
  802. end)
  803.  
  804. Citizen.CreateThread(function()
  805. local coords = {
  806. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  807. }
  808.  
  809. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  810.  
  811. ped:FleeAtribute('DISABLE_ENTER_VEHICLES', true)
  812. end)
  813. Set Ped Combat Attributes
  814. Client Side Only
  815. Enable or disable pedestrian combat attributes
  816.  
  817. Parameter Description
  818. attributes This is a list of attributes you want to change Example { {flag = 1, enabled = false}, {flag = 2, enabled = false} }
  819. attackrange The distance for aggro
  820. abilitylevel how good or not the ped is at fighting
  821. movement What kind of movement (0: Stationary (Will just stand in place), 1: Defensive (Will try to find cover and very likely to blind fire), 2: Offensive (Will attempt to charge at enemy but take cover as well), 3: Suicidal Offensive (Will try to flank enemy in a suicidal attack))
  822. ped:SetPedCombatAttributes(attributes, attackrange, abilitylevel, movement)
  823.  
  824. Example Usage:
  825.  
  826. two
  827. -- client side only
  828.  
  829. local VORPutils = {}
  830.  
  831. TriggerEvent("getUtils", function(utils)
  832. VORPutils = utils
  833. end)
  834.  
  835. Citizen.CreateThread(function()
  836. local coords = {
  837. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  838. }
  839.  
  840. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  841.  
  842. ped:SetPedCombatAttributes({
  843. {flag = 0, enabled = false}
  844. }, 1, 0, 2)
  845. end)
  846. Set Ped Combat Style
  847. Client Side Only
  848. Set the pedestrians combat style
  849.  
  850. Parameter Description
  851. combathash The combat style for the ped
  852. duration How long the ped has this combat style
  853. ped:SetCombatStyle(combathash, duration)
  854.  
  855. Example Usage:
  856.  
  857. two
  858. -- client side only
  859.  
  860. local VORPutils = {}
  861.  
  862. TriggerEvent("getUtils", function(utils)
  863. VORPutils = utils
  864. end)
  865.  
  866. Citizen.CreateThread(function()
  867. local coords = {
  868. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  869. }
  870.  
  871. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  872.  
  873. ped:SetCombatStyle('SituationAllStop', 240.0)
  874. end)
  875. Clear Ped Combat Style
  876. Client Side Only
  877. Clear the pedestrians combat style
  878.  
  879. ped:ClearCombatStyle()
  880.  
  881. Example Usage:
  882.  
  883. two
  884. -- client side only
  885.  
  886. local VORPutils = {}
  887.  
  888. TriggerEvent("getUtils", function(utils)
  889. VORPutils = utils
  890. end)
  891.  
  892. Citizen.CreateThread(function()
  893. local coords = {
  894. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  895. }
  896.  
  897. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  898.  
  899. ped:ClearCombatStyle()
  900. end)
  901. Attack Target
  902. Client Side Only
  903. Set a target for the ped to attack
  904.  
  905. Parameter Description
  906. target the ped to attack (can be player)
  907. style How long the ped has this combat style (GUARD, COMBAT_ANIMAL, LAW, LAW_SHERIFF)
  908. ped:AttackTarget(target, style)
  909.  
  910. Example Usage:
  911.  
  912. two
  913. -- client side only
  914.  
  915. local VORPutils = {}
  916.  
  917. TriggerEvent("getUtils", function(utils)
  918. VORPutils = utils
  919. end)
  920.  
  921. Citizen.CreateThread(function()
  922. local coords = {
  923. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  924. }
  925.  
  926. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  927.  
  928. ped:AttackTarget(PlayerPedId(), 'LAW')
  929. end)
  930. Remove Ped
  931. Client Side Only
  932. Remove a Ped
  933.  
  934. ped:Remove()
  935.  
  936. Example Usage:
  937.  
  938. two
  939. -- client side only
  940.  
  941. local VORPutils = {}
  942.  
  943. TriggerEvent("getUtils", function(utils)
  944. VORPutils = utils
  945. end)
  946.  
  947. Citizen.CreateThread(function()
  948. local coords = {
  949. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  950. }
  951.  
  952. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  953.  
  954. ped:Remove()
  955. end)
  956. Get Ped
  957. Client Side Only
  958. If there are natives this util does not yet support, you can use this to get the ped to utilize against any native.
  959.  
  960. ped:GetPed()
  961.  
  962. Example Usage:
  963.  
  964. two
  965. -- client side only
  966.  
  967. local VORPutils = {}
  968.  
  969. TriggerEvent("getUtils", function(utils)
  970. VORPutils = utils
  971. end)
  972.  
  973. Citizen.CreateThread(function()
  974. local coords = {
  975. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  976. }
  977.  
  978. local ped = VORPutils.Peds:Create('s_m_m_valdeputy_01', coords.x, coords.y, coords.z, 0, 'world', false)
  979.  
  980. local rawped = ped:GetPed()
  981.  
  982. -- Use rawped with whatever native required the ped entity
  983. end)
  984. Objects
  985. You can leverage Vorps built in function for easy spawn and manipulate in-game Object entities.
  986.  
  987. Create Object
  988. Client Side Only
  989. This will spawn an object in your game world
  990.  
  991. Parameter Description
  992. modelhash The hash of the model you want the ped to be
  993. x x world position coordinate
  994. and y world position coordinate
  995. With z world position coordinate
  996. heading The heading of the ped (Which way it is facing)
  997. networked Where to spawn ped. (world, vehicle, mount)
  998. method standard or custom - Standard will run place on ground and a few other house keeping
  999. VORPutils.Objects:Create()
  1000.  
  1001. Example Usage:
  1002.  
  1003. two
  1004. -- client side only
  1005.  
  1006. local VORPutils = {}
  1007.  
  1008. TriggerEvent("getUtils", function(utils)
  1009. VORPutils = utils
  1010. end)
  1011.  
  1012. Citizen.CreateThread(function()
  1013. local coords = {
  1014. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1015. }
  1016.  
  1017. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1018. end)
  1019. Pickup Light
  1020. Client Side Only
  1021. Add a light to the object
  1022.  
  1023. Parameter Description
  1024. state True/False
  1025. obj:PickupLight(state)
  1026.  
  1027. Example Usage:
  1028.  
  1029. two
  1030. -- client side only
  1031.  
  1032. local VORPutils = {}
  1033.  
  1034. TriggerEvent("getUtils", function(utils)
  1035. VORPutils = utils
  1036. end)
  1037.  
  1038. Citizen.CreateThread(function()
  1039. local coords = {
  1040. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1041. }
  1042.  
  1043. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1044.  
  1045. obj:PickupLight(true)
  1046. end)
  1047. Freeze
  1048. Client Side Only
  1049. Freeze Object
  1050.  
  1051. Parameter Description
  1052. state True/False
  1053. obj:Freeze(state)
  1054.  
  1055. Example Usage:
  1056.  
  1057. two
  1058. -- client side only
  1059.  
  1060. local VORPutils = {}
  1061.  
  1062. TriggerEvent("getUtils", function(utils)
  1063. VORPutils = utils
  1064. end)
  1065.  
  1066. Citizen.CreateThread(function()
  1067. local coords = {
  1068. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1069. }
  1070.  
  1071. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1072.  
  1073. obj:Freeze(true)
  1074. end)
  1075. Set Heading
  1076. Client Side Only
  1077. Set the heading of an object
  1078.  
  1079. Parameter Description
  1080. heading number coord relative to the game world
  1081. obj:SetHeading(heading)
  1082.  
  1083. Example Usage:
  1084.  
  1085. two
  1086. -- client side only
  1087.  
  1088. local VORPutils = {}
  1089.  
  1090. TriggerEvent("getUtils", function(utils)
  1091. VORPutils = utils
  1092. end)
  1093.  
  1094. Citizen.CreateThread(function()
  1095. local coords = {
  1096. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1097. }
  1098.  
  1099. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1100.  
  1101. obj:SetHeading(0)
  1102. end)
  1103. Place On Ground
  1104. Client Side Only
  1105. place the object on the groun properly
  1106.  
  1107. Parameter Description
  1108. state true/false
  1109. obj:PlaceOnGround(state)
  1110.  
  1111. Example Usage:
  1112.  
  1113. two
  1114. -- client side only
  1115.  
  1116. local VORPutils = {}
  1117.  
  1118. TriggerEvent("getUtils", function(utils)
  1119. VORPutils = utils
  1120. end)
  1121.  
  1122. Citizen.CreateThread(function()
  1123. local coords = {
  1124. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1125. }
  1126.  
  1127. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1128.  
  1129. obj:PlaceOnGround(true)
  1130. end)
  1131. Set As Mission
  1132. Client Side Only
  1133. The engine will keep object when players leave the area
  1134.  
  1135. Parameter Description
  1136. state true/false
  1137. obj:SetAsMission(state)
  1138.  
  1139. Example Usage:
  1140.  
  1141. two
  1142. -- client side only
  1143.  
  1144. local VORPutils = {}
  1145.  
  1146. TriggerEvent("getUtils", function(utils)
  1147. VORPutils = utils
  1148. end)
  1149.  
  1150. Citizen.CreateThread(function()
  1151. local coords = {
  1152. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1153. }
  1154.  
  1155. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1156.  
  1157. obj:SetAsMission(true)
  1158. end)
  1159. Set As No Longer Needed
  1160. Client Side Only
  1161. The engine will remove when players leave the area
  1162.  
  1163. obj:SetAsNoLongerNeeded()
  1164.  
  1165. Example Usage:
  1166.  
  1167. two
  1168. -- client side only
  1169.  
  1170. local VORPutils = {}
  1171.  
  1172. TriggerEvent("getUtils", function(utils)
  1173. VORPutils = utils
  1174. end)
  1175.  
  1176. Citizen.CreateThread(function()
  1177. local coords = {
  1178. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1179. }
  1180.  
  1181. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1182.  
  1183. obj:SetAsNoLongerNeeded()
  1184. end)
  1185. Invincible
  1186. Client Side Only
  1187. Set object as invincible
  1188.  
  1189. Parameter Description
  1190. state true/false
  1191. obj:Invincible(state)
  1192.  
  1193. Example Usage:
  1194.  
  1195. two
  1196. -- client side only
  1197.  
  1198. local VORPutils = {}
  1199.  
  1200. TriggerEvent("getUtils", function(utils)
  1201. VORPutils = utils
  1202. end)
  1203.  
  1204. Citizen.CreateThread(function()
  1205. local coords = {
  1206. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1207. }
  1208.  
  1209. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1210.  
  1211. obj:Invincible(true)
  1212. end)
  1213. Horse Jumpable
  1214. Client Side Only
  1215. Sets object as not jumpable by horse.
  1216.  
  1217. Parameter Description
  1218. state true/false
  1219. obj:SetNotHorseJumpable(state)
  1220.  
  1221. Example Usage:
  1222.  
  1223. two
  1224. -- client side only
  1225.  
  1226. local VORPutils = {}
  1227.  
  1228. TriggerEvent("getUtils", function(utils)
  1229. VORPutils = utils
  1230. end)
  1231.  
  1232. Citizen.CreateThread(function()
  1233. local coords = {
  1234. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1235. }
  1236.  
  1237. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1238.  
  1239. obj:SetNotHorseJumpable(true)
  1240. end)
  1241. Remove
  1242. Client Side Only
  1243. Remove Object
  1244.  
  1245. obj:Remove()
  1246.  
  1247. Example Usage:
  1248.  
  1249. two
  1250. -- client side only
  1251.  
  1252. local VORPutils = {}
  1253.  
  1254. TriggerEvent("getUtils", function(utils)
  1255. VORPutils = utils
  1256. end)
  1257.  
  1258. Citizen.CreateThread(function()
  1259. local coords = {
  1260. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1261. }
  1262.  
  1263. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1264.  
  1265. Wait(5000)
  1266.  
  1267. obj:Remove()
  1268. end)
  1269. Get Object
  1270. Client Side Only
  1271. Remove Object
  1272.  
  1273. obj:GetObj()
  1274.  
  1275. Example Usage:
  1276.  
  1277. two
  1278. -- client side only
  1279.  
  1280. local VORPutils = {}
  1281.  
  1282. TriggerEvent("getUtils", function(utils)
  1283. VORPutils = utils
  1284. end)
  1285.  
  1286. Citizen.CreateThread(function()
  1287. local coords = {
  1288. z = 118.38395690917968, y = 802.531982421875, x = -279.46728515625
  1289. }
  1290.  
  1291. local obj = VORPutils.Objects:Create('p_package09', coords.x, coords.y, coords.z, 0, true, 'standard')
  1292.  
  1293. Wait(5000)
  1294.  
  1295. local tobj = obj:GetObj()
  1296. end)
  1297. DataView
  1298. A DataView utility
  1299.  
  1300. Example Usage:
  1301.  
  1302. two
  1303. -- client side only
  1304. local view = DataView.ArrayBuffer(512)
  1305. if Citizen.InvokeNative(0x79923CD21BECE14E, 1, view:Buffer(), Citizen.ReturnResultAnyway()) then
  1306. local dlc = {
  1307. validCheck = view:GetInt64(0),
  1308. weaponHash = view:GetInt32(8),
  1309. val3 = view:GetInt64(16),
  1310. weaponCost = view:GetInt64(24),
  1311. ammoCost = view:GetInt64(32),
  1312. ammoType = view:GetInt64(40),
  1313. defaultClipSize = view:GetInt64(48),
  1314. nameLabel = view:GetFixedString(56, 64),
  1315. descLabel = view:GetFixedString(120, 64),
  1316. simpleDesc = view:GetFixedString(184, 64),
  1317. upperCaseName = view:GetFixedString(248, 64),
  1318. }
  1319. end
  1320. Files
  1321. An easy to use file manipulation system.
  1322.  
  1323. Open
  1324. Server Side Only
  1325. Open a file from a given file path
  1326.  
  1327. Parameter Description
  1328. resourcename the string name of your resource
  1329. filepath the path to the file you with to open or create
  1330. VORPutils.Files:Open(resourcename, filepath))
  1331.  
  1332. Example Usage:
  1333.  
  1334. two
  1335. -- Server side
  1336.  
  1337. local VORPutils = {}
  1338.  
  1339. TriggerEvent("getUtils", function(utils)
  1340. VORPutils = utils
  1341. end)
  1342.  
  1343. Citizen.CreateThread(function()
  1344. local file = VORPutils.Files:Open(GetCurrentResourceName(), 'data.txt')
  1345. end)
  1346. Read
  1347. Server Side Only
  1348. Read the file that you have openned.
  1349.  
  1350. Parameter Description
  1351. mode if nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly
  1352. file:Read(mode)
  1353.  
  1354. Example Usage:
  1355.  
  1356. two
  1357. -- Server side
  1358.  
  1359. local VORPutils = {}
  1360.  
  1361. TriggerEvent("getUtils", function(utils)
  1362. VORPutils = utils
  1363. end)
  1364.  
  1365. Citizen.CreateThread(function()
  1366. local file = VORPutils.Files:Open(GetCurrentResourceName(), 'data.txt')
  1367. local filedata = file:Read()
  1368. end)
  1369. Save
  1370. Server Side Only
  1371. Save data to the file that you have opened.
  1372.  
  1373. Parameter Description
  1374. content The data you with to save to the file
  1375. mode if nothing, it will default to standard save, modes are 'standard' or 'table'. Table will store a table to the file properly
  1376. file:Save(content, mode)
  1377.  
  1378. Example Usage:
  1379.  
  1380. two
  1381. -- Server side
  1382.  
  1383. local VORPutils = {}
  1384.  
  1385. TriggerEvent("getUtils", function(utils)
  1386. VORPutils = utils
  1387. end)
  1388.  
  1389. Citizen.CreateThread(function()
  1390. local file = VORPutils.Files:Open(GetCurrentResourceName(), 'data.txt')
  1391. local filedata = file:Read()
  1392.  
  1393. local data = "Some Awesome stuff!"
  1394.  
  1395. file:Save(data)
  1396. end)
  1397. Update
  1398. Server Side Only
  1399. Instead of needing to open and save a file, you can update data directly to the file.
  1400.  
  1401. Parameter Description
  1402. content The data you with to save to the file
  1403. mode if nothing, it will default to standard save, modes are 'standard' or 'table'. Table will store a table to the file properly
  1404. file:Update(content, mode)
  1405.  
  1406. Example Usage:
  1407.  
  1408. two
  1409. -- Server side
  1410.  
  1411. local VORPutils = {}
  1412.  
  1413. TriggerEvent("getUtils", function(utils)
  1414. VORPutils = utils
  1415. end)
  1416.  
  1417. Citizen.CreateThread(function()
  1418. local file = VORPutils.Files:Open(GetCurrentResourceName(), 'data.txt')
  1419. file:Update("Some Awesome stuff!")
  1420. end)
  1421. Lazy Functions
  1422. Server Side Only
  1423. There is a way to use these functions without needing to call the Open() function, this can be used for quick usage or prototyping, but is non-optimal and slower than the above.
  1424.  
  1425. Load File
  1426. Server Side Only
  1427. Read the file that you have openned.
  1428.  
  1429. Parameter Description
  1430. resourcename Name of the resource
  1431. filepath path to the file you with to load
  1432. mode if nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly
  1433. VORPutils.Files:Load(resourcename, filepath, mode)
  1434.  
  1435. Example Usage:
  1436.  
  1437. two
  1438. -- Server side
  1439.  
  1440. local VORPutils = {}
  1441.  
  1442. TriggerEvent("getUtils", function(utils)
  1443. VORPutils = utils
  1444. end)
  1445. -- Lazy functions, not as optimized
  1446. Citizen.CreateThread(function()
  1447. local file = VORPutils.Files:Load(GetCurrentResourceName(), 'data.txt')
  1448. end)
  1449. Save File
  1450. Server Side Only
  1451. Save the file that you have openned.
  1452.  
  1453. Parameter Description
  1454. resourcename Name of the resource
  1455. filepath path to the file you with to load
  1456. content data to save to the file
  1457. mode if nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly
  1458. VORPutils.Files:Load(resourcename, filepath, mode)
  1459.  
  1460. Example Usage:
  1461.  
  1462. two
  1463. -- Server side
  1464.  
  1465. local VORPutils = {}
  1466.  
  1467. TriggerEvent("getUtils", function(utils)
  1468. VORPutils = utils
  1469. end)
  1470. -- Lazy functions, not as optimized
  1471. Citizen.CreateThread(function()
  1472. VORPutils.Files:Save(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
  1473. end)
  1474. Update File
  1475. Server Side Only
  1476. Update the file that you have openned.
  1477.  
  1478. Parameter Description
  1479. resourcename Name of the resource
  1480. filepath path to the file you with to load
  1481. content data to update to the file
  1482. mode if nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly
  1483. VORPutils.Files:Update(resourcename, filepath, content, mode)
  1484.  
  1485. Example Usage:
  1486.  
  1487. two
  1488. -- Server side
  1489.  
  1490. local VORPutils = {}
  1491.  
  1492. TriggerEvent("getUtils", function(utils)
  1493. VORPutils = utils
  1494. end)
  1495. -- Lazy functions, not as optimized
  1496. Citizen.CreateThread(function()
  1497. VORPutils.Files:Update(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
  1498. end)
  1499. Print Logs
  1500. Vorp Utils provides an enhanced print functionality to the default Lua.
  1501.  
  1502. Features
  1503. Table printing support
  1504. ANSI Color and text formatting support
  1505. Setup
  1506. two
  1507. -- Server and Client
  1508. local VORPutils = {}
  1509.  
  1510. TriggerEvent("getUtils", function(utils)
  1511. VORPutils = utils
  1512.  
  1513. print = VORPutils.Print:initialize(print) --Initial setup
  1514. end)
  1515.  
  1516.  
  1517.  
  1518. Citizen.CreateThread(function()
  1519. --Use print as you normally would.
  1520. print('%{bold} %{red}TEST', {
  1521. hello = "world"
  1522. })
  1523.  
  1524. -- Print Output: TEST, { "hello" = "world"}
  1525. end)
  1526. Colors
  1527. Colors and backgrounds can be used usilizing the %{attribute} format
  1528.  
  1529. Type format Description
  1530. Text Format % Make Text Font weight heavier
  1531. Text Color % Set back to default color
  1532. Text Color %
  1533. Text Color %
  1534. Text Color %
  1535. Text Color %
  1536. Text Color %{magenta} or %
  1537. Text Color %
  1538. Text Color %{gray} or %
  1539. Text Color %{lightgray} or %
  1540. Text Color %
  1541. Text Color %
  1542. Text Color %
  1543. Text Color %
  1544. Text Color %
  1545. Text Color %
  1546. Background Color %
  1547. Background Color %
  1548. Background Color %
  1549. Background Color %
  1550. Background Color %
  1551. Background Color %
  1552. Background Color %{highlight gray} or %
  1553. Background Color %{highlight lightgray} or %
  1554. Background Color %
  1555. Background Color %
  1556. Background Color %
  1557. Background Color %
  1558. Background Color %
  1559. Background Color %
  1560. Example Usage:
  1561.  
  1562. two
  1563. print('%{blue}moon over the rainbow')
  1564. image
  1565.  
  1566. Advanced Classes
  1567. Many Programming languages, including Lua, provide a method to use a programing methedology called classes.
  1568.  
  1569. Lua, unfortunately does this in a way that is very non-standard to other languages, and can make it a bit confusing for some. This is an attempt to make it more in-line with other languages.
  1570.  
  1571. Benefits
  1572. Classes are nice for developers as it allows you to have a single, contained context (self) for the class to utilize.
  1573.  
  1574. Example Usage:
  1575.  
  1576. two
  1577. -- Server and Client
  1578. local VORPutils = {}
  1579.  
  1580. TriggerEvent("getUtils", function(utils)
  1581. VORPutils = utils
  1582. end)
  1583.  
  1584. Citizen.CreateThread(function()
  1585. local myClass = VORPutils.General:CreateClass(function(setup, register)
  1586. -- Setup is a constructor, meaning it is used to setup your default variables than can then be used in the following fuctions.
  1587. setup({
  1588. message = "Initial Text"
  1589. })
  1590.  
  1591.  
  1592. -- return the functions that you wish to register to the class.
  1593. return {
  1594. ChangeText = function(self, t) --This can now be called anywhere as myClass:ChangeText(t)
  1595. -- self is always in the first paramater above, this is required to manipulate the setup data.
  1596. self.message = t
  1597. end,
  1598. GetText = function(self) --This can now be called anywhere as myClass:GetText()
  1599. return self.message
  1600. end
  1601. }
  1602. end)
  1603.  
  1604. print(myClass:GetText()) -- Prints: Initial Text
  1605.  
  1606. myClass:ChangeText('HELLO WORLD!')
  1607.  
  1608. print(myClass:GetText()) -- Prints: HELLO WORLD!
  1609. end
  1610. Destruction
  1611. Objects (ymaps) can have built in destruction thanks to the engines use of RayFire, which is a tool for dynamic destruction.
  1612.  
  1613. This allows for things like like bank walls being blown out, railroad bridge blown up, trees falling over, etc.
  1614.  
  1615. Note that they are not networked and you'll need to sync clients manually.
  1616.  
  1617. Get Destruction Object
  1618. Client Side Only
  1619. Get nearby RawFire map Objects
  1620.  
  1621. Parameter Description
  1622. x in-game x coordinate
  1623. and in-game y coordinate
  1624. With in-game z coordinate
  1625. radius the radius from the coordinate
  1626. objectname destruction object name with RayFire attached
  1627. VORPutils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
  1628.  
  1629. Example Usage:
  1630.  
  1631. two
  1632. -- Client
  1633. local VORPutils = {}
  1634.  
  1635. TriggerEvent("getUtils", function(utils)
  1636. VORPutils = utils
  1637. end)
  1638.  
  1639. RegisterCommand('trigger', function()
  1640. local object = VORPutils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
  1641. end)
  1642. Check if the Destruction Object Exists
  1643. Client Side Only
  1644. Check if the RayFire Destruction Object exists.
  1645.  
  1646. object:DoesExist()
  1647.  
  1648. Example Usage:
  1649.  
  1650. two
  1651. -- Client
  1652. local VORPutils = {}
  1653.  
  1654. TriggerEvent("getUtils", function(utils)
  1655. VORPutils = utils
  1656. end)
  1657.  
  1658. RegisterCommand('trigger', function()
  1659. local object = VORPutils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
  1660. if object:DoesExist() then
  1661. --Exists!
  1662. end
  1663. end)
  1664. Reset State
  1665. Client Side Only
  1666. Reset the RayFire Destruction Objects state.
  1667.  
  1668. object:resetState()
  1669.  
  1670. Example Usage:
  1671.  
  1672. two
  1673. -- Client
  1674. local VORPutils = {}
  1675.  
  1676. TriggerEvent("getUtils", function(utils)
  1677. VORPutils = utils
  1678. end)
  1679.  
  1680. RegisterCommand('trigger', function()
  1681. local object = VORPutils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
  1682. if object:DoesExist() then
  1683. object:resetState()
  1684. end
  1685. end)
  1686. Reset State
  1687. Client Side Only
  1688. Reset the RayFire Destruction Objects state.
  1689.  
  1690. Parameter Description
  1691. state the state of the object. (6 will trigger most objects)
  1692. object:resetState()
  1693.  
  1694. Example Usage:
  1695.  
  1696. two
  1697. -- Client
  1698. local VORPutils = {}
  1699.  
  1700. TriggerEvent("getUtils", function(utils)
  1701. VORPutils = utils
  1702. end)
  1703.  
  1704. RegisterCommand('trigger', function()
  1705. local object = VORPutils.Destruct:GetMapObject(GetEntityCoords(PlayerPedId()), 150.0, 'des_val_sheriff')
  1706. if object:DoesExist() then
  1707. object:resetState()
  1708.  
  1709. Wait(3000)
  1710.  
  1711. object:SetState(6)
  1712. end
  1713. end)
  1714. Render
  1715. Render is an API to help with in-world and on screen drawing. (Text, Sprites, etc.)
  1716.  
  1717. WorldToScreen
  1718. Client Side Only
  1719. Converts an in-world coordinate to a screen position
  1720.  
  1721. Parameter Description
  1722. pos (vector3) in-world position
  1723. Returns vector 2 screen coords.
  1724.  
  1725. Returns Bool if its on screen
  1726.  
  1727. object:WorldToScreen(vector3(x, y, z))
  1728.  
  1729. Example Usage:
  1730.  
  1731. two
  1732. -- Client
  1733. local VORPutils = {}
  1734.  
  1735. TriggerEvent("getUtils", function(utils)
  1736. VORPutils = utils
  1737. end)
  1738.  
  1739. RegisterCommand('trigger', function()
  1740. local coords, onscreen = VORPutils.Render:WorldToScreen(GetEntityCoords(PlayerPedId()))
  1741.  
  1742. print(coords.x, coords.y, onscreen)
  1743. end)
  1744. WorldToHud
  1745. Client Side Only
  1746. Converts in-world coordinate to a hud position (bounded to screen)
  1747.  
  1748. Parameter Description
  1749. pos (vector3) in-world position
  1750. Returns vector 2 screen coords
  1751.  
  1752. Returns Bool if its on screen
  1753.  
  1754. object:WorldToHud(vector3(x, y, z))
  1755.  
  1756. Example Usage:
  1757.  
  1758. two
  1759. -- Client
  1760. local VORPutils = {}
  1761.  
  1762. TriggerEvent("getUtils", function(utils)
  1763. VORPutils = utils
  1764. end)
  1765.  
  1766. RegisterCommand('trigger', function()
  1767. local coords, onscreen = VORPutils.Render:WorldToHud(GetEntityCoords(PlayerPedId()))
  1768.  
  1769. print(coords.x, coords.y, onscreen)
  1770. end)
  1771. DrawSprite
  1772. Client Side Only
  1773. Draw Sprites on screen
  1774.  
  1775. Parameter Description
  1776. pos (vector2) table containing x and y coords of sprite position on screen
  1777. size (vector2) table containing x and y sizes (relative to screen x and y size, ranges from 0.0-1.0)
  1778. rotation (float) number of sprite rotation in degrees
  1779. color (vector3) table of rgba values
  1780. texturedict Name of texture dictionary to load texture from (e.g. "CommonMenu", "MPWeaponsCommon", etc.)
  1781. texturename Name of texture to load from texture dictionary (e.g. "last_team_standing_icon", "tennis_icon", etc.)
  1782. VORPutils.Render:DrawSprite(pos, size, rotation, color, texturedict, texturename)
  1783.  
  1784. Example Usage:
  1785.  
  1786. two
  1787. -- Client
  1788. local VORPutils = {}
  1789.  
  1790. TriggerEvent("getUtils", function(utils)
  1791. VORPutils = utils
  1792. end)
  1793.  
  1794. Citizen.CreateThread(function()
  1795. while true do
  1796. Citizen.Wait(0)
  1797. local onScreen, _x, _y = GetScreenCoordFromWorldCoord(GetEntityCoords(PlayerPedId()))
  1798.  
  1799. if onScreen then
  1800. VORPutils.Render:DrawSprite(vector2(_x, _y), vector2(0.2, 0.2), 190.0, {r: 255, g: 0, b: 0, a: 255}, "feeds", "hud_menu_4a")
  1801. end
  1802. end
  1803. end)
  1804. Draw Rectangle
  1805. Client Side Only
  1806. Draw a rectangle on screen
  1807.  
  1808. Parameter Description
  1809. pos (vector2) table containing x and y coords of sprite position on screen (ranges from 0.0-1.0)
  1810. size (vector2) table containing x and y sizes (ranges from 0.0-1.0)
  1811. color (vector3) table of rgba values
  1812. VORPutils.Render:DrawRectangle(pos, size, color)
  1813.  
  1814. Example Usage:
  1815.  
  1816. two
  1817. -- Client
  1818. local VORPutils = {}
  1819.  
  1820. TriggerEvent("getUtils", function(utils)
  1821. VORPutils = utils
  1822. end)
  1823.  
  1824. Citizen.CreateThread(function()
  1825. while true do
  1826. Citizen.Wait(0)
  1827. local onScreen, _x, _y = GetScreenCoordFromWorldCoord(GetEntityCoords(PlayerPedId()))
  1828.  
  1829. if onScreen then
  1830. VORPutils.Render:DrawRectangle(vector2(_x, _y), vector2(0.2, 0.2), {r: 255, g: 0, b: 0, a: 255})
  1831. end
  1832. end
  1833. end)
  1834. Draw Marker
  1835. Client Side Only
  1836. Draw a Marker in-world
  1837.  
  1838. Parameter Description
  1839. type
  1840. pos table containing x y and z coords
  1841. you table containing x y and z coords
  1842. rot rotation of the marker
  1843. scale table containing x y and z scale
  1844. color table of rgba values
  1845. bobupanddown does it bounce (true/false)
  1846. facecamera should it face the camera (true/false)
  1847. rotate does the marker rotate (true/false)
  1848. drawonents (true/false)
  1849. VORPutils.Render:DrawMarker(type, pos, dir, rot, scale, color, bob, facevamera, rotate, drawonents)
  1850.  
  1851. Example Usage:
  1852.  
  1853. two
  1854. -- Client
  1855. local VORPutils = {}
  1856.  
  1857. TriggerEvent("getUtils", function(utils)
  1858. VORPutils = utils
  1859. end)
  1860.  
  1861. Citizen.CreateThread(function()
  1862. while true do
  1863. Citizen.Wait(0)
  1864. VORPutils.Render:DrawMarker(0x50638AB9, GetEntityCoords(PlayerPedId()), vector3(0.0, 0.0, 0.0), vector3(0.0, 0.0, 0.0), vecotr3(0.15, 0.15, 0.15), {r: 255, g: 0, b: 0, a: 255}, false, false, false, false)
  1865. end
  1866. end)
  1867. Draw Text
  1868. Client Side Only
  1869. Draw a Text on screen
  1870.  
  1871. Parameter Description
  1872. pos table containing x and y coords of text position (0-1, 0-1)
  1873. text table containing x y and z coords
  1874. color table of rgba values
  1875. scale scale of the text
  1876. shadow if shadow is enabled (true/false)
  1877. VORPutils.Render:DrawText(pos, text, color, scale, shadow)
  1878.  
  1879. Example Usage:
  1880.  
  1881. two
  1882. -- Client
  1883. local VORPutils = {}
  1884.  
  1885. TriggerEvent("getUtils", function(utils)
  1886. VORPutils = utils
  1887. end)
  1888.  
  1889. Citizen.CreateThread(function()
  1890. while true do
  1891. Citizen.Wait(0)
  1892. local onScreen, _x, _y = GetScreenCoordFromWorldCoord(GetEntityCoords(PlayerPedId()))
  1893.  
  1894. if onScreen then
  1895. VORPutils.Render:DrawText(vector2(_x, _y), 'Vorp Rules!', {r: 255, g: 0, b: 0, a: 255}, 1.0, false)
  1896. end
  1897. end
  1898. end)
  1899. Game Events
  1900. Vorp_Utils has a built-in network and entity event watcher that can be utilized by other scripts easily.
  1901.  
  1902. Register Event Listener
  1903. Client Side Only
  1904. Register a callback that will be triggered whenever an in-game client event triggers.
  1905.  
  1906. Parameter Description
  1907. eventname name of the event to watch/listen to
  1908. callback fucntion to be triggered when an event is triggered
  1909. VORPutils.Events:RegisterEventListener(eventname, callback)
  1910.  
  1911. Example Usage:
  1912.  
  1913. two
  1914. -- Client
  1915. local VORPutils = {}
  1916.  
  1917. TriggerEvent("getUtils", function(utils)
  1918. VORPutils = utils
  1919. end)
  1920.  
  1921. Citizen.CreateThread(function()
  1922. VORPutils.Events:RegisterEventListener('EVENT_PICKUP_CARRIABLE', function(args)
  1923. print("EVENT TRIGGERED: EVENT_PICKUP_CARRIABLE", args[1], args[2])
  1924. end)
  1925. end)
  1926. Remove Event Listener
  1927. Client Side Only
  1928. Removes an event from the listener queue, listener will no longer listen once removed. This frees up in-game memory andis best practice if using listeners in a dynamic, or temporary way.
  1929.  
  1930. Parameter Description
  1931. listener object returns from RegisterEventListener
  1932. VORPutils.Events:RemoveEventListener(listener)
  1933.  
  1934. Example Usage:
  1935.  
  1936. two
  1937. -- Client
  1938. local VORPutils = {}
  1939.  
  1940. TriggerEvent("getUtils", function(utils)
  1941. VORPutils = utils
  1942. end)
  1943.  
  1944. Citizen.CreateThread(function()
  1945. local listener = VORPutils.Events:RegisterEventListener('EVENT_PICKUP_CARRIABLE', function(args)
  1946. print("EVENT TRIGGERED: EVENT_PICKUP_CARRIABLE", args[1], args[2])
  1947. end)
  1948.  
  1949.  
  1950. Wait(40000)
  1951.  
  1952. VORPutils.Events:RemoveEventListener(listener)
  1953. end)
  1954. DevMode
  1955. Client Side Only
  1956. This provides the ability to print every in-game event for development purpose.
  1957.  
  1958. Parameter Description
  1959. state object returns from RegisterEventListener
  1960. type (optional, will default to all) the type of event to listen too (entities, network, or all)
  1961. VORPutils.Events:DevMode(listener)
  1962.  
  1963. Example Usage:
  1964.  
  1965. two
  1966. -- Client
  1967. local VORPutils = {}
  1968.  
  1969. TriggerEvent("getUtils", function(utils)
  1970. VORPutils = utils
  1971. end)
  1972.  
  1973. Citizen.CreateThread(function()
  1974. VORPutils.Events:DevMode(true, 'entities')
  1975. -- VORPutils.Events:DevMode(true, 'network')
  1976. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement