Comments (1)
What exactly do u need? Advice on esx_xp integration?
Maybe the following helps ( pretty clumsy, thats what i did ). Will hopefully apply similar stuff to more esx
mods in the next days. Im curious to hear the authors opinion ( good job, nice mod btw 👍 ).
esx_weaponshop integration
- Add rank column
alter table sesx.weashops add column rank int default 0;
Maybe change your database scheme from sesx
to whatever yours is.
Storing ranks in db feels better than in config files, but other mods will require adding config values for rank checking.
Balancing the weapon ranks in db will be tested, can not recommend anything yet.
- Alter weaponshops code to respect and show new
rank
column
Server side, add rank column to database reading functions and check when buying:
diff --git a/resources/[esx]/esx_weaponshop/server/main.lua b/resources/[esx]/esx_weaponshop/server/main.lua
index c2b0b65..5583ff2 100644
--- a/resources/[esx]/esx_weaponshop/server/main.lua
+++ b/resources/[esx]/esx_weaponshop/server/main.lua
@@ -14,7 +14,8 @@ MySQL.ready(function()
table.insert(shopItems[result[i].zone], {
item = result[i].item,
price = result[i].price,
- label = ESX.GetWeaponLabel(result[i].item)
+ label = ESX.GetWeaponLabel(result[i].item),
+ rank = result[i].rank
})
end
@@ -45,6 +46,15 @@ end)
ESX.RegisterServerCallback('esx_weaponshop:buyWeapon', function(source, cb, weaponName, zone)
local xPlayer = ESX.GetPlayerFromId(source)
local price = GetPrice(weaponName, zone)
+ local rank_needed = GetRank(weaponName, zone)
+
+ local playerRank = xPlayer.get("rank")
+
+ if playerRank < rank_needed then
+ xPlayer.showNotification("Rank too low!")
+ cb(false)
+ return
+ end
if price == 0 then
print(('esx_weaponshop: %s attempted to buy a unknown weapon!'):format(xPlayer.identifier))
@@ -79,6 +89,19 @@ ESX.RegisterServerCallback('esx_weaponshop:buyWeapon', function(source, cb, weap
end
end)
+function GetRank(weaponName, zone)
+ local rank = MySQL.Sync.fetchScalar('SELECT rank FROM weashops WHERE zone = @zone AND item = @item', {
+ ['@zone'] = zone,
+ ['@item'] = weaponName
+ })
+
+ if rank then
+ return rank
+ else
+ return 0
+ end
+end
+
function GetPrice(weaponName, zone)
local price = MySQL.Sync.fetchScalar('SELECT price FROM weashops WHERE zone = @zone AND item = @item', {
['@zone'] = zone,
Client side, show rank in shop:
--- a/resources/[esx]/esx_weaponshop/client/main.lua
+++ b/resources/[esx]/esx_weaponshop/client/main.lua
@@ -56,9 +56,10 @@ function OpenShopMenu(zone)
for i=1, #Config.Zones[zone].Items, 1 do
local item = Config.Zones[zone].Items[i]
+ local rank = item.rank
table.insert(elements, {
- label = ('%s - <span style="color: green;">%s</span>'):format(item.label, _U('shop_menu_item', ESX.Math.GroupDigits(item.price))),
+ label = ('%s - <span style="color: green;">%s</span> (%s)'):format(item.label, _U('shop_menu_item', ESX.Math.GroupDigits(item.price)), ESX.Math.GroupDigits(rank)),
price = item.price,
weaponName = item.item
})
from esx_xp.
Related Issues (20)
- screeen issue HOT 1
- level for weapon
- get xp with job
- xp for killing AI and other players HOT 12
- weapon level
- leaderboard busted HOT 1
- Level Up Bug HOT 2
- [HELP] Detach Leaderboard from EXP bar HOT 1
- Nice script HOT 1
- Level Not Up
- 2 of 30 users I have don't work with the system HOT 1
- Leaderboard not updating
- How can I get xp when killing a player? HOT 1
- esx_jobs
- How can player get 2xp for playing 1 minute? HOT 1
- Lock the vehicle when reaching a pre-determined rank
- creating job only for battlepass?
- Invalid ID
- Hi, I have been trying to make it work for when you kill a player, but when testing it with your code, upload the xp all the time until the player revives, do you know any way to fix it?
- hey i want to a level reward but idk how it works im kinda new to lua
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esx_xp.