Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 2293967

Browse files
committed
1.50 RELEASE
- Now Supporting new mx-multicharacter - New commands added: start, stop, refresh
1 parent 1f617e1 commit 2293967

4 files changed

Lines changed: 123 additions & 85 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
- Can give job
1616
- Can give item
1717
- Can show active players
18+
- Can setcoords for player
19+
- Can start script
20+
- Can stop script
21+
- Can refresh scripts
1822

1923
# Images
2024
<a href="https://ibb.co/PcHQrvk"><img src="https://i.ibb.co/7nm4Sdh/image.png" alt="image" border="0"></a>
@@ -31,6 +35,14 @@
3135
- server.cfg > `ensure mx-servermanbot` `mx-bansystem`
3236
- Shift + right click on the `mx-servermanbot` folder and click `Open PowerShell window here`
3337
- write `npm i`
38+
- For start, refresh, stop commands add ur server.cfg >
39+
```
40+
# MX-SERVERMAN
41+
add_ace resource.mx-servermanbot command.start allow
42+
add_ace resource.mx-servermanbot command.ensure allow
43+
add_ace resource.mx-servermanbot command.stop allow
44+
add_ace resource.mx-servermanbot command.refresh allow
45+
```
3446

3547
## Config.json
3648
- Discord Application: https://discord.com/developers/applications/

