Guest User

Untitled

a guest
Apr 24th, 2019
3,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.33 KB | None | 0 0
  1. const _i = Citizen.pointerValueInt();
  2. const _f = Citizen.pointerValueFloat();
  3. const _v = Citizen.pointerValueVector();
  4. const _r = Citizen.returnResultAnyway();
  5. const _ri = Citizen.resultAsInteger();
  6. const _rf = Citizen.resultAsFloat();
  7. const _rl = Citizen.resultAsLong();
  8. const _s = Citizen.resultAsString();
  9. const _rv = Citizen.resultAsVector();
  10. const _ro = Citizen.resultAsObject();
  11. const _in = Citizen.invokeNativeByHash;
  12. const _ii = Citizen.pointerValueIntInitialized;
  13. const _fi = Citizen.pointerValueFloatInitialized;
  14. function _ch(hash) {
  15. if (typeof hash === 'string') {
  16. return window.GetHashKey(hash);
  17. }
  18.  
  19. return hash;
  20. }
  21.  
  22. function _ts(num) {
  23. if (num === 0 || num === null || num === undefined || num === false) { // workaround for users calling string parameters with '0', also nil being translated
  24. return null;
  25. }
  26. if (ArrayBuffer.isView(num) || num instanceof ArrayBuffer) { // these are handled as strings internally
  27. return num;
  28. }
  29. return num.toString();
  30. }
  31. function _fv(flt) {
  32. return flt + 0.0000001;
  33. }
  34.  
  35. function _mfr(fn) {
  36. return Citizen.makeRefFunction(fn);
  37. }
  38.  
  39. const _ENV = null;
  40.  
  41. /**
  42. * Cancels the currently executing event.
  43. */
  44. window.CancelEvent = function () {
  45. return _in(0x00000000, 0xfa29d35d);
  46. };
  47.  
  48. /**
  49. * thisScriptCheck - can be destroyed if it belongs to the calling script.
  50. */
  51. window.CreateVehicle = function (modelHash, x, y, z, heading, isNetwork, thisScriptCheck) {
  52. return _in(0x00000000, 0xdd75460a, _ch(modelHash), _fv(x), _fv(y), _fv(z), _fv(heading), isNetwork, thisScriptCheck);
  53. };
  54.  
  55. window.DeleteFunctionReference = function (referenceIdentity) {
  56. return _in(0x00000000, 0x1e86f206, _ts(referenceIdentity));
  57. };
  58.  
  59. window.DoesEntityExist = function (entity) {
  60. return _in(0x00000000, 0x3ac90869, entity, _r);
  61. };
  62.  
  63. window.DropPlayer = function (playerSrc, reason) {
  64. return _in(0x00000000, 0xba0613e1, _ts(playerSrc), _ts(reason));
  65. };
  66.  
  67. window.DuplicateFunctionReference = function (referenceIdentity) {
  68. return _in(0x00000000, 0xf4e2079d, _ts(referenceIdentity), _r, _s);
  69. };
  70.  
  71. window.EnableEnhancedHostSupport = function (enabled) {
  72. return _in(0x00000000, 0xf97b1c93, enabled);
  73. };
  74.  
  75. window.ExecuteCommand = function (commandString) {
  76. return _in(0x00000000, 0x561c060b, _ts(commandString));
  77. };
  78.  
  79. window.FlagServerAsPrivate = function (private_) {
  80. return _in(0x00000000, 0x13b6855d, private_);
  81. };
  82.  
  83. /**
  84. * No, this should be called SET_ENTITY_KINEMATIC. It does more than just "freeze" it's position.
  85. * ^Rockstar Devs named it like that, Now cry about it.
  86. */
  87. window.FreezeEntityPosition = function (entity, toggle) {
  88. return _in(0x00000000, 0x65c16d57, entity, toggle);
  89. };
  90.  
  91. window.GetConvar = function (varName, default_) {
  92. return _in(0x00000000, 0x6ccd2564, _ts(varName), _ts(default_), _r, _s);
  93. };
  94.  
  95. window.GetConvarInt = function (varName, default_) {
  96. return _in(0x00000000, 0x935c0ab2, _ts(varName), default_, _r, _ri);
  97. };
  98.  
  99. /**
  100. * Returns the name of the currently executing resource.
  101. * @return The name of the resource.
  102. */
  103. window.GetCurrentResourceName = function () {
  104. return _in(0x00000000, 0xe5e9ebbb, _r, _s);
  105. };
  106.  
  107. window.GetEntityCoords = function (entity) {
  108. return _in(0x00000000, 0x1647f1cb, entity, _r, _rv);
  109. };
  110.  
  111. window.GetEntityHeading = function (entity) {
  112. return _in(0x00000000, 0x972cc383, entity, _r, _rf);
  113. };
  114.  
  115. window.GetEntityModel = function (entity) {
  116. return _in(0x00000000, 0xdafcb3ec, entity, _r, _ri);
  117. };
  118.  
  119. window.GetEntityPopulationType = function (entity) {
  120. return _in(0x00000000, 0xfc30ddff, entity, _r, _ri);
  121. };
  122.  
  123. window.GetEntityRotation = function (entity) {
  124. return _in(0x00000000, 0x8ff45b04, entity, _r, _rv);
  125. };
  126.  
  127. window.GetEntityRotationVelocity = function (entity) {
  128. return _in(0x00000000, 0x9bf8a73f, entity, _r, _rv);
  129. };
  130.  
  131. window.GetEntityScript = function (entity) {
  132. return _in(0x00000000, 0xb7f70784, entity, _r, _s);
  133. };
  134.  
  135. window.GetEntityType = function (entity) {
  136. return _in(0x00000000, 0x0b1bd08d, entity, _r, _ri);
  137. };
  138.  
  139. window.GetEntityVelocity = function (entity) {
  140. return _in(0x00000000, 0xc14c9b6b, entity, _r, _rv);
  141. };
  142.  
  143. /**
  144. * Gets the current game timer in milliseconds.
  145. * @return The game time.
  146. */
  147. window.GetGameTimer = function () {
  148. return _in(0x00000000, 0xa4ea0691, _r, _rl);
  149. };
  150.  
  151. /**
  152. * This native converts the passed string to a hash.
  153. */
  154. window.GetHashKey = function (model) {
  155. return _in(0x00000000, 0x98eff6f1, _ts(model), _r, _ri);
  156. };
  157.  
  158. window.GetHostId = function () {
  159. return _in(0x00000000, 0x5f70f5a3, _r, _s);
  160. };
  161.  
  162. window.GetInstanceId = function () {
  163. return _in(0x00000000, 0x9f1c4383, _r, _ri);
  164. };
  165.  
  166. window.GetInvokingResource = function () {
  167. return _in(0x00000000, 0x4d52fe5b, _r, _s);
  168. };
  169.  
  170. window.GetNumPlayerIdentifiers = function (playerSrc) {
  171. return _in(0x00000000, 0xff7f66ab, _ts(playerSrc), _r, _ri);
  172. };
  173.  
  174. window.GetNumPlayerIndices = function () {
  175. return _in(0x00000000, 0x63d13184, _r, _ri);
  176. };
  177.  
  178. /**
  179. * Gets the amount of metadata values with the specified key existing in the specified resource's manifest.
  180. * See also: [Resource manifest](https://docs.fivem.net/resources/manifest/)
  181. * @param resourceName The resource name.
  182. * @param metadataKey The key to look up in the resource manifest.
  183. */
  184. window.GetNumResourceMetadata = function (resourceName, metadataKey) {
  185. return _in(0x00000000, 0x0776e864, _ts(resourceName), _ts(metadataKey), _r, _ri);
  186. };
  187.  
  188. window.GetNumResources = function () {
  189. return _in(0x00000000, 0x0863f27b, _r, _ri);
  190. };
  191.  
  192. window.GetPasswordHash = function (password) {
  193. return _in(0x00000000, 0x23473ea4, _ts(password), _r, _s);
  194. };
  195.  
  196. window.GetPlayerEndpoint = function (playerSrc) {
  197. return _in(0x00000000, 0xfee404f9, _ts(playerSrc), _r, _s);
  198. };
  199.  
  200. window.GetPlayerFromIndex = function (index) {
  201. return _in(0x00000000, 0xc8a9ce08, index, _r, _s);
  202. };
  203.  
  204. window.GetPlayerGuid = function (playerSrc) {
  205. return _in(0x00000000, 0xe52d9680, _ts(playerSrc), _r, _s);
  206. };
  207.  
  208. window.GetPlayerIdentifier = function (playerSrc, identifier) {
  209. return _in(0x00000000, 0x7302dbcf, _ts(playerSrc), identifier, _r, _s);
  210. };
  211.  
  212. window.GetPlayerLastMsg = function (playerSrc) {
  213. return _in(0x00000000, 0x427e8e6a, _ts(playerSrc), _r, _ri);
  214. };
  215.  
  216. window.GetPlayerName = function (playerSrc) {
  217. return _in(0x00000000, 0x406b4b20, _ts(playerSrc), _r, _s);
  218. };
  219.  
  220. window.GetPlayerPed = function (playerSrc) {
  221. return _in(0x00000000, 0x6e31e993, _ts(playerSrc), _r, _ri);
  222. };
  223.  
  224. window.GetPlayerPing = function (playerSrc) {
  225. return _in(0x00000000, 0xff1290d4, _ts(playerSrc), _r, _ri);
  226. };
  227.  
  228. /**
  229. * Returns all commands that are registered in the command system.
  230. * The data returned adheres to the following layout:
  231. * ```
  232. * [
  233. * {
  234. * "name": "cmdlist"
  235. * },
  236. * {
  237. * "name": "command1"
  238. * }
  239. * ]
  240. * ```
  241. * @return An object containing registered commands.
  242. */
  243. window.GetRegisteredCommands = function () {
  244. return window.msgpack_unpack(_in(0x00000000, 0xd4bef069, _r, _ro));
  245. };
  246.  
  247. window.GetResourceByFindIndex = function (findIndex) {
  248. return _in(0x00000000, 0x387246b7, findIndex, _r, _s);
  249. };
  250.  
  251. /**
  252. * Gets the metadata value at a specified key/index from a resource's manifest.
  253. * See also: [Resource manifest](https://docs.fivem.net/resources/manifest/)
  254. * @param resourceName The resource name.
  255. * @param metadataKey The key in the resource manifest.
  256. * @param index The value index, in a range from [0..GET_NUM_RESOURCE_METDATA-1].
  257. */
  258. window.GetResourceMetadata = function (resourceName, metadataKey, index) {
  259. return _in(0x00000000, 0x964bab1d, _ts(resourceName), _ts(metadataKey), index, _r, _s);
  260. };
  261.  
  262. /**
  263. * Returns the physical on-disk path of the specified resource.
  264. * @param resourceName The name of the resource.
  265. * @return The resource directory name, possibly without trailing slash.
  266. */
  267. window.GetResourcePath = function (resourceName) {
  268. return _in(0x00000000, 0x61dcf017, _ts(resourceName), _r, _s);
  269. };
  270.  
  271. /**
  272. * Returns the current state of the specified resource.
  273. * @param resourceName The name of the resource.
  274. * @return The resource state. One of `"missing", "started", "starting", "stopped", "stopping", "uninitialized" or "unknown"`.
  275. */
  276. window.GetResourceState = function (resourceName) {
  277. return _in(0x00000000, 0x4039b485, _ts(resourceName), _r, _s);
  278. };
  279.  
  280. window.InvokeFunctionReference = function (referenceIdentity, argsSerialized, argsLength, retvalLength) {
  281. return _in(0x00000000, 0xe3551879, _ts(referenceIdentity), _ts(argsSerialized), argsLength, _ii(retvalLength) /* may be optional */, _r, _s);
  282. };
  283.  
  284. window.IsAceAllowed = function (object) {
  285. return _in(0x00000000, 0x7ebb9929, _ts(object), _r);
  286. };
  287.  
  288. /**
  289. * Gets whether or not this is the CitizenFX server.
  290. * @return A boolean value.
  291. */
  292. window.IsDuplicityVersion = function () {
  293. return _in(0x00000000, 0xcf24c52e, _r);
  294. };
  295.  
  296. window.IsPlayerAceAllowed = function (playerSrc, object) {
  297. return _in(0x00000000, 0xdedae23d, _ts(playerSrc), _ts(object), _r);
  298. };
  299.  
  300. window.IsPrincipalAceAllowed = function (principal, object) {
  301. return _in(0x00000000, 0x37cf52ce, _ts(principal), _ts(object), _r);
  302. };
  303.  
  304. /**
  305. * Reads the contents of a text file in a specified resource.
  306. * If executed on the client, this file has to be included in `files` in the resource manifest.
  307. * Example: `local data = LoadResourceFile("devtools", "data.json")`
  308. * @param resourceName The resource name.
  309. * @param fileName The file in the resource.
  310. * @return The file contents
  311. */
  312. window.LoadResourceFile = function (resourceName, fileName) {
  313. return _in(0x00000000, 0x76a9ee1f, _ts(resourceName), _ts(fileName), _r, _s);
  314. };
  315.  
  316. window.NetworkGetEntityFromNetworkId = function (netId) {
  317. return _in(0x00000000, 0x5b912c3f, netId, _r, _ri);
  318. };
  319.  
  320. /**
  321. * Returns the owner ID of the specified entity.
  322. * @param entity The entity to get the owner for.
  323. * @return On the server, the server ID of the entity owner. On the client, returns the player/slot ID of the entity owner.
  324. */
  325. window.NetworkGetEntityOwner = function (entity) {
  326. return _in(0x00000000, 0x526fee31, entity, _r, _ri);
  327. };
  328.  
  329. window.NetworkGetNetworkIdFromEntity = function (entity) {
  330. return _in(0x00000000, 0x9e35dab6, entity, _r, _ri);
  331. };
  332.  
  333. window.PerformHttpRequestInternal = function (requestData, requestDataLength) {
  334. return _in(0x00000000, 0x8e8cc653, _ts(requestData), requestDataLength, _r, _ri);
  335. };
  336.  
  337. /**
  338. * Registered commands can be executed by entering them in the client console (this works for client side and server side registered commands). Or by entering them in the server console/through an RCON client (only works for server side registered commands). Or if you use a supported chat resource, like the default one provided in the cfx-server-data repository, then you can enter the command in chat by prefixing it with a `/`.
  339. * Commands registered using this function can also be executed by resources, using the [`ExecuteCommand` native](#_0x561C060B).
  340. * The restricted bool is not used on the client side. Permissions can only be checked on the server side, so if you want to limit your command with an ace permission automatically, make it a server command (by registering it in a server script).
  341. * **Example result**:
  342. * ![](https://i.imgur.com/TaCnG09.png)
  343. * @param commandName The command you want to register.
  344. * @param handler A handler function that gets called whenever the command is executed.
  345. * @param restricted If this is a server command and you set this to true, then players will need the command.yourCommandName ace permission to execute this command.
  346. */
  347. window.RegisterCommand = function (commandName, handler, restricted) {
  348. return _in(0x00000000, 0x5fa79b0f, _ts(commandName), _mfr(handler), restricted);
  349. };
  350.  
  351. /**
  352. * An internal function which allows the current resource's HLL script runtimes to receive state for the specified event.
  353. * @param eventName An event name, or "\*" to disable HLL event filtering for this resource.
  354. */
  355. window.RegisterResourceAsEventHandler = function (eventName) {
  356. return _in(0x00000000, 0xd233a168, _ts(eventName));
  357. };
  358.  
  359. /**
  360. * **Experimental**: This native may be altered or removed in future versions of CitizenFX without warning.
  361. * Registers a cached resource asset with the resource system, similar to the automatic scanning of the `stream/` folder.
  362. * @param resourceName The resource to add the asset to.
  363. * @param fileName A file name in the resource.
  364. * @return A cache string to pass to `REGISTER_STREAMING_FILE_FROM_CACHE` on the client.
  365. */
  366. window.RegisterResourceAsset = function (resourceName, fileName) {
  367. return _in(0x00000000, 0x9862b266, _ts(resourceName), _ts(fileName), _r, _s);
  368. };
  369.  
  370. /**
  371. * Registers a build task factory for resources.
  372. * The function should return an object (msgpack map) with the following fields:
  373. * ```
  374. * {
  375. * // returns whether the specific resource should be built
  376. * shouldBuild = func(resourceName: string): bool,
  377. * // asynchronously start building the specific resource.
  378. * // call cb when completed
  379. * build = func(resourceName: string, cb: func(success: bool, status: string): void): void
  380. * }
  381. * ```
  382. * @param factoryId The identifier for the build task.
  383. * @param factoryFn The factory function.
  384. */
  385. window.RegisterResourceBuildTaskFactory = function (factoryId, factoryFn) {
  386. return _in(0x00000000, 0x285b43ca, _ts(factoryId), _mfr(factoryFn));
  387. };
  388.  
  389. /**
  390. * Writes the specified data to a file in the specified resource.
  391. * Using a length of `-1` will automatically detect the length assuming the data is a C string.
  392. * @param resourceName The name of the resource.
  393. * @param fileName The name of the file.
  394. * @param data The data to write to the file.
  395. * @param dataLength The length of the written data.
  396. * @return A value indicating if the write succeeded.
  397. */
  398. window.SaveResourceFile = function (resourceName, fileName, data, dataLength) {
  399. return _in(0x00000000, 0xa09e7e7b, _ts(resourceName), _ts(fileName), _ts(data), dataLength, _r);
  400. };
  401.  
  402. window.SetConvar = function (varName, value) {
  403. return _in(0x00000000, 0x341b16d2, _ts(varName), _ts(value));
  404. };
  405.  
  406. window.SetConvarReplicated = function (varName, value) {
  407. return _in(0x00000000, 0xf292858c, _ts(varName), _ts(value));
  408. };
  409.  
  410. window.SetConvarServerInfo = function (varName, value) {
  411. return _in(0x00000000, 0x9338d547, _ts(varName), _ts(value));
  412. };
  413.  
  414. /**
  415. * p7 is always 1 in the scripts. Set to 1, an area around the destination coords for the moved entity is cleared from other entities.
  416. * Often ends with 1, 0, 0, 1); in the scripts. It works.
  417. * Axis - Invert Axis Flags
  418. */
  419. window.SetEntityCoords = function (entity, xPos, yPos, zPos, xAxis, yAxis, zAxis, clearArea) {
  420. return _in(0x00000000, 0xdf70b41b, entity, _fv(xPos), _fv(yPos), _fv(zPos), xAxis, yAxis, zAxis, clearArea);
  421. };
  422.  
  423. window.SetEntityHeading = function (entity, heading) {
  424. return _in(0x00000000, 0xe0ff064d, entity, _fv(heading));
  425. };
  426.  
  427. /**
  428. * rotationOrder refers to the order yaw pitch roll is applied
  429. * value ranges from 0 to 5. What you use for rotationOrder when setting must be the same as rotationOrder when getting the rotation.
  430. * Unsure what value corresponds to what rotation order, more testing will be needed for that.
  431. * For the most part R* uses 1 or 2 as the order.
  432. * p5 is usually set as true
  433. */
  434. window.SetEntityRotation = function (entity, pitch, roll, yaw, rotationOrder, p5) {
  435. return _in(0x00000000, 0x0a345efe, entity, _fv(pitch), _fv(roll), _fv(yaw), rotationOrder, p5);
  436. };
  437.  
  438. /**
  439. * Note that the third parameter(denoted as z) is "up and down" with positive ment.
  440. */
  441. window.SetEntityVelocity = function (entity, x, y, z) {
  442. return _in(0x00000000, 0xff5a1988, entity, _fv(x), _fv(y), _fv(z));
  443. };
  444.  
  445. window.SetGameType = function (gametypeName) {
  446. return _in(0x00000000, 0xf90b7469, _ts(gametypeName));
  447. };
  448.  
  449. window.SetHttpHandler = function (handler) {
  450. return _in(0x00000000, 0xf5c6330c, _mfr(handler));
  451. };
  452.  
  453. window.SetMapName = function (mapName) {
  454. return _in(0x00000000, 0xb7ba82dc, _ts(mapName));
  455. };
  456.  
  457. /**
  458. * Ped: The ped to warp.
  459. * vehicle: The vehicle to warp the ped into.
  460. * Seat_Index: [-1 is driver seat, -2 first free passenger seat]
  461. * Moreinfo of Seat Index
  462. * DriverSeat = -1
  463. * Passenger = 0
  464. * Left Rear = 1
  465. * RightRear = 2
  466. */
  467. window.SetPedIntoVehicle = function (ped, vehicle, seatIndex) {
  468. return _in(0x00000000, 0x07500c79, ped, vehicle, seatIndex);
  469. };
  470.  
  471. /**
  472. * Call SET_PLAYER_WANTED_LEVEL_NOW for immediate effect
  473. * wantedLevel is an integer value representing 0 to 5 stars even though the game supports the 6th wanted level but no police will appear since no definitions are present for it in the game files
  474. * disableNoMission- Disables When Off Mission- appears to always be false
  475. */
  476. window.SetPlayerWantedLevel = function (player, wantedLevel, disableNoMission) {
  477. return _in(0x00000000, 0xb7a0914b, player, wantedLevel, disableNoMission);
  478. };
  479.  
  480. /**
  481. * colorPrimary & colorSecondary are the paint index for the vehicle.
  482. * For a list of valid paint indexes, view: pastebin.com/pwHci0xK
  483. * -------------------------------------------------------------------------
  484. * Use this to get the number of color indices: pastebin.com/RQEeqTSM
  485. * Note: minimum color index is 0, maximum color index is (numColorIndices - 1)
  486. */
  487. window.SetVehicleColours = function (vehicle, colorPrimary, colorSecondary) {
  488. return _in(0x00000000, 0x57f24253, vehicle, colorPrimary, colorSecondary);
  489. };
  490.  
  491. window.StartResource = function (resourceName) {
  492. return _in(0x00000000, 0x29b440dc, _ts(resourceName), _r);
  493. };
  494.  
  495. window.StopResource = function (resourceName) {
  496. return _in(0x00000000, 0x21783161, _ts(resourceName), _r);
  497. };
  498.  
  499. window.TempBanPlayer = function (playerSrc, reason) {
  500. return _in(0x00000000, 0x1e35dbba, _ts(playerSrc), _ts(reason));
  501. };
  502.  
  503. /**
  504. * The backing function for TriggerClientEvent.
  505. */
  506. window.TriggerClientEventInternal = function (eventName, eventTarget, eventPayload, payloadLength) {
  507. return _in(0x00000000, 0x2f7a49e6, _ts(eventName), _ts(eventTarget), _ts(eventPayload), payloadLength);
  508. };
  509.  
  510. /**
  511. * The backing function for TriggerEvent.
  512. */
  513. window.TriggerEventInternal = function (eventName, eventPayload, payloadLength) {
  514. return _in(0x00000000, 0x91310870, _ts(eventName), _ts(eventPayload), payloadLength);
  515. };
  516.  
  517. window.VerifyPasswordHash = function (password, hash) {
  518. return _in(0x00000000, 0x2e310acd, _ts(password), _ts(hash), _r);
  519. };
  520.  
  521. /**
  522. * Returns whether or not the currently executing event was canceled.
  523. * @return A boolean.
  524. */
  525. window.WasEventCanceled = function () {
  526. return _in(0x00000000, 0x58382a19, _r);
  527. };
Advertisement
Add Comment
Please, Sign In to add comment