mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
1 line
5.4 KiB
JavaScript
1 line
5.4 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[1058],{9613:function(e,t,r){r.d(t,{Zo:function(){return u},kt:function(){return h}});var n=r(9496);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var c=n.createContext({}),s=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):a(a({},t),e)),r},u=function(e){var t=s(e.components);return n.createElement(c.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},d=n.forwardRef((function(e,t){var r=e.components,i=e.mdxType,o=e.originalType,c=e.parentName,u=l(e,["components","mdxType","originalType","parentName"]),d=s(r),h=i,v=d["".concat(c,".").concat(h)]||d[h]||p[h]||o;return r?n.createElement(v,a(a({ref:t},u),{},{components:r})):n.createElement(v,a({ref:t},u))}));function h(e,t){var r=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var o=r.length,a=new Array(o);a[0]=d;var l={};for(var c in t)hasOwnProperty.call(t,c)&&(l[c]=t[c]);l.originalType=e,l.mdxType="string"==typeof e?e:i,a[1]=l;for(var s=2;s<o;s++)a[s]=r[s];return n.createElement.apply(null,a)}return n.createElement.apply(null,r)}d.displayName="MDXCreateElement"},1550:function(e,t,r){r.r(t),r.d(t,{assets:function(){return u},contentTitle:function(){return c},default:function(){return h},frontMatter:function(){return l},metadata:function(){return s},toc:function(){return p}});var n=r(5443),i=r(3010),o=(r(9496),r(9613)),a=["components"],l={title:"Server",sidebar_position:1},c=void 0,s={unversionedId:"ox_core/Vehicle/Server/index",id:"ox_core/Vehicle/Server/index",title:"Server",description:"Ox.GetVehicle",source:"@site/docs/ox_core/Vehicle/Server/index.md",sourceDirName:"ox_core/Vehicle/Server",slug:"/ox_core/Vehicle/Server/",permalink:"/docs/ox_core/Vehicle/Server/",draft:!1,editUrl:"https://github.com/overextended/overextended.github.io/tree/main/docs/ox_core/Vehicle/Server/index.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{title:"Server",sidebar_position:1},sidebar:"ox_core",previous:{title:"Methods",permalink:"/docs/ox_core/Player/Server/methods"},next:{title:"Methods",permalink:"/docs/ox_core/Vehicle/Server/methods"}},u={},p=[{value:"Ox.GetVehicle",id:"oxgetvehicle",level:2},{value:"Ox.GetVehicles",id:"oxgetvehicles",level:2},{value:"Ox.CreateVehicle",id:"oxcreatevehicle",level:2}],d={toc:p};function h(e){var t=e.components,r=(0,i.Z)(e,a);return(0,o.kt)("wrapper",(0,n.Z)({},d,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h2",{id:"oxgetvehicle"},"Ox.GetVehicle"),(0,o.kt)("p",null,"Return an instance of CVehicle for the given entity."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-lua"},"local vehicle = Ox.GetVehicle(entity)\nprint(json.encode(vehicle, { indent = true }))\n")),(0,o.kt)("h2",{id:"oxgetvehicles"},"Ox.GetVehicles"),(0,o.kt)("p",null,"Returns an array containing all vehicles. Methods will not be applied if the first argument is false."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-lua"},"local vehicles = Ox.GetVehicles(usemetatable)\n\nfor i = 1, #vehicles do\n local vehicle = vehicles[i]\n print(json.encode(vehicle, { indent = true }))\nend\n")),(0,o.kt)("h2",{id:"oxcreatevehicle"},"Ox.CreateVehicle"),(0,o.kt)("p",null,"Spawns a vehicle and returns the instance of CVehicle.",(0,o.kt)("br",{parentName:"p"}),"\n","If the first argument is a number, it will attempt to spawn a vehicle from the database with a matching id."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-lua"},"local vehicleId = MySQL.scalar.await('SELECT id FROM vehicles WHERE owner = ? LIMIT 1', { player.charid })\n\nif vehicleId then\n local coords = player.getCoords()\n local vehicle = Ox.CreateVehicle(vehicleId, vector3(coords.x, coords.y + 1.0, coords.z) , GetEntityHeading(player.ped))\n\n if vehicle then\n print(json.encode(vehicle, { indent = true }))\n end\nend\n")),(0,o.kt)("p",null,"If the first argument is a table and the owner property is a number, or nil, the vehicle will be added to the database.",(0,o.kt)("br",{parentName:"p"}),"\n","Setting the owner as false creates a non-persistent vehicle."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-lua"},"local vehicle = Ox.CreateVehicle({\n model = 'sultanrs',\n owner = player.charid,\n}, player.getCoords(), GetEntityHeading(player.ped))\n")))}h.isMDXComponent=!0}}]); |