bot.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@ StartBot = () => {
103103
msg.channel.send(embed)
104104
return false;
105105
}
106+
}else if (args[0] == config.prefix + 'start') {
107+
if (args[1]) {
108+
return exports['mx-servermanbot'].start(args[1]);
109+
}else {
110+
embed
111+
.setColor('#ff0000')
112+
.setTitle('Usage: !start `script name`')
113+
.setAuthor('Incorrect Command Usage.')
114+
msg.channel.send(embed)
115+
return false;
116+
}
117+
}else if (args[0] == config.prefix + 'stop') {
118+
if (args[1]) {
119+
return exports['mx-servermanbot'].stop(args[1]);
120+
}else {
121+
embed
122+
.setColor('#ff0000')
123+
.setTitle('Usage: !stop `script name`')
124+
.setAuthor('Incorrect Command Usage.')
125+
msg.channel.send(embed)
126+
return false;
127+
}
128+
}else if (args[0] == config.prefix + 'refresh') {
129+
return exports['mx-servermanbot'].refresh(args[1]);
106130
}else if (args[0] == config.prefix + 'setcoords') {
107131
if (args[1] && args[2] && args[3] && args[4] && Number(args[2]) && Number(args[3]) && Number(args[4])) {
108132
return exports['mx-servermanbot'].SetCoords(args[1], args[2], args[3], args[4]);
@@ -298,6 +322,9 @@ StartBot = () => {
298322
.addField('giveitem', '**Add Item**', true)
299323
.addField('refreshwhitelist', '**Refresh Whitelist**', true)
300324
.addField('setcoords', '**Set Player Coords / Teleport**', true)
325+
.addField('start', '**Start Script**', true)
326+
.addField('stop', '**Stop Script**', true)
327+
.addField('refresh', '**Refresh Scripts**', true)
301328
msg.channel.send(embed);
302329
return false;
303330
}else if (args[0] == config.prefix + 'bannedplayers') {

config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"user_accounts": false,
1212
"user_inventory": false
1313
},
14-
"mx-multicharacter": false,
1514
"identifier": "license",
1615
"wipe_tables": [
1716
{"table": "users", "owner": "identifier"},

server.lua

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,10 @@ exports('Wipe', function (id)
123123
if GetPlayerName(id) then
124124
local fetch = [[SELECT identifier FROM users WHERE identifier = @id]]
125125
local fetchData = {['@id'] = Identifier(id)}
126-
if Config['mx-multicharacter'] then
127-
fetch = [[SELECT identifier FROM users WHERE citizenid = @id;]]
128-
fetchData = {['@id'] = exports['mx-multicharacter']:GetCitizenId(id)}
129-
end
130126
local result = MySQL.Sync.fetchAll(fetch, fetchData)
131127
if result and result[1] then
132128
for _, v in pairs(Config.wipe_tables) do
133-
if not Config['mx-multicharacter'] then
134-
MySQL.Sync.execute("DELETE FROM `"..v.table.."` WHERE `"..v.owner.."` = '"..Identifier(id).."'")
135-
else
136-
MySQL.Sync.execute("DELETE FROM `"..v.table.."` WHERE `"..v.owner.."` = '"..exports['mx-multicharacter']:GetCitizenId(id).."'")
137-
end
129+
MySQL.Sync.execute("DELETE FROM `"..v.table.."` WHERE `"..v.owner.."` = '"..Identifier(id).."'")
138130
end
139131
local embed = {
140132
description = GetPlayerName(id).." Wiped",
@@ -154,9 +146,6 @@ exports('Wipe', function (id)
154146
else
155147
local fetch = [[SELECT identifier FROM users WHERE identifier = @id;]]
156148
local fetchData = {['@id'] = id}
157-
if Config['mx-multicharacter'] then
158-
fetch = [[SELECT citizenid FROM users WHERE citizenid = @id;]]
159-
end
160149
local result = MySQL.Sync.fetchAll(fetch, fetchData)
161150
if result and result[1] then
162151
for _, v in ipairs(Config.wipe_tables) do
@@ -230,9 +219,6 @@ exports('GetInventory', function (id)
230219
else
231220
local fetch = [[SELECT inventory FROM users WHERE identifier = @id;]]
232221
local fetchData = {['@id'] = id}
233-
if Config['mx-multicharacter'] then
234-
fetch = [[SELECT inventory FROM users WHERE citizenid = @id]]
235-
end
236222
local result = MySQL.Sync.fetchAll(fetch, fetchData)
237223
if result and result[1] then
238224
local embed = {
@@ -323,9 +309,6 @@ exports('GetMoney', function (id)
323309
else
324310
local fetch = [[SELECT accounts FROM users WHERE identifier = @id;]]
325311
local fetchData = {['@id'] = id}
326-
if Config['mx-multicharacter'] then
327-
fetch = [[SELECT accounts FROM users WHERE citizenid = @id;]]
328-
end
329312
local result = MySQL.Sync.fetchAll(fetch, fetchData)
330313
if result and result[1] then
331314
local embed = {
@@ -377,12 +360,8 @@ exports('GetGeneralInformations', function (id)
377360
if GetPlayerName(id) then
378361
local fetch = [[SELECT * FROM users WHERE identifier = @id;]]
379362
local fetchData = {['@id'] = Identifier(id)}
380-
if Config['mx-multicharacter'] then
381-
fetch = [[SELECT firstname, lastname, dateofbirth, sex, job FROM users WHERE citizenid = @id;]]
382-
fetchData = {['@id'] = exports['mx-multicharacter']:GetCitizenId(id)}
383-
end
384363
local result = MySQL.Sync.fetchAll(fetch, fetchData)
385-
local ident = Config['mx-multicharacter'] and exports['mx-multicharacter']:GetCitizenId(id) or Identifier(id)
364+
local ident = Identifier(id)
386365
if result and result[1] then
387366
local job = GetJobProps(result[1].job, result[1].job_grade)
388367
local discord = GetDiscord(id) or 'Not Finded'
@@ -413,9 +392,6 @@ exports('GetGeneralInformations', function (id)
413392
else
414393
local fetch = [[SELECT * FROM users WHERE identifier = @id]]
415394
local fetchData = {['@id'] = id}
416-
if Config['mx-multicharacter'] then
417-
fetch = [[SELECT * FROM users WHERE citizenid = @id;]]
418-
end
419395
local result = MySQL.Sync.fetchAll(fetch, fetchData)
420396
if result and result[1] then
421397
local job = GetJobProps(result[1].job, result[1].job_grade)
@@ -497,20 +473,13 @@ exports('AddMoney', function (id, type, amount)
497473
else
498474
local fetch = [[SELECT accounts FROM users WHERE identifier = @id]]
499475
local fetchData = {['@id'] = id}
500-
if Config['mx-multicharacter'] then
501-
fetch = [[SELECT accounts FROM users WHERE citizenid = @id;]]
502-
end
503476
local result = MySQL.Sync.fetchAll(fetch, fetchData)
504477
if result and result[1] then
505478
if result[1].accounts and json.decode(result[1].accounts) then
506479
local accounts = json.decode(result[1].accounts)
507480
local oldMoney = accounts[type]
508481
accounts[type] = math.floor(accounts[type] + tonumber(amount))
509-
if not Config['mx-multicharacter'] then
510-
MySQL.Sync.execute('UPDATE users SET accounts = @accounts WHERE identifier = @id', {['@accounts'] = json.encode(accounts), ['@id'] = id})
511-
else
512-
MySQL.Sync.execute('UPDATE users SET accounts = @accounts WHERE citizenid = @id', {['@accounts'] = json.encode(accounts), ['@id'] = id})
513-
end
482+
MySQL.Sync.execute('UPDATE users SET accounts = @accounts WHERE identifier = @id', {['@accounts'] = json.encode(accounts), ['@id'] = id})
514483
local embed = {
515484
color = "#0094ff", -- blue
516485
title = '`'..GetPlayerName(id)..'` gived `'..amount..'` \nOld Balance: `'..oldMoney..'` \nNew Balance: `'..accounts[type]..'` \nType: `'..type..'`',
@@ -560,24 +529,13 @@ exports('SetJob', function(id, job, grade)
560529
else
561530
local fetch = [[SELECT job, job_grade FROM users WHERE identifier = @id]]
562531
local fetchData = {['@id'] = id}
563-
if Config['mx-multicharacter'] then
564-
fetch = [[SELECT job, job_grade FROM users WHERE citizenid = @id;]]
565-
end
566532
local result = MySQL.Sync.fetchAll(fetch, fetchData)
567533
if result and result[1] then
568-
if not Config['mx-multicharacter'] then
569-
MySQL.Sync.execute('UPDATE users SET job = @job, job_grade = @grade WHERE identifier = @id', {
570-
['@job'] = job,
571-
['@grade'] = grade,
572-
['@id'] = id
573-
})
574-
else
575-
MySQL.Sync.execute('UPDATE users SET job = @job, job_grade = @grade WHERE citizenid = @id', {
576-
['@job'] = job,
577-
['@grade'] = grade,
578-
['@id'] = id
579-
})
580-
end
534+
MySQL.Sync.execute('UPDATE users SET job = @job, job_grade = @grade WHERE identifier = @id', {
535+
['@job'] = job,
536+
['@grade'] = grade,
537+
['@id'] = id
538+
})
581539
local embed = {
582540
color = "#0094ff", -- blue
583541
title = id..' setted job \nOld Job: `'..result[1].job..'`\nNew Job: `'..job..'` \nOld Grade: `'..result[1].job_grade..'` \nNew Grade: `'..grade..'`',
@@ -655,20 +613,13 @@ exports('RemoveMoney', function (id, type, amount)
655613
else
656614
local fetch = [[SELECT accounts FROM users WHERE identifier = @id]]
657615
local fetchData = {['@id'] = id}
658-
if Config['mx-multicharacter'] then
659-
fetch = [[SELECT accounts FROM users WHERE citizenid = @id;]]
660-
end
661616
local result = MySQL.Sync.fetchAll(fetch, fetchData)
662617
if result and result[1] then
663618
if result[1].accounts and json.decode(result[1].accounts) then
664619
local accounts = json.decode(result[1].accounts)
665620
local oldMoney = accounts[type]
666621
accounts[type] = math.floor(accounts[type] - tonumber(amount))
667-
if not Config['mx-multicharacter'] then
668-
MySQL.Sync.execute('UPDATE users SET accounts = @accounts WHERE identifier = @id', {['@accounts'] = json.encode(accounts), ['@id'] = id})
669-
else
670-
MySQL.Sync.execute('UPDATE users SET accounts = @accounts WHERE citizenid = @id', {['@accounts'] = json.encode(accounts), ['@id'] = id})
671-
end
622+
MySQL.Sync.execute('UPDATE users SET accounts = @accounts WHERE identifier = @id', {['@accounts'] = json.encode(accounts), ['@id'] = id})
672623
local embed = {
673624
color = "#0094ff", -- blue
674625
title = '`'..id..'` taked `'..tonumber(amount)..'` \nOld Balance: `'..oldMoney..'` \nNew Balance: `'..accounts[type]..'` \nType: `'..type..'`',
@@ -707,42 +658,25 @@ exports('GiveItem', function (id, name, count)
707658
else
708659
local fetch = [[SELECT inventory FROM users WHERE identifier = @id]]
709660
local fetchData = {['@id'] = id}
710-
if Config['mx-multicharacter'] then
711-
fetch = [[SELECT inventory FROM users WHERE citizenid = @id]]
712-
end
713661
local result = MySQL.Sync.fetchAll(fetch, fetchData)
714662
if result and result[1] then
715663
if result[1].inventory then
716664
local inventory = json.decode(result[1].inventory)
717665
inventory[name] = inventory[name] >= 0 and count + inventory[name]
718-
if not Config['mx-multicharacter'] then
719-
MySQL.Sync.execute('UPDATE users SET inventory = @inv WHERE identifier = @id', {
720-
['@id'] = id,
721-
['@inv'] = json.encode(inventory)
722-
})
723-
else
724-
MySQL.Sync.execute('UPDATE users SET inventory = @inv WHERE citizenid = @id', {
725-
['@id'] = id,
726-
['@inv'] = json.encode(inventory)
727-
})
728-
end
666+
MySQL.Sync.execute('UPDATE users SET inventory = @inv WHERE identifier = @id', {
667+
['@id'] = id,
668+
['@inv'] = json.encode(inventory)
669+
})
729670
local embed = {
730671
color = "#0094ff", -- blue
731672
title = '`'..id..'` gived item. \nItem name:`'..name..'` \nCount: `'..count..'`',
732673
}
733674
TriggerEvent('mx-serverman:SendEmbed', embed)
734675
else
735-
if not Config['mx-multicharacter'] then
736-
MySQL.Sync.execute('UPDATE users SET inventory = @inv WHERE identifier = @id', {
737-
['@id'] = id,
738-
['@inv'] = json.encode({name = count})
739-
})
740-
else
741-
MySQL.Sync.execute('UPDATE users SET inventory = @inv WHERE citizenid = @id', {
742-
['@id'] = id,
743-
['@inv'] = json.encode({name = count})
744-
})
745-
end
676+
MySQL.Sync.execute('UPDATE users SET inventory = @inv WHERE identifier = @id', {
677+
['@id'] = id,
678+
['@inv'] = json.encode({name = count})
679+
})
746680
local embed = {
747681
color = "#0094ff", -- blue
748682
title = '`'..id..'` gived item. \nItem name:`'..name..'` \nCount: `'..count..'`',
@@ -778,7 +712,7 @@ exports('GetPlayers', function ()
778712
local discord = GetDiscord(players[i]) or 'Not Finded'
779713
embed.fields[1].value = embed.fields[1].value..GetPlayerName(players[i])..' ['..players[i]..']'
780714
embed.fields[2].value = embed.fields[2].value..'<@'..discord..'>'
781-
embed.fields[3].value = Config['mx-multicharacter'] and embed.fields[3].value..xPlayer.citizenid or embed.fields[3].value..xPlayer.identifier
715+
embed.fields[3].value = embed.fields[3].value..xPlayer.identifier
782716
end
783717
end
784718
TriggerEvent('mx-serverman:SendEmbed', embed)
@@ -801,6 +735,72 @@ exports('Revive', function (id)
801735
TriggerEvent('mx-serverman:SendEmbed', embed)
802736
end
803737
end)
738+
exports('start', function(name)
739+
local find = false
740+
for i = 1, GetNumResources() do
741+
local resource_id = i - 1
742+
local resource_name = GetResourceByFindIndex(resource_id)
743+
if name == resource_name then
744+
find = true
745+
break
746+
end
747+
end
748+
if find then
749+
local embed = {
750+
color = "#0094ff", -- blue
751+
title = name..' Started.',
752+
}
753+
ExecuteCommand('ensure '..name)
754+
TriggerEvent('mx-serverman:SendEmbed', embed)
755+
else
756+
local embed = {
757+
color = "#0094ff", -- blue
758+
title = 'Script not found!',
759+
}
760+
TriggerEvent('mx-serverman:SendEmbed', embed)
761+
end
762+
end)
763+
exports('stop', function(name)
764+
local find = false
765+
for i = 1, GetNumResources() do
766+
local resource_id = i - 1
767+
local resource_name = GetResourceByFindIndex(resource_id)
768+
if name == resource_name then
769+
find = true
770+
break
771+
end
772+
end
773+
if find then
774+
if GetResourceState(name) ~= 'stopped' then
775+
local embed = {
776+
color = "#0094ff", -- blue
777+
title = name..' Stopped.',
778+
}
779+
ExecuteCommand('stop '..name)
780+
TriggerEvent('mx-serverman:SendEmbed', embed)
781+
else
782+
local embed = {
783+
color = "#0094ff", -- blue
784+
title = 'The script is already closed!',
785+
}
786+
TriggerEvent('mx-serverman:SendEmbed', embed)
787+
end
788+
else
789+
local embed = {
790+
color = "#0094ff", -- blue
791+
title = 'Script not found!',
792+
}
793+
TriggerEvent('mx-serverman:SendEmbed', embed)
794+
end
795+
end)
796+
exports('refresh', function ()
797+
local embed = {
798+
color = "#0094ff", -- blue
799+
title = 'Scripts have been refreshed.',
800+
}
801+
ExecuteCommand('refresh')
802+
TriggerEvent('mx-serverman:SendEmbed', embed)
803+
end)
804804
exports('ReviveAll', function ()
805805
TriggerEvent('esx:getSharedObject', function(ESX)
806806
local players = ESX.GetPlayers()

0 commit comments

Comments
 (0)