Jump to content

IIYAMA

Moderators
  • Posts

    5,843
  • Joined

  • Last visited

  • Days Won

    160

IIYAMA last won the day on May 10

IIYAMA had the most liked content!

About IIYAMA

  • Birthday 01/01/2016

Member Title

  • Global Moderator

Details

  • Gang
    [HB]
  • Location
    Netherlands
  • Occupation
    I have never been to the streets of SA... so who knows?
  • Interests
    Design, scripting, UX/UI

Recent Profile Visitors

18,349 profile views

IIYAMA's Achievements

Gangsta

Gangsta (45/54)

1.4k

Reputation

  1. See useful function getPedGender for getting the gender. https://wiki.multitheftauto.com/wiki/GetPedGender (getPedGender and getSkinGender) As for the skins table: local maleSkins = skins[1] -- returns a table print(maleSkins[1]) -- first male skin local femaleSkins = skins[2] -- returns a table print(femaleSkins[1]) -- first female skin
  2. Requiring a loop and a table. function generateRandomNumbers (count, maxSize) local randomNumbers = {} for i=1, count do randomNumbers[#randomNumbers + 1] = math.random(maxSize) end return randomNumbers end local randomNumbers = generateRandomNumbers(30, 10) -- Generate 30 random numbers. With a max value of 10 print(1, randomNumbers[1]) -- 1 <random number> print(5, randomNumbers[5]) -- 5 <random number> print(10, randomNumbers[10]) -- 10 <random number> print(30, randomNumbers[30]) -- 30 <random number>
  3. It is a bit tricky, but not impossible. And if the rotation is inverted, then invert the rotation. But yes, changing the engine is not possible, there will always be some limitations.
  4. Not sure, but this is how you can get the camera rotation: local cameraElement = getCamera() -- local x, y, z = getElementRotation(cameraElement) --
  5. onClientElementDataChange, that is if you do not mis use elementdata. For example setting element data every frame. If the event onClientElementDataChange is triggered more than ~5x each second (9 func calls x 1s vs ~2 func calls each update, 9 / 2 = ~5). The timer will be more optimised than the event. (9x with different element data key) But in general the timer has a slower update timing, which should also taken in consideration.
  6. I agree with XaskeL, clusters are the most efficient way of doing this. @Hydra Feel free to use this cluster library, which I am using for the airplane resource. Or find another library if the cells are too large, there should be more available. (this is size 31x31) local sourceMap = Cluster:new() --[[ SET ]] local cell = sourceMap:getCellFromWorldMap( x, y ) if cell then cell:setData( "key", "<mixing>" ) end --[[ GET using position ]] local centerCell = sourceMap:getCellFromWorldMap( x, y ) local cellCollection = sourceMap:getCellsBetweenCells( sourceMap:getCellFromSourceMap( centerCell.x - 1, centerCell.y - 1 ), sourceMap:getCellFromSourceMap( centerCell.x + 1, centerCell.y + 1 ) ) -- 9 cells returned (but can be less) -- LOOP: cellCollection cell:getData( "key" ) --
  7. For the resource servertimesync, I am using this method to solve that problem. 1. I am using the function getServerTime to get the time, if available. local timeNow = exports.servertimesync:getServerTime() 2. If it not available, then I am also listening to the event "onServerTimeInitialized", which is triggered when the data is available. addEventHandler( "onServerTimeInitialized", root, function() end )
  8. setElementDoubleSided(obj, true) https://wiki.multitheftauto.com/wiki/SetElementDoubleSided If the object is successful created, you can use this function to make the object doublesided.
  9. You can reduce this code btw, by disable caseSensitive. bool addCommandHandler ( string commandName, function handlerFunction [, bool caseSensitive = true ] ) addCommandHandler("buy", detectPanel, false) As for your initial question. local zones_CScns = {["Jefferson"] = true} local zones_GTcns = {["Rodeo"] = true} --- ... if zones_CScns[gps] then CScns() elseif zones_GTcns[gps] then GTcns() end or -- !Order matters local zones --- ... local theFunc = zones[gps] if theFunc then theFunc() else -- do something else... end -- ... functions CScns and GTcns here zones = {["Jefferson"] = CScns, ["Rodeo"] = GTcns}
  10. Like this. When adding a subscriber, the data will be automatic synced. Here you have a test resource to see the behaviour of all stages. Very recommended to test it out, so that you do not add too much code.
  11. Step 1: Find ALL existing slots This method does not do that unfortunately. So you will have to create a new one. local carrySlots = self:findExistingItemSlots(itemID) Step 2: Fill those up. Step 3: Create new slots for the remaining items. Repeat until is fine. repeat local slotX, slotY = self:findFreeSlotForItem(itemID) if slotX then local countInsert = math.min(count, itemDetails.stacklimit) -- ... local newItem = { ["itemID"] = itemID, ["count"] = countInsert, ["slot"] = {x = slotX, y = slotY}, } count = count - countInsert -- ... end until count == 0 or not slotX Step 4: Return the items that do not fit, so that you can decide what to do with those. local remainingItems = object:giveItem(1, 8) if #remainingItems > 0 then iprint("items do not fit", #remainingItems) end
  12. You are not finished in the slightest + a lot of edge cases to look at. The most significant optimisation will be applied when working with subscriber mode. This will stop sending element data to other players and only the ones that need it. On vehicle enter: addElementDataSubscriber(veh, "Fuel", thePlayer ) On vehicle exit: removeElementDataSubscriber(veh, "Fuel", thePlayer ) https://wiki.multitheftauto.com/wiki/AddElementDataSubscriber setElementData( veh, "Fuel", fuelVeh, "subscribe" ) https://wiki.multitheftauto.com/wiki/SetElementData
  13. Clientside Doing a live check: if isPedInVehicle(localPlayer) then Serverside Add some more local's etc. local veh = getPedOccupiedVehicle(source) local stateG = getVehicleEngineState(veh) And make use of arguments for the vehMove() function. vehMove(veh, fuelVeh, x, y, z) -- in > arguments ------------- function vehMove(veh, fuelVeh, x, y, z) -- out > parameters That way you make sure that the data stays within the functions. Adding a fallback for new vehicles (until there is data available from a database): local fuelVeh = getElementData(veh, "Fuel") or 0 -- or set to max This doesn't looks like a logic line, there is no value change so there is no need to set it: setElementData(veh, "Fuel", fuelVeh) ------if the fuel it's above 0 then the fuel recieved it's saved (this is because of the next function)
  14. local duration = 10000 function cinematic1() smoothMoveCamera(2444.0747070312, -1656.7917480469, 28.93049621582, 2526.1335449219, -1710.7858886719, 10.195858001709, 2489.0947265625, -1636.412109375, 30.221374511719, 2499.2856445312, -1728.2391357422, -8.0401239395142, 10000) setTimer(cinematic2, duration , 1) end function cinematic2() smoothMoveCamera(1726.8065185547, -1484.8432617188, 143.54656982422, 1670.5084228516, -1413.7943115234, 185.7670135498, 1535.7916259766, -1267.5806884766, 272.14398193359, 1474.7834472656, -1199.0876464844, 311.97747802734, 10000) setTimer(cinematic3, duration , 1) end function cinematic3() smoothMoveCamera(1338.3666992188, -1257.4116210938, 95.983924865723, 1352.1002197266, -1257.2800292969, -3.0684490203857, 1340.6787109375, -1498.6977539062, 95.983924865723, 1354.4122314453, -1498.5661621094, -3.0684490203857, 10000) setTimer(cinematic1, duration , 1) end setPlayerHudComponentVisible("all", false) cinematic1() -- start Try this.
  15. Clientside is located on the player their pc. When the game is not running, you are able to modify your downloaded files. Files which are defined by the server meta.xml are protected and will be validated (+reset if incorrect). But files created by Lua scripts are not. As long as it is not setElementData, it is fine. Building the fuel system fuel-value-management clientside is OK, but not great.
×
×
  • Create New...