Szerző Téma: MunkaScript bug mi lehet?  (Megtekintve 1218 alkalommal)

MunkaScript bug mi lehet?
« Dátum: 2018. január 21. - 14:18:40 »
0 Show voters
Hali Probálkoztam egy munka script megirássával de sajnos nem igen megy :C Valaki tudna segiteni?
 
A munkafelvétel része megy de a probléma az hogy nem kapok kocsit se cp-t!
 

function getPayment(id)
local element = getElementByID(id)
if isElement(element) then
   return tonumber(getElementData(element, \"value\")) or 5000
else
   return 5000
end
end
function resetAllJobs()
exports.san_job_trash:manageTrashJob(false)
end
function applyJob(id)
resetAllJobs()
 if id == 1 then
   exports.san_job_trash:manageTrashJob(true)

end
end
-- munka felvétel
addCommandHandler(\"felmondas\", function(cmd)
if getElementData(localPlayer, \"char:job\") ~= 0 then
   if not isPedInVehicle(localPlayer) then
      exports.san_infobox:addNotification(\"Sikeresen Fel mondtál!\",\"success\")
      setElementData(localPlayer, \"char:job\", 0)
      applyJob(0)
   else
      exports.san_infobox:addNotification(\"Szálj ki a kocsiból!\",\"success\")
   end
else
   exports.san_infobox:addNotification(\"Jelenleg nincs munkád!\",\"success\")
end
end)
local jobNPCs = {}
function addJobPed(skin,x,y,z,rz,int,dim)
local ped = createPed(skin, x, y, z)
jobNPCs[ped] = true
setElementData(ped, \"name\", \"Ügyintéző\")
setElementInterior(ped, int)
setElementDimension(ped, dim)
-- setElementFrozen(ped, true)
setElementRotation(ped, 0, 0, rz)
end
function addNewPed(ped)
jobNPCs[ped] = true
end
addEvent(\"job:addNewPed\", true)
addEventHandler(\"job:addNewPed\", root, addNewPed)
addJobPed(110, 1207.8920898438, -1783.9304199219, 16.03125, 90, 0, 0)
 
function showJobGui()
if isElement(wEmployment) then return end
local width, height = 300, 400
local scrWidth, scrHeight = guiGetScreenSize()
local x = scrWidth/2 - (width/2)
local y = scrHeight/2 - (height/2)

wEmployment = guiCreateWindow(x, y, width, height, \"Munka felvétele\", false)
jobList = guiCreateGridList(0.05, 0.05, 0.9, 0.8, true, wEmployment)
local column = guiGridListAddColumn(jobList, \"Munka neve\", 0.6)
local helye = guiGridListAddColumn(jobList, \"Helye\", 0.3)


local row = guiGridListAddRow(jobList)
guiGridListSetItemText(jobList, row, column, \"Kukás[Ez müködik Jelenleg]\", false, false)
guiGridListSetItemText(jobList, row, helye, \"Los Santos\", false, false)

bAcceptJob = guiCreateButton(0.05, 0.9, 0.45, 0.1, \"Munka felvétele\", true, wEmployment)
bCancel = guiCreateButton(0.5, 0.9, 0.45, 0.1, \"Mégse\", true, wEmployment)

showCursor(true)

addEventHandler(\"onClientGUIClick\", bAcceptJob, acceptJob)
addEventHandler(\"onClientGUIDoubleClick\", jobList, acceptJob)
addEventHandler(\"onClientGUIClick\", bCancel, destroyJobGui)
end
function destroyJobGui(destroy)
if source == bCancel or destroy then
   destroyElement(jobList)
   destroyElement(bAcceptJob)
   destroyElement(bCancel)
   destroyElement(wEmployment)
   showCursor(false)
end
end
function acceptJob(button, state)
if button==\"left\" and source == bAcceptJob then
   local row, col = guiGridListGetSelectedItem(jobList)
   local job = getElementData(localPlayer, \"char:job\")
   if (row==-1) or (col==-1) then
      outputChatBox(\"[GoodFine] #FFFFFFKérlek válasz 1 munkát először.\", 255, 0, 0, true)
   elseif (job>0) then
      outputChatBox(\"[GoodFine] #FFFFFFMár van munkád!\", 255, 0, 0, true)
   else
      local job = 0
      local jobtext = guiGridListGetItemText(jobList, guiGridListGetSelectedItem(jobList), 1)
      
      if jobtext==\"Kukás\" then
         applyJob(1)
         setElementData(localPlayer, \"char:job\", 1)
         destroyJobGui(true)
      end
      
      outputChatBox(\"[GoodFine] #FFFFFFSikeresen felvetted a következő munkát: \"..jobtext..\"!\", 255, 0, 0, true)
   end
end
end
addEventHandler(\"onClientClick\", getRootElement(), function(button, state, absX, absY, wx, wy, wz, element)
if element and (jobNPCs[element]) and button==\"right\" and state==\"down\" then
   local x, y, z = getElementPosition(localPlayer)
   if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz) <= 5 then
      showJobGui()
   end
end
end)
-- munka felvétel eddig
addEventHandler(\"onClientResourceStart\", resourceRoot, function()
local myJob = tonumber(getElementData(localPlayer, \"char:job\")) or 0
applyJob(myJob)
end)


local possibleTrash = {1264, 1265}
local trashMoney = 1000
local trashID = possibleTrash[math.random(2)]
local trashVehicleID = 408
local isHolding = false
local markerFix = false
local hitMarker, deliverPoint, primaryBlip
local trashPositions = {
{-78.680229187012,-1187.9937744141,1.75},
{-106.34077453613,-299.65850830078,1.4296875},
{98.137725830078,-196.20822143555,1.484375},
{297.41998291016,-154.01693725586,1.578125},
{160.20262145996,-7.6971964836121,1.578125},
{1219.4182128906,310.82260131836,19.728824615479},
{1293.3883056641,345.66235351563,19.5546875},
{1270.2177734375,360.03115844727,19.5546875},
{1416.8967285156,270.44320678711,19.561782836914},
{1370.8100585938,201.15299987793,19.5546875},
{2233.4970703125,69.284088134766,26.484375},
{2257.70703125,78.768669128418,26.484375},
{-45.268489837646,-2494.7810058594,36.541534423828},
{309.48297119141,-53.893852233887,1.578125},
{343.02868652344,-79.54443359375,1.4195213317871},
{694.86114501953,-452.82705688477,16.3359375},
{689.93872070313,-566.27642822266,16.3359375},
{666.70520019531,-622.78723144531,16.3359375},
{1384.5567626953,376.43692016602,19.7578125},
{1412.0592041016,413.53002929688,19.7578125},
}
local hitPoint = {2087.705078125, -2031.5078125, 13.546875}
local jobActive = false
local holdingObject
function resetTrashJob()
for k, v in pairs(getElementsByType(\"object\")) do
   if getElementModel(v) == 1264 or getElementModel(v) == 1265 then
      if getElementData(v, \"trash\") then
         destroyElement(v)
      end
   end
end
for k, v in pairs(getElementsByType(\"blip\", getResourceRootElement(getThisResource()))) do
   if getElementData(v, \"trash\") then
      destroyElement(v)
   end
end
for k, v in pairs(getElementsByType(\"marker\", getResourceRootElement(getThisResource()))) do
   if getElementData(v, \"trash\") then
      destroyElement(v)
   end
end
if isElement(hitMarker) then
   destroyElement(hitMarker)
end
if isTimer(destroyTimer) then
   killTimer(destroyTimer)
end
if isElement(primaryBlip) then
   destroyElement(primaryBlip)
end
if isElement(marker) then
   destroyElement(marker)
end
if isElement(blip) then
   destroyElement(blip)
end
if isElement(trash) then
   destroyElement(trash)
end
if isElement(holdingObject) then
   exports.san_bone_attach:detachElementFromBone(holdingObject)
   destroyElement(holdingObject)
end
end
function trashMarkerHit(hitElement)
if hitElement == localPlayer and not isPedInVehicle(localPlayer) and not markerFix then
   removeEventHandler(\"onClientMarkerHit\", hitMarker, trashMarkerHit)
   resetTrashJob()
   exports.san_infobox:addNotification(\"Sikeresen megkaptad a munkajárműved!\",\"success\")
   outputChatBox(\"#ffffffTérképeden jelöltük az összeszedendő szemetet.\", 0, 255, 255, true)
   outputChatBox(\"#ffffff((#ffffffA munka elvégzéséhez kattints a #4f98e1szemétre#ffffff, utána pedig a #4f98e1kukásautó #ffffffhátuljára, hogy bedobd a szemetet.))\", 0, 255, 255, true)            
   triggerServerEvent(\"createTrashCar\", getRootElement(), hitPoint[1], hitPoint[2], hitPoint[3], localPlayer)
   generateTrashPoint2()
end
end
function manageTrashJob(state)
if state and not jobActive then
   jobActive = true
   primaryBlip = createBlip(hitPoint[1], hitPoint[2], hitPoint[3], 18)
   hitMarker = createMarker(hitPoint[1], hitPoint[2], hitPoint[3] - 1, \"checkpoint\", 4, 255, 255, 255, 100)
   addEventHandler(\"onClientMarkerHit\", hitMarker, trashMarkerHit)
elseif jobActive and not state then
   jobActive = false
   resetTrashJob()
end
end
addEventHandler(\"onClientVehicleExit\", getRootElement(), function(player, seat)
if player == localPlayer and player and seat == 0 and exports.san_job_vehs:isJobVehicle(source, 3) then
   local x, y, z = getElementPosition(source)
   x = x + 5
   deliverPoint = createColSphere(x, y, z, 2)   
   attachElements(deliverPoint, source, 0, -4, 0)      
end
end)
addEventHandler(\"onClientVehicleEnter\", getRootElement(), function(player, seat)
if player and player == localPlayer and seat == 0 and exports.san_job_vehs:isJobVehicle(source, 3) and deliverPoint and isElement(deliverPoint) then
   destroyElement(deliverPoint)
end
end)
addEventHandler(\"onClientClick\", getRootElement(),
function(button, state, x, y, wx, wy, wz, element)
   if button and state and state == \"down\" then
      if element and isElement(element) and getElementModel(element) == trashID and not isHolding and getElementData(element, \"trash\") then
         local x, y, z = getElementPosition(localPlayer)
         local cx, cy, cz = getElementPosition(element)
         if getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) <= 2 then
            exports.san_bone_attach:attachElementToBone(element, localPlayer, 11, 0, 0, 0.2, 0, 180, 0)      
            holdingObject = element   
            setObjectScale(element, 0.5)
            isHolding = true
            exports.san_chat:sendLocalMeMessage(localPlayer, \"lehajol majd felveszi a szemeteszsákot.\")         
         end
      elseif element and isElement(element) and getElementType(element) == \"vehicle\" and getElementModel(element) == trashVehicleID and isHolding then
         local x, y, z = getElementPosition(localPlayer)
         local cx, cy, cz = getElementPosition(element)
         if isElementWithinColShape(localPlayer, deliverPoint) then
            generateTrashPoint2()
            isHolding = false
            exports.san_chat:sendLocalMeMessage(localPlayer, \"bedobja a szemetet a kukásautóba.\")
            setElementData(localPlayer, \"char:Money\", getElementData(localPlayer, \"char:Money\") + exports.ex_job_core:getPayment(\"kukas_fizetes\"))
         end
      end
   end
end
)
addEventHandler(\"onClientResourceStart\", resourceRoot, function()
if getElementData(localPlayer, \"char:job\") == 1 then
   local restoreJob = getElementData(localPlayer, \"job:RestoreTrash\")
   if restoreJob then
      generateTrashPoint2()
   else
      manageTrashJob(true)
   end
   setElementData(localPlayer, \"job:RestoreTrash\", nil, false)
end
end)
addEventHandler(\"onClientResourceStop\", resourceRoot, function()
if isElement(blip) then
   setElementData(localPlayer, \"job:RestoreTrash\", true, false)
end
end)
local oldNumber = 0
function generateTrashPoint2()
local szam = math.random(1, #trashPositions)
if szam == oldNumber then
   generateTrashPoint2()
   return
end
resetTrashJob()
oldNumber = szam
trash = createObject(trashID, trashPositions[szam][1], trashPositions[szam][2], trashPositions[szam][3] - 0.5)
setElementData(trash, \"trash\", true)
setObjectBreakable(trash, false)
blip = createBlip(trashPositions[szam][1], trashPositions[szam][2], trashPositions[szam][3], 18, 3)
setElementData(blip, \"trash\", true)
marker = createMarker(trashPositions[szam][1], trashPositions[szam][2], trashPositions[szam][3] - 1, \"checkpoint\", 4, 79, 152, 225, 100)   
setElementData(marker, \"trash\", true)
setElementData(marker, \"name\", \"Uticél\")
setElementFrozen(trash, true)
end
addEventHandler(\"onClientPlayerVehicleExit\", getRootElement(), function(vehicle, seat)
if exports.san_job_vehs:isJobVehicle(vehicle, 3) and source == localPlayer and seat == 0 then
   destroyTimer = setTimer(function()
      resetTrashJob()
      manageTrashJob(true)
   end, 600000, 1)
end
end)
addEventHandler(\"onClientPlayerVehicleEnter\", getRootElement(), function(vehicle, seat)
if vehicle and seat == 0 and exports.san_job_vehs:isJobVehicle(vehicle, 3) and getElementData(source, \"char:job\") == 1 then
   if isTimer(destroyTimer) then
      killTimer(destroyTimer)
   end
end
end)


function isJobVehicle(veh, job)
local jobID = tonumber(getElementData(veh, \"job:Vehicle\")) or 0
return jobID == job
end
function isMyJobVehicle(veh)
local owner = tonumber(getElementData(veh, \"veh:Owner\")) or 0
local myID = tonumber(getElementData(localPlayer, \"dbid\")) or 0
return owner == myID
end
addEventHandler(\"onClientPlayerVehicleExit\", getRootElement(), function(vehicle, seat)
if getElementData(vehicle, \"job:Vehicle\") and source == localPlayer and seat == 0 then
   exports.san_infobox:addNotification(\"A járműved 10 perc múlva törlödik!\",\"error\")
   triggerServerEvent(\"delJobCar\", getRootElement(), vehicle)
   jobTimer = setTimer(function()
      setElementData(localPlayer, \"disableJobCar\", false)
   end, 120000, 1)
end
end)
addEventHandler(\"onClientVehicleEnter\", getRootElement(), function(thePlayer, seat)
if thePlayer and thePlayer == localPlayer and getElementData(source, \"job:Vehicle\") then
   triggerServerEvent(\"stopJobCarTimer\", getRootElement(), source)
   if isTimer(jobTimer) then killTimer(jobTimer) end
end
end)
addEventHandler(\"onClientPlayerWasted\", getRootElement(), function()
if isPedInVehicle(source) and getElementData(getPedOccupiedVehicle(source), \"job:Vehicle\") then
   triggerServerEvent(\"delJobCar\", getRootElement(), getPedOccupiedVehicle(source))
   jobTimer = setTimer(function()
      setElementData(localPlayer, \"disableJobCar\", false)
   end, 120000, 1)
end
end)
addEventHandler(\"onClientResourceStop\", resourceRoot, function()
setElementData(localPlayer, \"disableJobCar\", false)
end)
local hiddenVehicleComponents = {}
addEvent(\"setVehicleComponentVisible\", true)
addEventHandler(\"setVehicleComponentVisible\", getRootElement(), function(veh, component, state)
if not state then
   if not hiddenVehicleComponents[veh] then
      hiddenVehicleComponents[veh] = {}
   end
   hiddenVehicleComponents[veh][component] = true
else
   if hiddenVehicleComponents[veh][component] then
      hiddenVehicleComponents[veh][component] = nil
   end
   local i=1
   for k,v in pairs(hiddenVehicleComponents[veh]) do
      i = i + 1
   end
   if i == 0 then
      hiddenVehicleComponents[veh] = nil
   end
end
setVehicleComponentVisible(veh, component, state)
end)
addEventHandler(\"onClientElementStreamIn\", root, function()
if getElementType(source) == \"vehicle\" then
   if hiddenVehicleComponents[source] then
      for k,v in pairs(hiddenVehicleComponents[source]) do
         setVehicleComponentVisible(source, k, false)
      end
   end
end
end)
-- kocsi mod
local tempTable = {}
local loadedMods = {}
function loadCarMod(file, mod)
local key = #tempTable+1
if not tempTable[key] then
   tempTable[key]

MunkaScript bug mi lehet?
« Válasz #1 Dátum: 2018. január 21. - 20:06:10 »
+2 Show voters
SanMTA? Merthogy nem te írtad, az biztos. Ne haragudj meg, de egy ekkora script-et meg tudsz írni, de debugscript segítségével nem tudod kijavítani? Döcög.

MunkaScript bug mi lehet?
« Válasz #2 Dátum: 2018. január 22. - 06:29:52 »
0 Show voters
De mivel én irtam csak probálom debugscript 3 és semmit se csinál

MunkaScript bug mi lehet?
« Válasz #3 Dátum: 2018. január 22. - 10:48:44 »
0 Show voters

MunkaScript bug mi lehet?
« Válasz #4 Dátum: 2018. január 22. - 10:59:32 »
0 Show voters
Idézetet írta: slre14 date=1516598992


   
      De mivel én irtam csak probálom debugscript 3 és semmit se csinál
   


2 kérdéssel előbb még azt írtad idézem \" Hali most kezdtem a luát \" és egy pozíció lekéréssel problémáid voltak. Ezt meg megtudtad \"írni\"?  (Nem bántásként írom, csak tudjuk hogy nem te írtad)

MunkaScript bug mi lehet?
« Válasz #5 Dátum: 2018. január 22. - 12:31:45 »
0 Show voters
Ha te írtad volna nem lenne tele \"san_infobox\"-al :D

MunkaScript bug mi lehet?
« Válasz #6 Dátum: 2018. január 22. - 15:53:35 »
0 Show voters
Ne haragudj a modorom miatt, de nem kell azt állítani, hogy te írtad. Na, de inkább segítsünk. Debugscript ír valamit?

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal