Jump to content

MTA gun crafting system


Hribec

Recommended Posts

Hi, i need help from someone who knows smthing about scripting with OWL 2020.

i created script which should let me create a weapon, everything works fine, it will took me materials from inventory but wouldnt give me a gun that i wanted to create in the end... imma show yall example of my script... Thanks forward for every advice u give me.

------

function colt(thePlayer, staniceel)
    local itemy = {310, 310, 310, 310, 310, 310, 303}
       
    if not exports.global:hasSpaceForItem(thePlayer, vahaz) then
        setElementData(thePlayer, "vyrabeni", false)
 
        setElementData(staniceel, "vyrabeni", false)
        outputChatBox("Tvůj inventář je plný.", thePlayer, 255, 0, 0, true)
        return
    end
 
    if (6 > exports['item-system']:countItems(thePlayer, 310, 1)) or not exports.global:hasItem(thePlayer, 303) then
        setElementData(thePlayer, "vyrabeni", false)
 
        setElementData(staniceel, "vyrabeni", false)
        outputChatBox("Nemáš u sebe dostatek surovin pro výrobu.", thePlayer, 255, 0, 0)
        for i, v in ipairs(itemy) do
            outputChatBox(exports["item-system"]:getItemName(v), thePlayer, 255, 0, 0)
        end
        return
    else
        for k,itemy in ipairs(itemy) do
            exports.global:takeItem(thePlayer,itemy)
        end
 
        setTimer(function()
        local adminDBID = tonumber(getElementData(thePlayer, "account:character:id"))
        local playerDBID = tonumber(getElementData(thePlayer, "account:character:id"))
        local gSerial = exports.global:createWeaponSerial(1, adminDBID, playerDBID)
        local wepID = 22
        exports.global:giveItem(thePlayer, 115, wepID..":"..gSerial..":"..exports.weapon:getCustomWeaponName(wepID)..":0")
       
        end, cas, 1)
        triggerClientEvent(thePlayer, "vyrobka:progbar", thePlayer, nil, nil, staniceel)
    end
end
addEvent("vyrobka:colt", true)
addEventHandler("vyrobka:colt", getRootElement(), colt)

 

 

 

vyrabeni = craft, itemy = items, vyrobka = machine that creates guns, 

wepID = colt id from gunlist at my rp server.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...