Files
overextended.github.io/assets/js/d92657ac.409ace77.js
T

1 line
6.2 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[7499],{9613:function(e,r,t){t.d(r,{Zo:function(){return u},kt:function(){return y}});var a=t(9496);function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function l(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?l(Object(t),!0).forEach((function(r){n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function p(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},l=Object.keys(e);for(a=0;a<l.length;a++)t=l[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)t=l[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}var i=a.createContext({}),c=function(e){var r=a.useContext(i),t=r;return e&&(t="function"==typeof e?e(r):o(o({},r),e)),t},u=function(e){var r=c(e.components);return a.createElement(i.Provider,{value:r},e.children)},s={inlineCode:"code",wrapper:function(e){var r=e.children;return a.createElement(a.Fragment,{},r)}},d=a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,l=e.originalType,i=e.parentName,u=p(e,["components","mdxType","originalType","parentName"]),d=c(t),y=n,g=d["".concat(i,".").concat(y)]||d[y]||s[y]||l;return t?a.createElement(g,o(o({ref:r},u),{},{components:t})):a.createElement(g,o({ref:r},u))}));function y(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var l=t.length,o=new Array(l);o[0]=d;var p={};for(var i in r)hasOwnProperty.call(r,i)&&(p[i]=r[i]);p.originalType=e,p.mdxType="string"==typeof e?e:n,o[1]=p;for(var c=2;c<l;c++)o[c]=t[c];return a.createElement.apply(null,o)}return a.createElement.apply(null,t)}d.displayName="MDXCreateElement"},6428:function(e,r,t){t.r(r),t.d(r,{assets:function(){return u},contentTitle:function(){return i},default:function(){return y},frontMatter:function(){return p},metadata:function(){return c},toc:function(){return s}});var a=t(5443),n=t(3010),l=(t(9496),t(9613)),o=["components"],p={title:"Methods"},i=void 0,c={unversionedId:"ox_core/Player/Server/methods",id:"ox_core/Player/Server/methods",title:"Methods",description:"These functions are inherited by instances of CPlayer.",source:"@site/docs/ox_core/Player/Server/methods.md",sourceDirName:"ox_core/Player/Server",slug:"/ox_core/Player/Server/methods",permalink:"/docs/ox_core/Player/Server/methods",draft:!1,editUrl:"https://github.com/overextended/overextended.github.io/tree/main/docs/ox_core/Player/Server/methods.md",tags:[],version:"current",lastUpdatedAt:1656531847,formattedLastUpdatedAt:"6/29/2022",frontMatter:{title:"Methods"},sidebar:"ox_core",previous:{title:"Events",permalink:"/docs/ox_core/Player/Server/events"},next:{title:"Server",permalink:"/docs/ox_core/Vehicle/Server/"}},u={},s=[{value:"player.set",id:"playerset",level:2},{value:"player.get",id:"playerget",level:2},{value:"player.getCoords",id:"playergetcoords",level:2},{value:"player.setGroup",id:"playersetgroup",level:2},{value:"player.hasGroup",id:"playerhasgroup",level:2},{value:"player.isPlayerInScope",id:"playerisplayerinscope",level:2},{value:"player.triggerScopedEvent",id:"playertriggerscopedevent",level:2}],d={toc:s};function y(e){var r=e.components,t=(0,n.Z)(e,o);return(0,l.kt)("wrapper",(0,a.Z)({},d,t,{components:r,mdxType:"MDXLayout"}),(0,l.kt)("p",null,"These functions are inherited by instances of CPlayer."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local player = Ox.GetPlayer(source)\n")),(0,l.kt)("h2",{id:"playerset"},"player.set"),(0,l.kt)("p",null,"Sets the player's metadata for key to the given value."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local key, value = 'iq', 300\nplayer.set(key, value)\n")),(0,l.kt)("h2",{id:"playerget"},"player.get"),(0,l.kt)("p",null,"Return the player's metadata. Sending an argument will retrieve a specific metadata key."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local data = player.get()\nlocal iq = player.get('iq')\n")),(0,l.kt)("h2",{id:"playergetcoords"},"player.getCoords"),(0,l.kt)("p",null,"Return the player's world position. The value will be cached for future calls, so send true for the first argument to update it."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local coords = player.getCoords(update)\n")),(0,l.kt)("h2",{id:"playersetgroup"},"player.setGroup"),(0,l.kt)("p",null,"Updates the player's grade for the given group. A value of 0 will remove the player"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local group, grade = 'police', 3\nplayer.setGroup(group, grade)\n")),(0,l.kt)("h2",{id:"playerhasgroup"},"player.hasGroup"),(0,l.kt)("p",null,"Check if the player is a member of a given group, and returns the matching group name and grade.",(0,l.kt)("br",{parentName:"p"}),"\n","The filter can be a string, array, or object where key is the group, and value is the minimum grade."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local filter = { police = 0, sheriff = 0 }\nlocal group, grade = player.hasGroup(filter)\n")),(0,l.kt)("h2",{id:"playerisplayerinscope"},"player.isPlayerInScope"),(0,l.kt)("p",null,"Check if the given source is inside the player's scope."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"local target = 2\nlocal inScope = player.isPlayerInScope(target)\n")),(0,l.kt)("h2",{id:"playertriggerscopedevent"},"player.triggerScopedEvent"),(0,l.kt)("p",null,"Trigger a client event for all players in the player's scope."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-lua"},"player.triggerScopedEvent(eventName, ...)\n")))}y.isMDXComponent=!0}}]);