mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
Consistent indentation and remove some files
Mixing tabs and spaces when embedding Lua can easily break MDX syntax.
This commit is contained in:
1 parent
b87ef48d2e
commit
6bead3ca32
21 files changed
+146
-240
No files matched your search
@@ -157,24 +157,24 @@ The correct formatting is `export = resourceName.exportName`.
|
||||
|
||||
```lua
|
||||
exports('bandage', function(data, slot)
|
||||
local playerPed = PlayerPedId()
|
||||
local maxHealth = GetEntityMaxHealth(playerPed)
|
||||
local health = GetEntityHealth(playerPed)
|
||||
local playerPed = PlayerPedId()
|
||||
local maxHealth = GetEntityMaxHealth(playerPed)
|
||||
local health = GetEntityHealth(playerPed)
|
||||
|
||||
-- Does the ped need to heal?
|
||||
if health < maxHealth then
|
||||
-- Use the bandage
|
||||
exports.ox_inventory:useItem(data, function(data)
|
||||
-- The item has been used, so trigger the effects
|
||||
if data then
|
||||
SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))
|
||||
exports.ox_inventory:notify({text = 'You feel better already'})
|
||||
end
|
||||
end)
|
||||
else
|
||||
-- Don't use the item
|
||||
exports.ox_inventory:notify({type = 'error', text = 'You don\'t need a bandage right now'})
|
||||
end
|
||||
-- Does the ped need to heal?
|
||||
if health < maxHealth then
|
||||
-- Use the bandage
|
||||
exports.ox_inventory:useItem(data, function(data)
|
||||
-- The item has been used, so trigger the effects
|
||||
if data then
|
||||
SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))
|
||||
exports.ox_inventory:notify({text = 'You feel better already'})
|
||||
end
|
||||
end)
|
||||
else
|
||||
-- Don't use the item
|
||||
exports.ox_inventory:notify({type = 'error', text = 'You don\'t need a bandage right now'})
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -187,23 +187,23 @@ This can either be an export (recommended), or added to [items/server.lua](https
|
||||
```lua
|
||||
exports('bandage', function(event, item, inventory, slot, data)
|
||||
if event == 'usingItem' then
|
||||
local playerPed = GetPlayerPed(inventory.source)
|
||||
local maxHealth = GetEntityMaxHealth(playerPed)
|
||||
local health = GetEntityHealth(playerPed)
|
||||
local playerPed = GetPlayerPed(inventory.source)
|
||||
local maxHealth = GetEntityMaxHealth(playerPed)
|
||||
local health = GetEntityHealth(playerPed)
|
||||
|
||||
if health >= maxHealth then
|
||||
TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'error', text = 'You don\'t need a bandage right now'})
|
||||
TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'error', text = 'You don\'t need a bandage right now'})
|
||||
|
||||
-- Returning 'false' will prevent the item from being used
|
||||
-- Returning 'false' will prevent the item from being used
|
||||
return false
|
||||
end
|
||||
|
||||
return
|
||||
return
|
||||
elseif event == 'usedItem' then
|
||||
return TriggerClientEvent('ox_inventory:notify', inventory.source, {text = 'You feel better already'})
|
||||
return TriggerClientEvent('ox_inventory:notify', inventory.source, {text = 'You feel better already'})
|
||||
|
||||
elseif event == 'buying' then
|
||||
return TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'success', text = 'You bought a bandage'})
|
||||
return TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'success', text = 'You bought a bandage'})
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -14,8 +14,8 @@ We can set up custom stashes from outside the resource utilising the exported Re
|
||||
-- weight: number
|
||||
-- owner: string or boolean (optional)
|
||||
-- groups: table (optional)
|
||||
-- name: string
|
||||
-- grade: number
|
||||
-- name: string
|
||||
-- grade: number
|
||||
-- coords: vector or table (optional)
|
||||
```
|
||||
|
||||
@@ -40,17 +40,17 @@ Below the value is hardset, but it could be loaded from the database (especially
|
||||
```lua
|
||||
-- Server
|
||||
local stash = {
|
||||
id = '42wallabyway',
|
||||
label = '42 Wallaby Way',
|
||||
slots = 50,
|
||||
weight = 100000,
|
||||
owner = 'char1:license'
|
||||
id = '42wallabyway',
|
||||
label = '42 Wallaby Way',
|
||||
slots = 50,
|
||||
weight = 100000,
|
||||
owner = 'char1:license'
|
||||
}
|
||||
|
||||
AddEventHandler('onServerResourceStart', function(resourceName)
|
||||
if resourceName == 'ox_inventory' or resourceName == GetCurrentResourceName() then
|
||||
exports.ox_inventory:RegisterStash(stash.id, stash.label, stash.slots, stash.weight, stash.owner)
|
||||
end
|
||||
if resourceName == 'ox_inventory' or resourceName == GetCurrentResourceName() then
|
||||
exports.ox_inventory:RegisterStash(stash.id, stash.label, stash.slots, stash.weight, stash.owner)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Client
|
||||
@@ -63,23 +63,23 @@ The following sample is based on esx_property's db data.
|
||||
local properties
|
||||
|
||||
MySQL.query('SELECT * FROM `properties`', {}, function(result)
|
||||
properties = result
|
||||
properties = result
|
||||
end
|
||||
|
||||
RegisterNetEvent('ox:loadStashes', function(id)
|
||||
local stash = properties[id]
|
||||
if stash then
|
||||
-- id: 1, name: WhispymoundDrive, label: 2677 Whispymound Drive, coords: {"x":118.748,"y":566.573,"z":175.697}
|
||||
ox_inventory:RegisterStash(stash.name, stash.label, 50, 100000, true, false, json.encode(stash.room_menu))
|
||||
end
|
||||
if stash then
|
||||
-- id: 1, name: WhispymoundDrive, label: 2677 Whispymound Drive, coords: {"x":118.748,"y":566.573,"z":175.697}
|
||||
ox_inventory:RegisterStash(stash.name, stash.label, 50, 100000, true, false, json.encode(stash.room_menu))
|
||||
end
|
||||
end)
|
||||
|
||||
-- Client
|
||||
local ox_inventory = exports.ox_inventory
|
||||
|
||||
if ox_inventory:openInventory('stash', property.id) == false then
|
||||
TriggerServerEvent('ox:loadStashes')
|
||||
ox_inventory:openInventory('stash', property.id)
|
||||
TriggerServerEvent('ox:loadStashes')
|
||||
ox_inventory:openInventory('stash', property.id)
|
||||
end
|
||||
```
|
||||
|
||||
@@ -88,7 +88,7 @@ end
|
||||
We put together an example resource showcasing how to properly utilise the stash API:
|
||||
|
||||
<div style={{width: 'fit-content'}}>
|
||||
<a href="https://www.github.com/overextended/ox_inventory_examples">
|
||||
<IconButton side='left' icon={<BsGithub/>}>GitHub</IconButton>
|
||||
</a>
|
||||
<a href="https://www.github.com/overextended/ox_inventory_examples">
|
||||
<IconButton side='left' icon={<BsGithub/>}>GitHub</IconButton>
|
||||
</a>
|
||||
</div>
|
||||
Reference in new issue
Block a user