Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ITEMS = {}
- local inventory_table = {}
- AddEventHandler("playerSpawned", function()
- RegisterNetEvent("item:getItems")
- TriggerServerEvent("item:getItems")
- end)
- RegisterNetEvent("gui:getItems")
- AddEventHandler("gui:getItems", function(THEITEMS)
- ITEMS = {}
- ITEMS = THEITEMS
- InventoryMenu()
- end)
- AddEventHandler("player:receiveItem", function(item, quantity)
- item = tonumber(item)
- if (ITEMS[item] == nil) then
- new(item, quantity)
- else
- add({ item, quantity })
- end
- end)
- AddEventHandler("player:looseItem", function(item, quantity)
- item = tonumber(item)
- if (ITEMS[item].quantity >= quantity) then
- delete({ item, quantity })
- else
- Chat("Vous n'avez pas assez de ressources")
- end
- end)
- function new(item, quantity)
- RegisterNetEvent("item:setItem")
- TriggerServerEvent("item:setItem", item, quantity)
- TriggerServerEvent("item:getItems")
- end
- function dump(o)
- if type(o) == 'table' then
- local s = '{ '
- for k,v in pairs(o) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. dump(v) .. ','
- end
- return s .. '} '
- else
- return tostring(o)
- end
- end
- function delete(arg)
- local itemId = tonumber(arg[1])
- local qty = arg[2]
- local item = ITEMS[itemId]
- item.quantity = item.quantity - qty
- RegisterNetEvent("item:updateQuantity")
- TriggerServerEvent("item:updateQuantity", item.quantity, itemId)
- TriggerEvent("farm:updateQuantity", item.quantity, itemId)
- InventoryMenu()
- end
- function add(arg)
- local itemId = tonumber(arg[1])
- local qty = arg[2]
- local item = ITEMS[itemId]
- item.quantity = item.quantity + qty
- RegisterNetEvent("item:updateQuantity")
- TriggerServerEvent("item:updateQuantity", item.quantity, itemId)
- TriggerEvent("farm:updateQuantity", item.quantity, itemId)
- InventoryMenu()
- end
- function InventoryMenu()
- for k,v in pairs(inventory_table) do
- inventory_table[k] = nil
- end
- for k, v in pairs(ITEMS) do
- if (v.quantity > 0) then
- table.insert(inventory_table, {title = v.quantity .. " " .. tostring(v.libelle), name = tostring(v.libelle)})
- end
- end
- end
- RegisterNetEvent("farm:updateQuantity")
- AddEventHandler("farm:updateQuantity", function(qty, id)
- TriggerEvent('chatMessage', "", {255, 0, 0}, ITEMS[id].quantity)
- ITEMS[id].quantity = qty
- TriggerEvent('chatMessage', "", {255, 0, 0}, ITEMS[id].quantity)
- end)
- local pmenu = {
- opened = false,
- title = "Menu Personnel",
- currentmenu = "main",
- lastmenu = nil,
- currentpos = nil,
- selectedbutton = 0,
- marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
- menu = {
- x = 0.1,
- y = 0.26,
- width = 0.2,
- height = 0.04,
- buttons = 10,
- from = 1,
- to = 10,
- scale = 0.4,
- font = 0,
- ["main"] = {
- title = "CATEGORIES",
- name = "main",
- buttons = {
- {title = "Inventaire", name = "Inventaire", description = ""},
- {title = "Animations", name = "Animations", description = ""},
- {title = "Objets", name = "Objets", description = ""},
- {title = "Téléphone (WIP)", name = "TelephoneWIP", description = ""},
- {title = "Carté d'identité (WIP)", name = "CarteidentiteWIP", description = ""},
- {title = "Donner de l'argent (WIP)", name = "DonnerdelargentWIP", description = ""},
- }
- },
- ["Inventaire"] = {
- title = "Inventaire",
- name = "Inventaire",
- buttons = inventory_table
- -- {title = "Couteau", name = "Knife", costs = 400, description = {}, model = "WEAPON_Knife"},
- -- }
- },
- ["InventaireSelect"] = {
- title = "INVENTAIRE",
- name = "InventaireSelect",
- buttons = {
- {title = "Jeter (WIP)", name = "drop"},
- }
- },
- ["Animations"] = {
- title = "ANIMATIONS",
- name = "Animations",
- buttons = {
- {title = "Annuler Animation", emote = "STOP EMOTE"},
- {title = "Applaudire", emote = "WORLD_HUMAN_CHEERING"},
- {title = "Allongé par terre", emote = "WORLD_HUMAN_BUM_SLUMPED"},
- {title = "Regarder sa carte", emote = "WORLD_HUMAN_TOURIST_MAP"},
- {title = "Faire du Yoga", emote = "WORLD_HUMAN_YOGA"},
- {title = "Faire des pompes", emote = "WORLD_HUMAN_PUSH_UPS"},
- {title = "Montrer ses muscles", emote = "WORLD_HUMAN_MUSCLE_FLEX"},
- {title = "Lever des haltères", emote = "WORLD_HUMAN_MUSCLE_FREE_WEIGHTS"},
- {title = "Faire des abdo", emote = "WORLD_HUMAN_SIT_UPS"},
- {title = "Faire des tractions", emote = "PROP_HUMAN_MUSCLE_CHIN_UPS"},
- {title = "Fumer une cigarette", emote = "WORLD_HUMAN_SMOKING"},
- {title = "Fumer un buzz1", emote = "WORLD_HUMAN_SMOCKING_POT"},
- {title = "Fumer un buzz2", emote = "WORLD_HUMAN_DRUG_DEALER"},
- {title = "Café", emote = "WORLD_HUMAN_AA_COFFEE"},
- {title = "Café2", emote = "WORLD_HUMAN_DRINKING"},
- {title = "Clipboard", emote = "WORLD_HUMAN_CLIPBOARD"},
- {title = "Photo", emote = "WORLD_HUMAN_PAPARAZZI"},
- {title = "Jumelle", emote = "WORLD_HUMAN_BINOCULARS"},
- {title = "Jouer de la musique", emote = "WORLD_HUMAN_MUSICIAN"},
- {title = "Se laver comme un clochard", emote = "WORLD_HUMAN_BUM_WASH"},
- {title = "Pancarte de clochard", emote = "WORLD_HUMAN_BUM_FREEWAY"},
- {title = "Fouiler", emote = "PROP_HUMAN_BUM_BIN"},
- {title = "Faire la circulation", emote = "WORLD_HUMAN_CAR_PARK_ATTENDANT"},
- {title = "jardiner", emote = "WORLD_HUMAN_GARDENER_PLANT"},
- {title = "utiliser un marteau", emote = "WORLD_HUMAN_HAMMERING"},
- {title = "posture de garde", emote = "WORLD_HUMAN_GUARD_STAND"},
- {title = "Chill", emote = "WORLD_HUMAN_LEANING"},
- {title = "Faire la teuf", emote = "WORLD_HUMAN_PARTYING"},
- {title = "S'assoir par terre", emote = "WORLD_HUMAN_PICNIC"},
- {title = "Nettoyer", emote = "WORLD_HUMAN_MAID_CLEAN"},
- {title = "Faire le tapin luxe", emote = "WORLD_HUMAN_PROSTITUTE_HIGH_CLASS"},
- {title = "Faire le tapin pauvre", emote = "WORLD_HUMAN_PROSTITUTE_LOW_CLASS"},
- {title = "Se rechauffer les mains", emote = "WORLD_HUMAN_STAND_FIRE"},
- {title = "Pécher", emote = "WORLD_HUMAN_STAND_FISHING"},
- {title = "Utiliser sont portable", emote = "WORLD_HUMAN_STAND_MOBILE"},
- {title = "Prendre un selfie", emote = "WORLD_HUMAN_TOURIST_MOBILE"},
- {title = "Dur Dur l'alcool", emote = "WORLD_HUMAN_STUPOR"},
- {title = "Allongé sur le ventre", emote = "WORLD_HUMAN_SUNBATHE"},
- {title = "Allongé sur le dos", emote = "WORLD_HUMAN_SUNBATHE_BACK"},
- {title = "Faire de la mecanique", emote = "WORLD_HUMAN_VEHICULE_MECHANIC"},
- {title = "Souder", emote = "WORLD_HUMAN_WELDING"},
- {title = "Faire un BBQ", emote = "PROP_HUMAN_BBQ"},
- {title = "S'appuyer contre un mur", emote = "PROP_HUMAN_BUM_SHOPPING_CART"},
- {title = "Prendre des notes", emote = "CODE_HUMAN_MEDIC_TIME_OF_DEATH"},
- }
- },
- ["Objets"] = {
- title = "Objets",
- name = "Objets",
- buttons = {
- {title = "Prendre Mallette 1", hash = "WEAPON_BRIEFCASE"},
- {title = "Prendre Mallette 2", hash = "WEAPON_BRIEFCASE_02"},
- {title = "Prendre digiscanner 1", hash = "WEAPON_DIGISCANNER"},
- }
- },
- ["Telephone"] = {
- title = "TELEPHONE",
- name = "Telephone",
- buttons = {
- {title = "Répertoire", name = "Pistol", model = "WEAPON_Pistol"},
- {title = "Police", name = "CombatPistol", model = "WEAPON_CombatPistol"},
- {title = "Médecin", name = "Pistol50", model = "WEAPON_PISTOL50"},
- {title = "Taxi", name = "HeavyPistol", model = "WEAPON_HeavyPistol"},
- {title = "Dépanneur", name = "VintagePistol", model = "WEAPON_VintagePistol"},
- {title = "Journaliste", name = "APPistol", model = "WEAPON_APPistol"},
- }
- },
- ["Carteidentite"] = {
- title = "CARTE DIDENTITE",
- name = "Carteidentite",
- buttons = {
- {title = "TEST", name = "MicroSMG", model = "WEAPON_MicroSMG"},
- {title = "TEST", name = "MachinePistol", model = "WEAPON_MachinePistol"},
- {title = "TEST", name = "SMG", model = "WEAPON_SMG"},
- {title = "TEST", name = "AssaultSMG", model = "WEAPON_AssaultSMG"},
- {title = "TEST", name = "CombatPDW", model = "WEAPON_CombatPDW"},
- {title = "TEST", name = "Gusenberg", model = "WEAPON_Gusenberg"},
- }
- },
- ["Donnerdelargent"] = {
- title = "DONNER DE LARGENT",
- name = "Donnerdelargent",
- buttons = {
- {title = "TEST", name = "PumpShotgun", description = {}, model = "WEAPON_PumpShotgun"},
- {title = "TEST", name = "SawnoffShotgun", description = {}, model = "WEAPON_SawnoffShotgun"},
- }
- },
- }
- }
- local function LocalPed()
- return GetPlayerPed(-1)
- end
- function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
- SetTextFont(font)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(1, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextCentre(centre)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x , y)
- end
- function f(n)
- return n + 0.0001
- end
- function LocalPed()
- return GetPlayerPed(-1)
- end
- function try(f, catch_f)
- local status, exception = pcall(f)
- if not status then
- catch_f(exception)
- end
- end
- function firstToUpper(str)
- return (str:gsub("^%l", string.upper))
- end
- --local veh = nil
- function OpenCreator()
- boughtWeapon = false
- local ped = GetPlayerPed(-1)
- pmenu.currentmenu = "main"
- pmenu.opened = true
- pmenu.selectedbutton = 0
- end
- function CloseCreator()
- Citizen.CreateThread(function()
- local ped = GetPlayerPed(-1)
- pmenu.opened = false
- pmenu.menu.from = 1
- pmenu.menu.to = 10
- end)
- end
- function drawMenuButton(button,x,y,selected)
- local menu = pmenu.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(button.title)
- if selected then
- DrawRect(x,y,menu.width,menu.height,255,255,255,255)
- else
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- end
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function drawMenuTitle(txt,x,y)
- local menu = pmenu.menu
- SetTextFont(2)
- SetTextProportional(0)
- SetTextScale(0.5, 0.5)
- SetTextColour(255, 255, 255, 255)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- local backlock = false
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- -- drawTxt(dump(pmenu.menu["Animations"].buttons),0,1,0.5,0.75,0.2,255,255,255,255)
- -- drawTxt(dump(pmenu.menu["Inventaire"].buttons),0,1,0.5,0.80,0.2,255,255,255,255)
- -- drawTxt(dump(inventory_table),0,1,0.5,0.85,0.2,255,255,255,255)
- -- drawTxt(dump(ITEMS),0,1,0.5,0.9,0.4,255,255,255,255)
- -- drawTxt(pmenu.menu["Inventaire"].title),0,1,0.5,0.95,0.4,255,255,255,255)
- if IsControlJustPressed(1,246) then
- if pmenu.opened then
- CloseCreator()
- else
- OpenCreator()
- end
- end
- if pmenu.opened then
- local ped = LocalPed()
- local menu = pmenu.menu[pmenu.currentmenu]
- drawTxt(pmenu.title,1,1,pmenu.menu.x,pmenu.menu.y,1.0, 255,255,255,255)
- drawMenuTitle(menu.title, pmenu.menu.x,pmenu.menu.y + 0.08)
- drawTxt(pmenu.selectedbutton.."/"..tablelength(menu.buttons),0,0,pmenu.menu.x + pmenu.menu.width/2 - 0.0385,pmenu.menu.y + 0.067,0.4, 255,255,255,255)
- local y = pmenu.menu.y + 0.12
- buttoncount = tablelength(menu.buttons)
- local selected = false
- for i,button in pairs(menu.buttons) do
- if i >= pmenu.menu.from and i <= pmenu.menu.to then
- if i == pmenu.selectedbutton then
- selected = true
- else
- selected = false
- end
- drawMenuButton(button,pmenu.menu.x,y,selected)
- y = y + 0.04
- if selected and IsControlJustPressed(1,201) then
- ButtonSelected(button)
- end
- end
- end
- end
- if pmenu.opened then
- if IsControlJustPressed(1,202) then
- Back()
- end
- if IsControlJustReleased(1,202) then
- backlock = false
- end
- if IsControlJustPressed(1,188) then
- if pmenu.selectedbutton > 1 then
- pmenu.selectedbutton = pmenu.selectedbutton -1
- if buttoncount > 10 and pmenu.selectedbutton < pmenu.menu.from then
- pmenu.menu.from = pmenu.menu.from -1
- pmenu.menu.to = pmenu.menu.to - 1
- end
- end
- end
- if IsControlJustPressed(1,187)then
- if pmenu.selectedbutton < buttoncount then
- pmenu.selectedbutton = pmenu.selectedbutton +1
- if buttoncount > 10 and pmenu.selectedbutton > pmenu.menu.to then
- pmenu.menu.to = pmenu.menu.to + 1
- pmenu.menu.from = pmenu.menu.from + 1
- end
- end
- end
- end
- end
- end)
- function round(num, idp)
- if idp and idp>0 then
- local mult = 10^idp
- return math.floor(num * mult + 0.5) / mult
- end
- return math.floor(num + 0.5)
- end
- function ButtonSelected(button)
- local ped = GetPlayerPed(-1)
- local this = pmenu.currentmenu
- local btn = button.name
- if this == "main" then
- if btn == "Inventaire" then
- OpenMenu('Inventaire')
- elseif btn == "Animations" then
- OpenMenu('Animations')
- elseif btn == "Objets" then
- OpenMenu('Objets')
- elseif btn == "Telephone" then
- OpenMenu('Telephone')
- elseif btn == "Carteidentite" then
- OpenMenu('Carteidentite')
- elseif btn == "Donnerdelargent" then
- OpenMenu('Donnerdelargent')
- end
- elseif this == "Inventaire" then
- OpenMenu('InventaireSelect')
- elseif this == "Animations" then
- if ped and button.emote == "STOP EMOTE" then
- ClearPedTasks(ped)
- elseif ped then
- ClearPedTasks(ped)
- TaskStartScenarioInPlace(ped, button.emote, 0, true)
- end
- elseif this == "Objets" then
- if ped then
- GiveDelayedWeaponToPed(PlayerPedId(), GetHashKey(button.hash), 1000, true)
- end
- end
- end
- function OpenMenu(menu)
- pmenu.lastmenu = pmenu.currentmenu
- pmenu.menu.from = 1
- pmenu.menu.to = 10
- pmenu.selectedbutton = 0
- pmenu.currentmenu = menu
- end
- function Back()
- if backlock then
- return
- end
- backlock = true
- if pmenu.currentmenu == "main" then
- boughtWeapon = false
- CloseCreator()
- elseif pmenu.currentmenu == "Inventaire" then
- OpenMenu("main")
- else
- OpenMenu(pmenu.lastmenu)
- end
- end
- function stringstarts(String,Start)
- return string.sub(String,1,string.len(Start))==Start
- end
- function Chat(debugg)
- TriggerEvent("chatMessage", '', { 0, 0x99, 255 }, tostring(debugg))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement