-
Posts
2,753 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Captain Cody
-
Well whole script seams to be screwed up now.
-
That worked but I'm getting debug errors, for the on quit or on truck leave, expected function at argument 3, got null. Functions ----- function destroyVehicle () if destroyTimer then --destroyThings local playerTruckerJobData = truckerJobData[PlayerAb] if playerTruckerJobData then local TrailerAb = playerTruckerJobData["trailer"] local FinishPoint = playerTruckerJobData["marker"] local blip = playerTruckerJobData["blip"] destroyElement (TrailerAb) destroyElement (FinishPoint) destroyElement (blip) --removeEventHandlers removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onVehicleEnter", truckMain, destrTimer) removeEventHandler ("onPlayerQuit", PlayerAb, onQuit) else return false end end function vehicleExit (PlayerAb) if source == truckMain then outputChatBox ("Go back to the truck within a minute", PlayerAb, 255, 255, 255, true) destroyTimer = setTimer (destroyVehicle, 600000, 1) addEventHandler ("onVehicleEnter", truckMain, destrTimer) else return false end end function destrTimer (thePlayer) if source == truckMain and thePlayer == playerAb then local team = getPlayerTeam (thePlayer) if getTeamName (team) == "Other" or getTeamName (team) == "Police" then return false else killTimer (destroyTimer) removeEventHandler ("onVehicleEnter", truckMain, destrTimer) setVehicleLocked (truckMain, true) end else return false end end function onQuit () if source == PlayerAb then --destroyThings local playerTruckerJobData = truckerJobData[PlayerAb] if playerTruckerJobData then local TrailerAb = playerTruckerJobData["trailer"] local FinishPoint = playerTruckerJobData["marker"] local blip = playerTruckerJobData["blip"] destroyElement (TrailerAb) destroyElement (FinishPoint) destroyElement (blip) --removeEventHandlers removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onPlayerQuit", PlayerAb, onQuit) end end end end --- The event handlers --- On mission start -- addEventHandler ("onVehicleExit", truckMain, vehicleExit) addEventHandler ("onPlayerQuit", playerAb, onQuit) On mission end -- removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onPlayerQuit", playerAb, onQuit)
-
Probably did 90% of this wrong. But here's what I have -- For start mission - function startMissionAAA ( hitElement) if getElementType ( hitElement ) == "vehicle" and getVehicleOccupant ( hitElement ) then PlayerAb = getVehicleOccupant ( hitElement ) truckerJobData[PlayerAb] = {} local playerTruckerJobData = truckerJobData[PlayerAb] local trailer = createVehicle (435, TrailerX, TrailerY, TrailerZ, 0, TrailerRotation, trailerType[randomLoc]) setVehicleVariant (TrailerAb, 5, 0) attachTrailerToVehicle ( hitElement, TrailerAb ) setPlayerTeam ( PlayerAb, TruckDriverAA ) truckMain = hitElement --Location stuff-- destroyElement (markerAAB) randomLoc = math.random (1, locationCount) local FinishPoint = createMarker (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], "cylinder", 3, 0, 200, 55, 255, PlayerAb) local blip = createBlip (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], 0, 2, 255, 0, 0, 255, 0, 10000, PlayerAb) --Chat Stuff-- outputChatBox ("Drive to the red blip on the map", PlayerAb, 255, 255, 255, true) --addEventHandlers addEventHandler ("onVehicleExit", truckMain, vehicleExit) addEventHandler ("onMarkerHit", FinishPoint , EndTheMission) addEventHandler ("onPlayerQuit", PlayerAb, onQuit) --Add the stuff into table-- playerTruckerJobData["blip"] = blip playerTruckerJobData["marker"] = FinishPoint playerTruckerJobData["trailer"] = trailer else return false end end and for end mission -- function EndTheMission () local playerTruckerJobData = truckerJobData[PlayerAb] if playerTruckerJobData then local TrailerAb = playerTruckerJobData["trailer"] local FinishPoint = playerTruckerJobData["marker"] local blip = playerTruckerJobData["blip"] if getElementType ( hitElement ) == "trailer" then outputDebugString("EndTheMission") outputChatBox ("This load got you " .. tableMoney[randomLoc] .. "$ If you would like to continue head back to one of the trucking depos.", PlayerAb, 255, 255, 255, true) givePlayerMoney (PlayerAb, tableMoney[randomLoc]) setPlayerTeam ( PlayerAb, NoJob ) --destroyThings destroyElement (TrailerAb) destroyElement (FinishPoint) destroyElement (blip) --removeEventHandlers removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onPlayerQuit", PlayerAb, onQuit) else return false end end Gives me error, end expected near 188 "The end line, right after the end mission function" addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), startScript)
-
I got it working a while ago..
-
Well I know how to make table and stuff, but the trailer is created when the player hits a marker. function startMissionAAA ( hitElement) if getElementType ( hitElement ) == "vehicle" and getVehicleOccupant ( hitElement ) then --Trailer location-- TrailerAb = createVehicle (435, TrailerX, TrailerY, TrailerZ, 0, TrailerRotation, trailerType[randomLoc]) setVehicleVariant (TrailerAb, 5, 0) attachTrailerToVehicle ( hitElement, TrailerAb ) I'm wondering how I would add the trailer created here into the table.
-
taxidriver = getPlayersInTeam ( TaxiDriverTeam ) outputChatBox ( "(source) needs a taxi", taxidriver ) Debug - Expected element, got table How would I do this, cannot find any thing on wiki to do this. And how would I define the person who did the command, using source gives me debug expected element got nil. addCommandHandler ("taxi", taxiMessage) function taxiMessage ()
-
for the table, how would I make it so a trailer created on marker hit is part of it?
-
Ok I thought I had got it working but can you explain more clearly what And with onMarkerHit you compare inside the function, the hitElement(first argument) with the truck element. Means? function EndTheMission (hitElement) if hitElement == TrailerAb then And the event handler for it - addEventHandler ("onMarkerHit", FinishPoint , EndTheMission) Here is what I got, it works for the first person, then when a secound person tries to deliver it does not work.
-
I cannot find anything on the wiki about it but, I'm trying to get the gui for a job I'm working on to apear on marker hit "Got that after some help" but it apears to everyone on the server. --Get the Job Marker-- myMarker = createMarker( -241.9082, -227.8291, 1.2086515, "cylinder", 1.1, 0, 255, 0) function MarkerHit(hitElement) if getElementType(hitElement) == "player" then showCursor(true) --Create Stuff-- acceptBtn = guiCreateButton(0.39, 0.38, 0.22, 0.05, "Accept Legal Load", true) --Event handler-- addEventHandler("onClientGUIClick", acceptBtn, startMissionA ) acceptBtn2 = guiCreateButton(0.39, 0.44, 0.22, 0.05, "Accept Illegal Load -WIP-", true) cancelBtn = guiCreateButton(0.40, 0.50, 0.21, 0.07, "Cancel", true) --Event handler-- guiSetProperty(cancelBtn, "NormalTextColour", "FFC30000") addEventHandler("onClientGUIClick", cancelBtn, closeMain) memo = guiCreateMemo(0.39, 0.58, 0.23, 0.07, "Trucking Job is new, it may have bugs. If you find any please report, Illegal load is non-functional right now..", true) guiMemoSetReadOnly(memo, true) end end addEventHandler ( "onClientMarkerHit", myMarker , MarkerHit ) --Functions-- function closeMain() guiSetVisible (acceptBtn, not guiGetVisible ( acceptBtn ) ) guiSetVisible (acceptBtn2, not guiGetVisible ( acceptBtn2 ) ) guiSetVisible (cancelBtn, not guiGetVisible ( cancelBtn ) ) guiSetVisible (memo, not guiGetVisible ( memo ) ) showCursor(false) end function startMissionA() guiSetVisible (acceptBtn, not guiGetVisible ( acceptBtn ) ) guiSetVisible (acceptBtn2, not guiGetVisible ( acceptBtn2 ) ) guiSetVisible (cancelBtn, not guiGetVisible ( cancelBtn ) ) guiSetVisible (memo, not guiGetVisible ( memo ) ) triggerServerEvent ( "startTheMission", resourceRoot) showCursor(false) end How would I fix?
-
The question is, How would I do this with EventHandlers? addEventHandler ("onVehicleExit", rootElement, vehicleExit) addEventHandler ("onMarkerHit", FinishPoint , EndTheMission) addEventHandler ("onPlayerQuit", rootElement, onQuit)
-
I know that I cannot create more then one of the same functions, but the question I'm asking is how would I get it so 2 or more people can use the same function in this just Example : "Finisha" if one person accepts the job then another person accepts it, then it removes the first players ability to finish the job. How would I get around this?
-
How would 2 or more players use the same function? When one player gets they trailer/load it over writes the previous player and will not let them deliver.
-
The issue is not the blips and stuff, those individually get assigned to the player who hit the marker. But the functions that let the player actually finish the mission, and remove the trailer and finish point if the player leaves the truck or disconnects.
-
Well I already found the issue but something I cannot figure out is how to allow more then one person to do the job at a time, It creates more then one event handler for the players and over writes the first one. Any idea on how to get around this?
-
Ohhh, thank you. Missed those, have been working on this script with no sleep for few days trying to get it working.
-
What do you think I have been been doing? I wouldn't stay up till 3-5 am just to sit around and do nothing, I have been debugging it, I cannot find the issue.
-
Script is a trucking job, when player accepts job it creates blip and marker and connects trailer to the truck they are in, when they hit blip they get payed and the trailer disapears, Issue I'm having is when they hit the marker nothing happens, and none of the functions to remove trailer if they leave, disconnect etc are working. Cannot find what I did wrong. -- Detects truck and starts mission -- function startMissionAAA ( hitElement) if getElementType ( hitElement ) == "vehicle" and getVehicleOccupant ( hitElement ) --Creates trailer, and attaches it to the truck-- trailer = createVehicle (435, -208.95801, -211.38281, 1.421875, 0, 0, 180) setVehicleVariant (trailer, 0, 0) attachTrailerToVehicle ( hitElement, trailer ) Defines the driver and the truck -- PlayerAb = hitElementa truckMain = hitElement --Creates blips for the finnish-- finisha = createMarker (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], "cylinder", 3, 0, 200, 55, 255, hitElementa) blip = createBlip (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], 0, 2, 255, 0, 0, 255, 0, 10000, hitElementa) Event Handlers -- addEventHandler ("onTrailerDetach", getRootElement() , trailerDetach) addEventHandler ("onVehicleExit", getRootElement(), vehicleExit) addEventHandler ("onMarkerHit", finisha , EndTheMission) addEventHandler ("onPlayerQuit", getRootElement(), onQuit) Functions for removing trailer if something goes wrong -- function destroyVehicle () -- function trailerDetach () if source == trailer then -- function vehicleExit (PlayerAb) if source == truckMain then -- function onQuit () if source == PlayerAb then -- --End function -- function EndTheMission (hitElement) if hitElement == trailer then outputChatBox ("End money is " .. tableMoney[randomLoc] .. "$ If you would like to continue head back to one of the trucking depos.", PlayerAb, 255, 255, 255, true) givePlayerMoney (PlayerAb, tableMoney[randomLoc]) --destroyThings destroyElement (trailer) destroyElement (finisha) destroyElement (blip) --removeEventHandlers removeEventHandler ("onTrailerDetach", getRootElement(), trailerDetach) removeEventHandler ("onVehicleExit", getRootElement(), vehicleExit) removeEventHandler ("onPlayerQuit", getRootElement(), onQuit) else return false end end It may be alot but any help would be appreciated. I have been staying up till 3-4 am trying to get this script working.
-
https://wiki.multitheftauto.com/wiki/Ge ... ngineState
-
Try stopping the Editor GUI
-
Well that worked, but it seams the rest of the script no longer works.
-
How would I do it so it checks for driver when the towing vehicle is attatched to the trailer?
-
towingVehicle = getVehicleTowedByVehicle ( trailer ) playeraab = getVehicleOccupant ( towingVehicle ) trailer = createVehicle (435, 64.477539, -268.84082, 3, 0, 0, 360) error in debugscript - Expected vehicle argument for getVehicleTowedbyVehicle and GetVehicleOccupant.
-
--Nvm ignore what was here--
-
Worked thx, hopefully that's all the help I need with this.
-
That works, but so I do not have to start a new thread, any idea why this is not working? addEventHandler ( "onClientGUIClick", cancelBtn, Cancela, true ) function Cancela () guiSetVisible ( acceptBtn, false ) guiSetVisible ( acceptBtn2, false ) guiSetVisible ( cancelBtn, false ) guiSetVisible ( memo, false ) end It gives me Error, expected element in argument 2 for the event handler.
