krystian334 Posted January 16, 2016 Share Posted January 16, 2016 (edited) I have a problem with trucker job because when two players to participate in this job will not only let him take the second checkpoint site. and automatic first gets money and can not continue. Here is my resurce : --// Made by: MoPoMaN --//Tables and other stuff tableLocationsX = {} tableLocationsY = {} tableLocationsZ = {} tableMoney = {} locationCount = 6 --//Location 1 tableLocationsX[1] = 1141 tableLocationsY[1] = -875 tableLocationsZ[1] = 43 tableMoney[1] = math.random( 20000, 25000 ) --//Location 2 tableLocationsX[2] = 1186 tableLocationsY[2] = -883 tableLocationsZ[2] = 43 tableMoney[2] = math.random( 20000, 25000 ) --//Location3 tableLocationsX[3] = 1312 tableLocationsY[3] = -857 tableLocationsZ[3] = 39 tableMoney[3] = math.random( 20000, 25000 ) --//Location4 tableLocationsX[4] = 2121 tableLocationsY[4] = -1783 tableLocationsZ[4] = 13 tableMoney[4] = math.random( 20000, 25000 ) --//Location5 tableLocationsX[5] = 2146 tableLocationsY[5] = -1177 tableLocationsZ[5] = 23 tableMoney[5] = math.random( 20000, 25000 ) --//Location6 tableLocationsX[6] = 1853 tableLocationsY[6] = -1862 tableLocationsZ[6] = 13 tableMoney[6] = math.random( 20000, 25000 ) function startScript () --Marker marker = createMarker (2776.7, -2427.3, 12.6, "cylinder", 1.1, 0, 255, 0) addEventHandler ("onMarkerHit", marker, startMission) --Objects and Ped ped = createPed (302, 2776.7, -2428.1, 13.6) addEventHandler ("onPedWasted", getRootElement(), respawnPed) --Blip startBlip = createBlip (2776.9, -2423.9, 12.7, 51) end function startMission (hitElement) if getElementType (hitElement) == "player" then --Check team -- local team = getPlayerTeam (hitElement) -- if getTeamName (team) ~= "Workers" then -- local teamName = getTeamName (team) -- outputChatBox ("#ffaa00// #ffffffOnly workers can drive trucks! Press F2 to change the team.", hitElement, 255, 255, 255, true) -- return false -- else --createThings rekka = createVehicle (515, 2779.6, -2437.2, 14.7, 0, 0, 90) vaunu = createVehicle (435, 2789.2, -2437.1, 14.2, 0, 0, 90) randomLoc = math.random (1, locationCount) finish = createMarker (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], "cylinder", 3, 0, 200, 55, 255, hitElement) blip = createBlip (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], 0, 2, 255, 0, 0, 255, 0, 10000, hitElement) marker = createMarker (2776.7, -2427.3, 12.6, "cylinder", 1.1, 0, 255, 0) --addEventHandlers addEventHandler ("onVehicleExit", getRootElement(), vehicleExit) addEventHandler ("onMarkerHit", finish, reward) addEventHandler ("onPlayerQuit", getRootElement(), onQuit) --other pelaaja = hitElement outputChatBox (" #ffffffLivreaza marfa la checkpoint-ul de pe minimap #ffaa00", pelaaja, 255, 255, 255, true) setElementPosition (marker, -406, -64, 2.4) setVehicleVariant (vaunu, 0, 0) warpPedIntoVehicle (hitElement, rekka) -- end else return false end end function vehicleExit (leaver) if source == rekka and leaver == pelaaja then outputChatBox ("#ffaa00// #ffffffIntra inapoi in vehicul !", leaver, 255, 255, 255, true) addEventHandler ("onVehicleEnter", getRootElement(), destrTimer) else return false end end function destrTimer (thePlayer) if source == rekka and thePlayer == pelaaja then local team = getPlayerTeam (thePlayer) if getTeamName (team) == "Freeroam" or getTeamName (team) == "The Police" then return false else killTimer (destroyTimer) removeEventHandler ("onVehicleEnter", getRootElement(), destrTimer) setVehicleLocked (rekka, true) end else return false end end function destroyVehicle () if dedstroyTimer then --destroyThings destroyElement (rekka) destroyElement (vaunu) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onVehicleEnter", getRootElement(), destrTimer) removeEventHandler ("onPlayerQuit", getRootElement(), onQuit) --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) setElementPosition (marker, 2776.6, -2425.5, 12.6) else return false end end function onQuit () if source == pelaaja then --destroyThings destroyElement (rekka) destroyElement (vaunu) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onPlayerQuit", getRootElement(), onQuit) --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) setElementPosition (marker, 2776.6, -2425.5, 12.6) end end function reward (hitElement) if hitElement == rekka then --other startBlip = createBlip (2776.9, -2423.9, 12.7, 51) setElementPosition (marker, 2776.6, -2425.5, 12.6) palkittava = getVehicleOccupant (rekka, 0) givePlayerMoney (palkittava, tableMoney[randomLoc]) --destroyThings destroyElement (vaunu) destroyElement (finish) destroyElement (blip) --removeEventHandlers removeEventHandler ("onTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onPlayerQuit", getRootElement(), onQuit) else return false end end function respawnPed () if source == ped then timer = setTimer (pedRespawn, 5000, 1) else return false end end function pedRespawn () killTimer (timer) destroyElement (ped) ped = createPed (302, 2776.7, -2428.1, 13.6) end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), startScript) Edited January 16, 2016 by Guest Link to comment
Addlibs Posted January 16, 2016 Share Posted January 16, 2016 Please use [lua] tags so that it's easier to see the code. Link to comment
krystian334 Posted January 16, 2016 Author Share Posted January 16, 2016 Please use [lua] tags so that it's easier to see the code. Finish Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 By looking at your script, it seems like you've created a server sided script which won't work for the thing you want. You're going to have to use triggerClientEvent and triggerServerEvent in order to create the right markers for 1 person only, and make him finish the job which he started. The script is currently only working in a way for 1 person doing 1 job. Link to comment
krystian334 Posted January 16, 2016 Author Share Posted January 16, 2016 By looking at your script, it seems like you've created a server sided script which won't work for the thing you want. You're going to have to use triggerClientEvent and triggerServerEvent in order to create the right markers for 1 person only, and make him finish the job which he started. The script is currently only working in a way for 1 person doing 1 job. So what to do? Link to comment
tosfera Posted January 16, 2016 Share Posted January 16, 2016 either avoid users from doing the same job, or rewrite the script so it has a client and server sided file that controls the marker creation and the events for markers. Link to comment
krystian334 Posted January 16, 2016 Author Share Posted January 16, 2016 either avoid users from doing the same job, or rewrite the script so it has a client and server sided file that controls the marker creation and the events for markers. and how can I do this? 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