Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2021-12-23, 19:48


Erczi







Wiek: 27
Na forum: 2371 dni
Posty: 17
Nick w MP: ewwe

Piwa: 4

Respekt: 50

Gdy odk?adam paczke nie daje mi kasy i expa a w debugu wyskakuje taki b??d


Kod:

local sx, sy = guiGetScreenSize()

local settings = {

job_markerpos = {3314.52, -434.43, 573.75},
job_int = 1,
pos_x = 1280,
pos_y = 720,
jobCode = "magazynier",
jobMarker = nil,
jobMarkerPos = {3312.81, -414.53, 573.75},
gui = false,
gui_2 = false,
caseTexture = dxCreateTexture("img/skrzynia.png", "argb", false, "clamp"),
targetMarker = nil,
targetBlip = nil,
playerPack = nil,

}

local positions = {

{3289.81, -441.02, 573.75},
{3285.61, -441.09, 573.75},
{3281.68, -441.33, 573.75},
{3263.26, -422.89, 573.75},


}

local w, h = (sx/settings.pos_x),(sy/settings.pos_y)
local zoom = 1
if sx < settings.pos_x then
zoom = math.min(2, settings.pos_x / sx)
end

addEventHandler( "onClientResourceStart", resourceRoot, function()
marker = createMarker(settings.job_markerpos[1], settings.job_markerpos[2], settings.job_markerpos[3]-1, "cylinder", 2, 255, 51, 204, 75)
setElementData(marker, "marker:text", "PRACA DORYWCZA - MAGAZYNIER")
setElementInterior(marker, settings.job_int)

addEventHandler( "onClientMarkerHit", marker, hitMarker)
addEventHandler( "onClientMarkerLeave", marker, leaveMarker)
end)

