Jump to content

IIYAMA

Moderators
  • Posts

    6,063
  • Joined

  • Last visited

  • Days Won

    209

Everything posted by IIYAMA

  1. This is exactly what I meant. function EndTheMission (hitElement) if hitElement == TrailerAb then As I said before, it makes the resource only working for 1 player at the time. When you want more players to be able to use it at the same time, you simply need tables.
  2. The random player has no team.
  3. onVehicleExit, replace the rootElement with the truck element. onPlayerQuit, replace the rootElement with the player element. And with onMarkerHit you compare inside the function, the hitElement(first argument) with the truck element.
  4. If you want to get around that, you will have to assign this job to only player. Doing this by storing it's userdata/player inside a variable and checking it when another player tries to do the same job.
  5. because there is only 1 function or well there is only 1 variable that holds that function. But that is not the problem, the problem is with the data. The data is shared between all other players, because it is serverside code.
  6. Ask the last question again to yourself. Isn't it obviously with a job resource that more players are using the same variables? If you can't and won't understand the logic of this, then you will be working on a system that can never be used by multiple players. I can't fix something that can't be fixed, sorry.
  7. For managing multiply data you need to use tables. For example you start a job for a player. truckerJobData = {} -- declare on top of your script. [/divbox] When you start this job, you do this: truckerJobData[player] = {} You use the player as key of the table. Which is between the brackets > [ ]. I saw tables before in your resource, so you probably already know how they work. You inset an empty table in there, which you can fill up later on. [divbox=#000000] The next step is to redeclare the table in a variable of choice: (this is just a method I like to use) local playerTruckerJobData = truckerJobData[player] [/divbox] After redeclaring the variable that gives access to the empty table, you are going to collect and create the data of the job. This can be the: truck, trailer, blip and marker. local finisha = createMarker (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], "cylinder", 3, 0, 200, 55, 255, hitElementa) local blip = createBlip (tableLocationsX[randomLoc], tableLocationsY[randomLoc], tableLocationsZ[randomLoc], 0, 2, 255, 0, 0, 255, 0, 10000, hitElementa) local truckM = createVehicle(514, -715, 963, 12) local trailer = createVehicle ( 435, 0, 0, 4 ) [divbox=#000000] And the last step is to insert the required data of the job, inside your empty table. playerTruckerJobData["blip"] = blip playerTruckerJobData["marker"] = finisha playerTruckerJobData["truck"] = truckM playerTruckerJobData["trailer"] = trailer There are a few ways to do it, but try first this one, because it is easy to read. [/divbox] Ones you did that, you can access your: trailers, trucks, blips and markers very easy. The only thing you need to do is knowing the player/(player-userdata). To access your trailer and destroy it, example: local playerTruckerJobData = truckerJobData[player] if playerTruckerJobData then -- if the player have any job data then ... local trailer = playerTruckerJobData["trailer"] -- then get the trailer element. if isElement(trailer) then -- check if the trailer still does exist in the MTA world. destroyElement(trailer) -- destroy the trailer. end end
  8. I am looking at your code and I can figure out some of the issues. Pls ask those questions bellow to yourself: - What happens when you execute the function getRootElement()? - What happens when you attach an addEventHandler with a root element? - What happens when you declare a global variable twice with a different value? For example the variable 'trailer'.
  9. You are doing that to yourself, if you are skipping the debug guide. https://wiki.multitheftauto.com/wiki/Debugging Every mistake can be found with that guide.
  10. IIYAMA

    [HELP] Please

    debug the variable banTime... if you want to know which condition you have to use.
  11. You can only get it's position: https://wiki.multitheftauto.com/wiki/GetPedBonePosition But you can't actually get them.
  12. Line 17.............. .................................................................................................................................. .................................................................................................................................. .................................................................................................................................. .................................................................................................................................. .................................................................................................................................. .................................................................................................................................. ............ Ask him yourself, it is his script. -__-"
  13. IIYAMA

    [HELP] Please

    No, I don't think so. Because the real time never stops, while the ban time is static. function WwW (banPointer, responsibleElement) local player = source local banTime = getBanTime(banPointer) if not banTime then -- ban time isn't specific, so perma ban. setElementData(player, "Data", (getElementData(player, "Data") or 0) + 1) else --local seconds = banTime - getRealTime().timestamp setElementData(player, "Data2", (getElementData(player, "Data2") or 0) + 1) end end addEventHandler ( "onPlayerBan", getRootElement(), WwW )
  14. IIYAMA

    [HELP] Please

    But your main problem is that 'onPlayerBan' doesn't support: seconds, data, additional Only the banPointer and it's responsibleElement. Use ban functions instead: function WwW (banPointer, responsibleElement) local player = source -- The player that gets banned. local seconds = getBanTime(banPointer) - getRealTime().timestamp
  15. IIYAMA

    [HELP] Please

    The element data will directly be removed after the player is banned... It will not even synchronized with the other players in the server because it is a slow transfer.
  16. 'next' returns the first data and it's index of a table if there is. The reason why the code fails is because the vehicle is nil/false. Which causes getVehicleOccupants to fail working(you also got an warning of that) and will return nil... next(nil) = ERROR. So... Replace line 2 with: if not isElement(vehicle) or getElementType(vehicle) ~= "vehicle" then return false, nil end
  17. The only thing you had to do was removing the variable that holds the function. Because you want to insert the function inside the variable 'table' in it's table, and not in the variable 'testFunction'. - testFunction table = { [1] = {"table item", "table item", "event", function () outputChatBox ("test") end } } Execute the function: table[1][4]()
  18. by learning to edit col files. Can't help you with that.
  19. Probably 1 of your models contain collision of the other models. Which you can only use when you place the exact same objects on the exact same order next to each other.
  20. -- debug -- addEventHandler("onClientRender",root, function () ------------- local playerHealth = math.min(getElementHealth(localPlayer),100) local strangeValue = 1000 -- We start at 1000 (when you have 100 health) strangeValue = strangeValue + ((100-playerHealth)*100) -- debug -- dxDrawText("strangeValue: " .. strangeValue, 300,300) end) ------------- ?
  21. just copy past this useful function in your code: function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end From: https://wiki.multitheftauto.com/wiki/IsPlayerInTeam and the custom function(isPlayerInTeams) can be used without any exports.
  22. IIYAMA

    MG nest

    It is code from scratch,
  23. - Did you test it with other sounds and formats? - Try it to play it at 'onClientResourceStart' just to be sure. - Try it as local file, because the lua code doesn't wait for it to load from the url. etc. There are a lot of conditions why it might not work. The only thing you can do is by check them all, till you find the solution/problem.
×
×
  • Create New...