-
Posts
6,063 -
Joined
-
Last visited
-
Days Won
209
Everything posted by IIYAMA
-
And why don't you show us the code then? Do you really think we can see through your eyes? !
-
What don't you understand about our explanations? We gave you two solutions, where for one already copy past ready is... -_-"
-
Then you should not have said that, because it has nothing to do with the problem. And you know now how to solve it...
-
By checking if the key is pressed. https://wiki.multitheftauto.com/wiki/GetKeyState and a bindKey for the first execution. Use one function for the marker and a second one for the bindkey.
-
Company system. So i need takePlayerMoney from player and givePlayerMoney to company. That has at the moment nothing to do with this. You are using addCommandHandler and not the company resource to trigger this function.
-
When the tonumber function receive something else than number characters(as a string), it will return nil/false. Problem will remains the same when you type wrong characters.
-
Where are you debug lines mate? Add one between line 1 and 2. Add one between line 4 and 5. Add one between line 6 and 7. Add one between line 8 and 9. Add one between line 11 and 12. Add one between line 13 and 14. ETC. And don't add an addEventHandler with "onClientKey" inside this function, because you can't remove that addEventHandler any more. At the end you will have (30+) addEventHandlers, each time you refuel your vehicle another addEventHandler + function will be created and added.
-
Apply the math.floor function on line 5... instead of where it is now.
-
Apply the math.floor function on the variable >amount<, after converting(tonumber) and the validation(if amount then). Which ends at line 4.
-
local payaddon = playerTruckerJobData["Illegal"] and 5000 or 0
-
1 x function = 1 x end 1 x if = 1 x end There are 3 ends, 1 function and 0 if's
-
np.
-
np.
-
Ah I see. Indeed a sort of 'hack'.
-
Typo: function vehicleExit (PlayerAb) local playerTruckerJobData = truckerJobData[player] function vehicleExit (PlayerAb) local playerTruckerJobData = truckerJobData[PlayerAb] Add argument of the player. destroyTimer = setTimer (destroyVehicle, 600000, 1) local destroyTimer = setTimer (destroyVehicle, 600000, 1,PlayerAb) insert the timer >destroyTimer< into playerTruckerJobData. playerTruckerJobData["timer"] = destroyTimer So every player has his own timer. Timers don't support a source element, replace like this: function destroyVehicle (PlayerAb) -- local playerTruckerJobData = truckerJobData[PlayerAb] -- removeEventHandler ("onPlayerQuit", PlayerAb, onQuit) -- truckerJobData[PlayerAb] = nil How do I get this PlayerAb there? Like this: local destroyTimer = setTimer (destroyVehicle, 600000, 1,[color=#FF0000]PlayerAb[/color]) function destroyVehicle ([color=#FF0000]PlayerAb[/color])
-
Those functions are for checking if elements are rendered by the GTA engine. step 1) You add those two events to two functions. step 2) On both of those functions. You validate the source element with the type "vehicle", using the function getElementType. step 3) Use the event onClientElementStreamIn (+ function) to insert the a sound with the source as key of the table. local sound = playSound3D(engine_sound, x, y, z, true) if sound then local_sound[source] = sound setElementParent(sound,source) end and you set the source element as parent of the sound element with setElementParent. (when the vehicle gets destroyed, the sound element is also gone) step 4) Use the event onClientElementStreamOut (+ function) to receive the sound with the source as key of the table. Delete the sound with stopSound. And as last you nil a table location with the sound element as key. local sound = local_sound[source] if isElement(sound) then destroyElement(sound) end local_sound[source] = nil Extra info The only thing you have to take a closer look at is that you have to check the table ones in while(maybe 2 hours?) for destroyed vehicles. This can be done with using getTickCount(). But this is extra, I don't think there are a lot of players playing longer than 10 hours. Or you can choose for onClientElementDestroy to replace the use of setElementParent.
-
By putting this inside the function you are going to call from. With a valid playerAb element as argument.. startMissionAAA(playerAb)
-
I told you with huge letters not to apply an addEventHandler to the startMissionAAA function. And take over that function correctly.
-
Wtf, that works O_o Thank you very much!
-
Small update on the endTheMission. function endTheMission (truckMain,matchingDimension) if matchingDimension then local playerAb = getVehicleOccupant(truckMain) if playerAb then local playerTruckerJobData = truckerJobData[playerAb] if playerTruckerJobData and playerTruckerJobData["vehicle"] == truckMain and playerTruckerJobData["marker"] == source then -- Check if all data is correct. outputDebugString("endTheMission") local randomMoney = (tonumber(tableMoney[randomLoc]) or 0) outputChatBox ("This load got you " .. randomMoney .. "$ If you would like to continue head back to one of the trucking depos.", playerAb, 255, 255, 255, true) givePlayerMoney (playerAb, randomMoney) setPlayerTeam ( playerAb, NoJob ) ------------------ -- the clean up -- local trailerAb = playerTruckerJobData["trailer"] local blip = playerTruckerJobData["blip"] --removeEventHandlers removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onPlayerQuit", playerAb, onQuit) removeEventHandler ("onMarkerHit", source , endTheMission) --destroyThings if isElement(trailerAb) then -- validate(if is still exist) before destroy destroyElement (trailerAb) end if isElement(blip) then -- validate(if is still exist) before destroy destroyElement (blip) end destroyElement(source) -- destroy the marker, no validate needed. (element used in event, so must exist) destroyElement(truckMain) -- destroy the truck, no validate needed. (element used in event, so must exist) truckerJobData[playerAb] = nil -- clean up -- the clean up -- ------------------ end end end end The onQuit function. function onQuit () local playerTruckerJobData = truckerJobData[source] if playerTruckerJobData then --destroyThings local truckMain = playerTruckerJobData["vehicle"] local trailerAb = playerTruckerJobData["trailer"] local finishPoint = playerTruckerJobData["marker"] local blip = playerTruckerJobData["blip"] --removeEventHandlers removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onPlayerQuit", source, onQuit) removeEventHandler ("onMarkerHit", finishPoint , endTheMission) if isElement(trailerAb) then -- validate(if is still exist) before destroy destroyElement (trailerAb) end if isElement(finishPoint) then -- validate(if is still exist) before destroy destroyElement (finishPoint) end if isElement(blip) then -- validate(if is still exist) before destroy destroyElement(blip) end if isElement(truckMain) then -- validate(if is still exist) before destroy destroyElement(truckMain) end truckerJobData[source] = nil end end The rest you have to do on your own. You have enough inspiration material now.
-
startMissionAAA < execute this function with the player as first argument. Don't add an addEventHandler on this function, but call it from another function(which might have an addEventHandler). function startMissionAAA (playerAb) local truckMain = getPedOccupiedVehicle(playerAb) if truckMain then truckerJobData[playerAb] = {} local playerTruckerJobData = truckerJobData[playerAb] local trailer = createVehicle (435, TrailerX, TrailerY, TrailerZ, 0, TrailerRotation, trailerType[randomLoc]) setVehicleVariant (TrailerAb, 5, 0) attachTrailerToVehicle ( truckMain, TrailerAb ) setPlayerTeam ( playerAb, TruckDriverAA ) --Location stuff-- local 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["vehicle"] = truckMain playerTruckerJobData["blip"] = blip playerTruckerJobData["marker"] = finishPoint playerTruckerJobData["trailer"] = trailer else return false end end function endTheMission (truckMain,matchingDimension) if matchingDimension then local playerAb = getVehicleOccupant(truckMain) if playerAb then local playerTruckerJobData = truckerJobData[playerAb] if playerTruckerJobData and playerTruckerJobData["vehicle"] == truckMain and playerTruckerJobData["marker"] == source then -- Check if all data is correct. outputDebugString("endTheMission") local randomMoney = (tonumber(tableMoney[randomLoc]) or 0) outputChatBox ("This load got you " .. randomMoney .. "$ If you would like to continue head back to one of the trucking depos.", playerAb, 255, 255, 255, true) givePlayerMoney (playerAb, randomMoney) setPlayerTeam ( playerAb, NoJob ) ------------------ -- the clean up -- local trailerAb = playerTruckerJobData["trailer"] local finishPoint = playerTruckerJobData["marker"] local blip = playerTruckerJobData["blip"] --removeEventHandlers removeEventHandler ("onVehicleExit", truckMain, vehicleExit) removeEventHandler ("onPlayerQuit", playerAb, onQuit) removeEventHandler ("onMarkerHit", source , endTheMission) --destroyThings if isElement(trailerAb) then -- validate(if is still exist) before destroy destroyElement (trailerAb) end if isElement(finishPoint) then -- validate(if is still exist) before destroy destroyElement (finishPoint) end if isElement(blip) then -- validate(if is still exist) before destroy destroyElement (blip) end destroyElement(source) -- destroy the marker, no validate needed. (element used in event, so must exist) destroyElement(truckMain) -- destroy the truck, no validate needed. (element used in event, so must exist) truckerJobData[playerAb] = nil -- clean up -- the clean up -- ------------------ end end end end
-
What is the best way to get the resource from the resourceRoot element? covert: getResourceRootElement() to getThisResource ( ) --convert: resourceRoot -- to resource I am trying to get the resource from an element in the game. local elementParent = source local elementsThatHaveParents = 0 repeat local elementParent_ = getElementParent ( elementParent ) if elementParent_ and elementParent_ ~= root then elementParent = elementParent_ elementsThatHaveParents = elementsThatHaveParents+1 else elementParent_ = nil end until not elementParent_ https://wiki.multitheftauto.com/wiki/Element_tree And this a workaround which I am not happy about. local theResourceThatOwnsThisElement = false local resourceTable = getResources() for i=1,#resourceTable do local resource = resourceTable[i] if getResourceRootElement(resource) == elementParent then theResourceThatOwnsThisElement = resource break end end
-
Take a look at this resource for inspiration: https://community.multitheftauto.com/in ... ls&id=6177 I used hedit in 2012 to collect the data and wrote that script afterwards.
-
Line 6 and 7. >local RPM = getVehicleRPM(veh)< >setElementData(veh,"RPM",RPM)< Move after: if veh then Line 19: Validate sound with isElement before destroying it. Line 31: Validate the sound with if state, before setting it's volume etc. Line 44: Makes no sense, nilling an location but losing access to the sound element. But what I strongly recommend you, is not using the player as key of the table but the vehicles instead. Use to add and remove from the table: https://wiki.multitheftauto.com/wiki/On ... ntStreamIn and https://wiki.multitheftauto.com/wiki/On ... tStreamOut
-
In a post before I explained exacly how to store and receive data from a table.