@@ -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 .. ' ` \n Old Balance: `' .. oldMoney .. ' ` \n New Balance: `' .. accounts [type ].. ' ` \n Type: `' .. 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 \n Old Job: `' .. result [1 ].job .. ' `\n New Job: `' .. job .. ' ` \n Old Grade: `' .. result [1 ].job_grade .. ' ` \n New 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 ).. ' ` \n Old Balance: `' .. oldMoney .. ' ` \n New Balance: `' .. accounts [type ].. ' ` \n Type: `' .. 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. \n Item name:`' .. name .. ' ` \n Count: `' .. 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. \n Item name:`' .. name .. ' ` \n Count: `' .. 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
803737end )
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 )
804804exports (' ReviveAll' , function ()
805805 TriggerEvent (' esx:getSharedObject' , function (ESX )
806806 local players = ESX .GetPlayers ()
0 commit comments