function warehouseJob()
dxDrawImage(385*w, 183*h, 520*w, 355*h, ":dmta_interface/img/background.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("PRACA DORYWCZA", 441*w, 183*h, 841*w, 227*h, tocolor(255, 255, 255, 255), 1/zoom, exports.dmta_interface:getGUIFont("normal15"), "center", "bottom", false, false, false, false, false)
dxDrawText("MAGAZYNIER", 441*w, 229*h, 841*w, 277*h, tocolor(255, 51, 204, 255), 1/zoom, exports.dmta_interface:getGUIFont("light10"), "center", "top", false, false, false, false, false)
if getElementData(localPlayer, "player:job") == settings.jobCode then
exports['dmta_buttons']:dxCreateButton("Zako?„cz prac?™", 570*w, 408*h, 150*w, 55*h, 1)
else
exports['dmta_buttons']:dxCreateButton("Pracuj", 570*w, 408*h, 150*w, 55*h, 1)
end
exports['dmta_buttons']:dxCreateButton("Zamknij", 570*w, 473*h, 150*w, 55*h, 2)
dxDrawText("Praca polega na odk?‚adaniu skrzy?„ na odpowiednie rega?‚y.", 441*w, 310*h, 841*w, 358*h, tocolor(255, 255, 255, 255), 1/zoom, exports.dmta_interface:getGUIFont("light10"), "center", "center", false, false, false, false, false)
end

function drawCase()
dxDrawImage(385*w, 183*h, 520*w, 355*h, ":dmta_interface/img/background.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("SKRZYNIA", 441*w, 429*h, 841*w, 277*h, tocolor(255, 255, 255, 255), 1/zoom, exports.dmta_interface:getGUIFont("normal15"), "center", "bottom", false, false, false, false, false)
dxDrawText("KLIKNIJ NA SKRZYNIE ABY J?„ PODNIEĹš?†", 441*w, 429*h, 841*w, 277*h, tocolor(255, 51, 204, 255), 1/zoom, exports.dmta_interface:getGUIFont("light10"), "center", "top", false, false, false, false, false)

if isMouseIn(590*w, 293*h, 100*w, 100*h) then
dxDrawImage(590*w, 293*h, 100*w, 100*h, settings.caseTexture, 0, 0, 0, tocolor(255, 255, 255, 155), false)
else
dxDrawImage(590*w, 293*h, 100*w, 100*h, settings.caseTexture, 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
end

function hitMarker(el)
if el ~= localPlayer then return end
if not isEventHandlerAdded("onClientRender", root, warehouseJob) then
addEventHandler("onClientRender", root, warehouseJob)
end
showCursor(true)
settings.gui = true
end

function leaveMarker(el)
if el ~= localPlayer then return end
if isEventHandlerAdded("onClientRender", root, warehouseJob) then
removeEventHandler("onClientRender", root, warehouseJob)
end
showCursor(false)
settings.gui = false
end

function warehouseStartJob()
settings.jobMarker = createMarker(settings.jobMarkerPos[1], settings.jobMarkerPos[2], settings.jobMarkerPos[3]-1, "cylinder", 2, 255, 51, 204, 75)
setElementData(settings.jobMarker, "marker:text", "ODBI?“R SKRZYŃ")
setElementInterior(settings.jobMarker, settings.job_int)
setElementData(localPlayer, "player:job", settings.jobCode)

addEventHandler("onClientMarkerHit", settings.jobMarker, getCaseHit)
removeEventHandler("onClientMarkerHit", settings.jobMarker, getCaseLeave)
exports.dmta_interface:showPlayerNotification("Rozpoczynasz prac?™ jako magazynier", "info")

toggleControl("sprint", false)
toggleControl("jump", false)
toggleControl("crouch", false)
end

function warehouseStopJob()
if isElement(settings.jobMarker) then
destroyElement(settings.jobMarker)
settings.jobMarker = nil
end

if isElement(settings.playerPack) then
setElementFrozen(localPlayer, true)
setPedAnimation(localPlayer,"CARRY","liftup",-1,false,true,false)
setTimer( function()
if isElement(settings.playerPack) then
x, y, z = getElementPosition(localPlayer)
destroyElement(settings.playerPack)
settings.playerPack = nil
setElementPosition(localPlayer, x, y, z + 0.03)
end
setElementFrozen(localPlayer, false)
end, 500, 1)
end

if isElement(settings.targetMarker) then
destroyElement(settings.targetMarker)
settings.targetMarker = nil
end

if isElement(settings.targetBlip) then
destroyElement(settings.targetBlip)
settings.targetBlip = nil
end

setElementData(localPlayer, "player:job", false)
exports.dmta_interface:showPlayerNotification("Praca zosta?‚a zako?„czona", "info")

toggleControl("sprint", true)
toggleControl("jump", true)
toggleControl("crouch", true)
end
setElementData(localPlayer, "player:job", false)

function getCaseHit(el)
if el ~= localPlayer then return end
if isElement(settings.playerPack) then return end
if not isEventHandlerAdded("onClientRender", root, drawCase) then
addEventHandler("onClientRender", root, drawCase)
end
showCursor(true)
settings.gui2 = true
end

function getCaseLeave(el)
if el ~= localPlayer then return end
if isElement(settings.playerPack) then return end
if isEventHandlerAdded("onClientRender", root, drawCase) then
removeEventHandler("onClientRender", root, drawCase)
end
showCursor(false)
settings.gui2 = false
end

function setDilveryTarget(el)

if isElement(settings.targetBlip) then
destroyElement(settings.targetBlip)
end

if isElement(settings.targetMarker) then
destroyElement(settings.targetMarker)
end

setPedAnimation(localPlayer,"CARRY","liftup",-1,false,true,false)
setTimer(function()
setPedAnimation(localPlayer, "CARRY", "crry_prtial", 1)
end, 500, 1)

settings.playerPack = createObject(1271, 0, 0, 0)
setElementCollisionsEnabled(settings.playerPack, false)
exports.bone_attach:attachElementToBone(settings.playerPack, localPlayer, 12, 0.23,0.35,0.1,0,165,-20)

local losuj = math.random(1, #positions)

settings.targetMarker = createMarker(positions[losuj][1], positions[losuj][2], positions[losuj][3]-1.0, "checkpoint", 1.5, 255, 51, 204, 25)
settings.targetBlip = createBlipAttachedTo(settings.targetMarker, 12)
setElementInterior(settings.targetBlip, 1)


addEventHandler("onClientMarkerHit", settings.targetMarker, function(el, md)
if el ~= localPlayer then return end
if getPedOccupiedVehicle(el) then return end

if isElement(settings.targetBlip) then
destroyElement(settings.targetBlip)
end

if isElement(settings.targetMarker) then
destroyElement(settings.targetMarker)
end

setElementFrozen(localPlayer, true)

setPedAnimation(localPlayer,"CARRY","liftup",-1,false,true,false)

setTimer( function()

if isElement(settings.playerPack) then
x, y, z = getElementPosition(localPlayer)
destroyElement(settings.playerPack)
setElementPosition(localPlayer, x, y, z + 0.03)
end

triggerServerEvent("jobMoney", localPlayer, localPlayer, settings.jobCode)
setElementFrozen(localPlayer, false)
end, 500, 1)

end)

end

addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "up" then
if settings.gui2 == true then
if isMouseIn(590*w, 293*h, 100*w, 100*h) then -- Biere skrzynie
if isElement(settings.playerPack) then return end
removeEventHandler("onClientRender", root, drawCase)
showCursor(false)
settings.gui2 = false
setDilveryTarget()
end
end
end
end)

addEventHandler( "onClientPlayerWasted", root, function()
if getElementData(source, "player:job") == settings.jobCode then
warehouseStopJob()
end
end)

addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "up" then
if settings.gui == true then
if isMouseIn(570*w, 473*h, 150*w, 55*h) then -- Exit
removeEventHandler("onClientRender", root, warehouseJob)
settings.gui = false
showCursor(false)
elseif isMouseIn(570*w, 408*h, 150*w, 55*h) then -- Start job
if getElementData(localPlayer, "player:job") == settings.jobCode then
warehouseStopJob()
removeEventHandler("onClientRender", root, warehouseJob)
settings.gui = false
showCursor(false)
else
warehouseStartJob()
removeEventHandler("onClientRender", root, warehouseJob)
settings.gui = false
showCursor(false)
end
end
end
end
end)















































function isMouseIn ( x, y, width, height )
if ( not isCursorShowing( ) ) then
return false
end
local sx, sy = guiGetScreenSize ( )
local cx, cy = getCursorPosition ( )
local cx, cy = ( cx * sx ), ( cy * sy )
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
return true
else
return false
end
end

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if
type( sEventName ) == 'string' and
isElement( pElementAttachedTo ) and
type( func ) == 'function'
then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end

return false
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-12-24, 11:40


_jvneczek







Wiek: 22
Na forum: 4326 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

gdzie jobMoney po serverside

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-12-24, 12:41


iksorek







Wiek: 25
Na forum: 2560 dni
Posty: 10
Nick w MP: XoreK

Piwa: 95

Respekt: 60

Jak si? domy?lam masz trigger jobMoney kt?rego zastosowanie znajdziesz w pystories-ustawienia-prace (), tam dodaj do tabelki prac? magazyniera

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-12-24, 13:49


Erczi







Wiek: 27
Na forum: 2371 dni
Posty: 17
Nick w MP: ewwe

Piwa: 4

Respekt: 50

"iksorek" napisał/a:

Jak si? domy?lam masz trigger jobMoney kt?rego zastosowanie znajdziesz w pystories-ustawienia-prace (), tam dodaj do tabelki prac? magazyniera


Mam w tabeli ale nadal nie daje kasy
na innych pracach tez nie daje

Kod:

local mnoznik = 2

local settings = {

["kosiarki"] = {
money = {50000, 55000},
exp = {2,3},
jobPoints = {1,2},
},

["magazynier"] = {
money = {55000, 60000},
exp = {2,3},
jobPoints = {1, 2},
},

["kurier"] = {
money = {2000000, 4000000},
exp = {2,8},
jobPoints = {3,5},
},

["pszczelarz"] = {
money = {80000, 90000},
exp = {2,3},
jobPoints = {1,3},


}

addEvent("jobMoney", true)
addEventHandler("jobMoney", root, function(plr, job)
if isElement(plr) then
local siano = math.random(settings[job].money[1], settings[job].money[2])
local exp = math.random(settings[job].exp[1], settings[job].exp[2])
local punkty = math.random(settings[job].jobPoints[1], settings[job].jobPoints[2])
local uid = getElementData(plr, "player:uid")

if uid and punkty then
exports['dmta_db']:dbSet('UPDATE dmta_users SET jobPoints=jobPoints+? WHERE id=?',math.floor(punkty), uid)
end

if getElementData(plr, "player:premium") then
local siano = math.floor((siano*1.2)*math.floor(mnoznik))
local exp = math.floor((exp*1.2)*math.floor(mnoznik))
givePlayerMoney(plr, siano)
exports.dmta_levels:addExp(plr, exp)
exports.dmta_interface:showPlayerNotification(plr, "Otrzymujesz wynagrodzenie w postaci "..siano.."$ oraz "..exp.." EXP", "info")
else
local siano = math.floor(siano*math.floor(mnoznik))
local exp = math.floor(exp*math.floor(mnoznik))
givePlayerMoney(plr, siano)
exports.dmta_levels:addExp(plr, exp)
exports.dmta_interface:showPlayerNotification(plr, "Otrzymujesz wynagrodzenie w postaci "..siano.."$ oraz "..exp.." EXP", "info")
end
else
outputDebugString("B?‚?…d - Event: jobMoney", 3)
end
end)


Postaw piwo autorowi tego posta
 

 
Tagi: nie :: daje :: kasy :: expa :: zarabianie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku