Apocalypso Posted April 12, 2017 Share Posted April 12, 2017 Hello again! So introduction why i write.. Well i watched youtube of old scripts, and find out one interesting script, who i added to my serv Job-System.... i updated the script and added new stuffs, to work smooth with server, Idea was that i remaked this script and make it usefull, and it worked... only now i got some problems... So how it works Script is - Client sided (job system , markers, outputchatbox, etc) because i dont need that chatbox show how many trees left to all players when they aint working or they roleplaying.. next is woods (client sided) script where i did not change anything because there is too much places of woods (redwood etc) locations all around MTA SA ... and last is Server sided : The functions what provide money, like givemoney to lumberjack and maths wheere there is shown how much and some eventcalls Problem : Those trees are showing only to those who apply jobs, and everjone got their own forrest, but when other player is near, it looks like that "lumberjack" is idiot, who runs around with chainsaw, where is no trees :D... So why there aint showing those "forest " trees to other, i know that is because that function of cut tree and animation of falling trees are "Client Sided" But when i swap it and change deffinitons of Server and client event triggers, it just amm.. fuk up all jobs.... and all debug is red...so Help please... After that i thinked to add some objects too what can be putted on car (wood log) or something, where is function givetree but if they aint showing up now there is no reason to add it here the script i edited 1) Server sided function givePlayerTree() moneyw = math.random(5,10) exports.global:giveMoney(client,moneyw) end addEvent("DGAlumberjack.GivePlayerTree", true) addEventHandler("DGAlumberjack.GivePlayerTree", root, givePlayerTree) function giveBonus() moneyMultiplier = math.random(1,2) moneyAmount = math.floor(math.random(300, 400)*moneyMultiplier) exports.global:giveMoney(client,moneyAmount) exports.hud:sendBottomNotification(client, "Darbadevējs:", "Tu saņēmi prēmiju €"..moneyAmount.." apmērā, par meža likvidēšanu...") end addEvent("DGAlumberjack.GiveBonus", true) addEventHandler("DGAlumberjack.GiveBonus", root, giveBonus) function onDFTenter(enteringPlayer) if (isElement(source)) then if (getElementModel(source) == 578) then if (getElementData(enteringPlayer, "job") == 10) then triggerClientEvent(enteringPlayer, "DGAlumberjack.JobStart", enteringPlayer) end end end end addEventHandler("onVehicleEnter", root, onDFTenter) Client sided with anim and woods function JobStart() if (not (isJobStarted)) then currentForest = math.random(#treesPositions) colCircle = createColCircle(treesPositions[currentForest]["colShape"][1], treesPositions[currentForest]["colShape"][2], 30) createBlipAttachedTo(colCircle, 0) addEventHandler("onClientColShapeHit", colCircle, onColCircleHit) for i,v in ipairs(treesPositions[currentForest]) do objAmount[i] = createObject(idList[math.random(#idList)],treesPositions[currentForest][i][1], treesPositions[currentForest][i][2], treesPositions[currentForest][i][3]) treeColShape[i] = createColCircle(treesPositions[currentForest][i][1], treesPositions[currentForest][i][2], 3.5) end treeAmount = #objAmount isJobStarted = true end end addEvent("DGAlumberjack.JobStart", true) addEventHandler("DGAlumberjack.JobStart", root, JobStart) assignMarker = nil assignBlip = nil function JobStop() if (isElement(assignMarker)) then destroyElement(assignMarker) destroyElement(assignBlip) end if (isElement(colCircle)) then colCircleBlip = getAttachedElements(colCircle)[1] if (colCircleBlip) then destroyElement(colCircleBlip) end destroyElement(colCircle) end for k, v in ipairs(objAmount) do if (isElement(v)) then local blip = getAttachedElements(v)[1] if (blip) then destroyElement(blip) end destroyElement(v) end end for k, v in ipairs(treeColShape) do if (isElement(v)) then destroyElement(v) end end isJobStarted = false objAmount = {} treeColShape = {} treeAmount = 0 end addEvent("DGAlumberjack.JobStop", true) addEventHandler("DGAlumberjack.JobStop", root, JobStop) function onColCircleHit(hitElement) if (hitElement == localPlayer) then colCircleBlip = getAttachedElements(colCircle)[1] if (colCircleBlip) then destroyElement(colCircleBlip) end destroyElement(colCircle) for k, v in ipairs(objAmount) do if (isElement(v)) then createBlipAttachedTo(v) end end end end function treeCheck() if (treeAmount == 0) then triggerServerEvent("DGAlumberjack.GiveBonus", root) JobStop() else outputChatBox("Tu nocirti koku, vēl palika: "..treeAmount,255,255,0) end end function cutTree(index) if (isElement(objAmount[index])) then local x, y, z = getElementPosition(objAmount[index]) setElementFrozen(localPlayer, true) setTimer(fadeCamera, 350, 1, false) setTimer(fadeCamera, 4800, 1, true) setTimer(setElementFrozen, 6000, 1, localPlayer, false) moveObject(objAmount[index],6000,x,y,z-10,0,90,90) setTimer(destroyTree, 7000, 1, index) destroyElement(getAttachedElements(objAmount[index])[1]) end end function destroyTree(index) if (isElement(objAmount[index])) then destroyElement(objAmount[index]) triggerServerEvent("DGAlumberjack.GivePlayerTree", root) treeAmount = treeAmount -1 treeCheck() end end local lastCount = getTickCount() function onChainsawUse() if (getPedWeapon(localPlayer) == 9) then if (not (isPedInVehicle(localPlayer))) then if (not (isElementFrozen(localPlayer))) then if (not (isCursorShowing())) then if ((getTickCount() - lastCount) > 1500) then for k, v in ipairs(treeColShape) do if (isElement(v)) then if (isElementWithinColShape(localPlayer, v)) then destroyElement(v) cutTree(k) break end end end lastCount = getTickCount() end end end end end end bindKey("mouse1", "down", onChainsawUse) And last one is just pozzitions of wods only at end is is this idList = { [1] = 696, [2] = 697, [3] = 693, } currentForest = nil mainWindow = nil colCircle = nil sellTablesButton = nil isJobStarted = false isCrafting = false objAmount = {} treeColShape = {} descLabel = {} minMaxTables = {5, 10} minMaxMoney = {} treeAmount = 0 treesCrafted = 0 treesToCraft = 0 tablesMade = 0 playerTrees = 0 playerTables = 0 Help please Link to comment
Rataj Posted April 16, 2017 Share Posted April 16, 2017 Carefully swap it to server-side, make sure, everything is right for server-side as it should be. If it won't work again, then reply with debugscript errors, so we can help you specifically with some mistake you probably made previously when swapping to server-side. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now