Jump to content

IIYAMA

Moderators
  • Posts

    6,089
  • Joined

  • Last visited

  • Days Won

    216

Everything posted by IIYAMA

  1. Ask your self first: "how do I refer to any of these values?" Inspect your table: iprint(items ) Until you are able to get the first and the second value. After that (tell me when you are ready) we are going to take the easy route: guiCreateGridList. Because the concept of "dx items" seems to be a too high level for now.
  2. Set it to 0, every frame. https://wiki.multitheftauto.com/wiki/OnClientRender
  3. Do first all the steps from above. Then structure your table and sub-tables like this: local items = { { label = "Test1", value = 1 }, { label = "Test2", value = 2 }, { label = "Test3", value = 3 } } local item = items[1] iprint("The label is:", item.label, " and the value is: ", item.value) Main table: local items = { { label = "Test1", value = 1 }, { label = "Test2", value = 2 }, { label = "Test3", value = 3 } } Sub-tables: local items = { { label = "Test1", value = 1 }, { label = "Test2", value = 2 }, { label = "Test3", value = 3 } }
  4. Are the images drawn from path? (not recommended: line 68) If not, what are the arguments you use for the textures?
  5. You need this part of you previous code: local items = {{"Test"},{"Test1"},{"Test2"},} for i = currentCell + 1, maxRows + currentCell do local value = items[i] local key = i - currentCell - 1 if value ~= nil then -- check cursor here end end You need the position of the rectangle: dxDrawRectangle ( float startX, float startY, float width, float height ) screenW * 0.7499, screenH * 0.3269+((key)*27), screenW * 0.2380, screenH * 0.025 Combine that with this useful function (don't forget to copy the function from that wiki page): https://wiki.multitheftauto.com/wiki/IsMouseInPosition isMouseInPosition ( int x, int y, int width, int height ) And you need a break to stop the loop: --for i=1, 100 do --if something then --outputChatBox("found") break --end --end Can you build it with all the bricks from above?
  6. Before I forget. If you want to SET it per player. setElementData(player, "weaponmodel", --[[...]]) GET for yourself. getElementData(localPlayer, "weaponmodel")
  7. Nope, this is what it should become: {123, 321, 231, 312, 132} Unless you want to add more data PER weapon model. Btw if you want to send + get data to each individual:
  8. By putting it in a new table. local newTable = {} for k,v in ipairs(weapons) do newTable[#newTable + 1] = v["model"] end and SET that.
  9. Don't save it per player. Because everybody will download the data double/triple/10x/100x/1000x... ? Save all data inside of the element resourceRoot, under the key "weaponmodel" local weapons = dbPoll(query,-1) if weapons then setElementData(resourceRoot, "weaponmodel", weapons) end Now debug the data, when it is available. local weapons function draw() weapons = weapons or getElementData(resourceRoot, "weaponmodel") -- if no data from buffer, get the data. if weapons then dxDrawText(inspect(weapons), 300, 300) end end addEventHandler("onClientRender", root, draw)
  10. You are SET the elementData to each player element and you try to GET the elementdata from the root element. (Not the same element) Recommendation: - SET and GET it with the resourceRoot. - GET the data each frame, because you do not know when it is available.
  11. There are fade in/out states for the camera, maybe a script sets an invalid value, does not set the right one or none at all. https://wiki.multitheftauto.com/wiki/FadeCamera
  12. By cancelling these event: https://wiki.multitheftauto.com/wiki/OnClientPlayerHeliKilled (Players) https://wiki.multitheftauto.com/wiki/OnClientPedHeliKilled (Peds) See examples on those pages.
  13. You can attach an object to the weapon (same model) and set the opacity of the weapon-element to 0. This way you can change the attach offset in depended.
  14. You can only use WHERE once. After that you have the operators: AND, OR and NOT at your disposal. See these examples: https://www.w3schools.com/sql/sql_and_or.asp
  15. Be careful with this, doing this every frame will kill the network of other players that are not inside of the local-network. The following function can be used to reduce update. (every 300 milliseconds) if checkPassiveTimer("attachedToWeapon_aim", true, 300) then setElementData ( localPlayer, "attachedToWeapon_aim", {hitX,hitY,hitZ} ) end It is a useful function (by me), source code can be found here: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer
  16. I have experimented with the first part. The rest is for you to do. setElementAlpha(localPlayer, 0) addEventHandler("onClientResourceStop", resourceRoot, function () setElementAlpha(localPlayer, 255) end) addEventHandler("onClientPreRender", root, function () --[[ Creating the direction vector ]] local cameraX, cameraY, cameraZ, lx, ly, lz = getCameraMatrix() local directionVector = (Vector3(lx, ly, lz) - Vector3( cameraX, cameraY, cameraZ)) directionVector:normalize ( ) directionVector = directionVector * 300 local screenX, screenY = guiGetScreenSize() local startPositionX, startPositionY, startPositionZ = x, y, z local turrentX, turretY, turretZ = getElementPosition(localPlayer) -- must be the turret position turretZ = turretZ - 0.2 -- < just for test purposes -- draw turret dxDrawLine3D(turrentX, turretY, turretZ, turrentX, turretY, turretZ - 0.5, tocolor(0,0,0)) dxDrawLine3D(turrentX, turretY, turretZ - 0.5, turrentX + 0.5, turretY, turretZ - 1, tocolor(0,0,0)) dxDrawLine3D(turrentX, turretY, turretZ - 0.5, turrentX - 0.5, turretY, turretZ - 1, tocolor(0,0,0)) dxDrawLine3D(turrentX, turretY, turretZ - 0.5, turrentX, turretY - 0.5, turretZ - 1, tocolor(0,0,0)) dxDrawLine3D(turrentX, turretY, turretZ - 0.5, turrentX, turretY + 0.5, turretZ - 1, tocolor(0,0,0)) -- detect any hits local hit, hitX, hitY, hitZ, elementHit = processLineOfSight ( turrentX, turretY, turretZ, cameraX + directionVector.x, cameraY + directionVector.y, cameraZ + directionVector.z, true, -- checkBuildings true, -- checkVehicles true, -- checkPlayers true, -- checkObjects false, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff localPlayer -- element ignoredElement ) if not hit then hitX, hitY, hitZ = cameraX + directionVector.x, cameraY + directionVector.y, cameraZ + directionVector.z end dxDrawText(hit and "COLLISION!" or "NO COLLISION!", 300, 300) -- draw the line + cursor dxDrawLine3D(turrentX, turretY, turretZ, hitX, hitY, hitZ) local cursorX, cursorY = getScreenFromWorldPosition (hitX, hitY, hitZ) if cursorX then dxDrawCircle ( cursorX, cursorY, 10) dxDrawCircle (screenX / 2, screenY / 2, 10) end end)
  17. That is the first step. Depending on the dimension size. Like milliseconds/seconds/minutes/hours/days, you can also save a lot of data at these 2 dimensions: milliseconds/seconds Are those dimensions included? If yes, then I can explain a little bit more. Server triggerClientEvent(receivers, "<eventName>", resourceRoot, date) Client -- <triggerClientEvent resource> addEvent("<eventName>", true) -- <resource 1> addEventHandler("<eventName>", root, function () end) -- <resource 2> addEventHandler("<eventName>", root, function () end) ---------------------- -- or more specified. ---------------------- -- <resource 1> addEventHandler("<eventName>", getResourceRootElement ( getResourceFromName ("<triggerClientEvent resource name>")), function () end, false) -- <resource 2> addEventHandler("<eventName>", getResourceRootElement ( getResourceFromName ("<triggerClientEvent resource name>")), function () end, false)
  18. Before I give you recommendations. You will have to make a choice. -[x] left and right? - [ ] up and down? Complexity (synchronisation) +1 - [ ] crosshair based on camera? Complexity + 2 - [ ] crosshair based on turret? - [ ] crosshair left/right based on camera Complexity + 1 + crosshair up/down based on turret?
  19. You know what the local keyword does right??? If not, watch this video. local Weapon = createWeapon("minigun",0,0,0) Weapon = createWeapon("minigun",0,0,0) Extra function ClientfireWeapon() if isElement(Weapon) then setWeaponState ( Weapon, "firing" ) end end
  20. IIYAMA

    Server bug!

    "Alphabetical order", I don't think that should be the correct order, that is if the start-up order matters. In most gamemodes there is inside of the meta.xml(of the gamemode) a few <include/> tag located. https://wiki.multitheftauto.com/wiki/Meta.xml These are used to make other resources to start up with them. They also define the start-up order. For example in stealth: <meta> <info author="Slothman" version="1.0.2" name="Stealth" description="Allow scripts to insert a ped that simulates combat with a real player" type="gamemode" /> <!-- ... --> <include resource="scoreboard" /> <include resource="killmessages" /> <include resource="maplimits" /> <!-- ... --> </meta>
  21. IIYAMA

    Server bug!

    Sounds like an configuration setting went wrong after closing the server. Your only friend here, is to add debug lines in the most important components of your gamemode and check which debug line doesn't show up. You might also want to check if the start-up order is correct. Some resources do require other resources to be even working, an incorrect start-up order can mess the initialization up.
  22. @majqq Keep in mind that even if there is no data added, the triggerClientEvent it's (5x?) packet size is bigger than that from setElementData. And triggerClientEvent is also a lot faster and therefore it's data rate is higher, if no buffer is used, it will cause blocking the network a lot faster than with setElementData. So if you broadcast to all players, triggerClientEvent might not always be the best option, because you do not reduce data. triggerClientEvent Fast data rate / requires a slow interval Run code directly / (with elementdata that is only possible for the second time you set the data) More secure No auto download for new players Specify target players* *Before the beta from below. There is a new function available in the beta for element data, that will help shrink the data usage of players that do not need the data. https://wiki.multitheftauto.com/wiki/AddElementDataSubscriber More information here: https://wiki.multitheftauto.com/wiki/SetElementData
  23. WIKI

    Yesterday I added my first wiki page. Which is not necessary something you call 'news'. But it was a lot of fun figuring out how the interface actually works. It is to be honest not very beginner friendly, even though there is a lot of documentation added. documentation

     

    The page/function which I added to the useful functions list:

    https://wiki.multitheftauto.com/wiki/CheckPassiveTimer

    This useful function allows you to use passive timers in your conditions. For example you want to prevent players repeatedly using a command.

    I named the function 'checkPassiveTimer', not sure if that is the best name for it, since it it does SET, CHECK and UPDATE, (+ Clean up cycle), depending on the situation. Checking is what you expect it actually does, so I picked that one.

     

    addCommandHandler("candy", 
    function (player)
    	if checkPassiveTimer("candy timer", player, 5000) then
    		outputChatBox("YES, EAT!", player)
    	else
    		outputChatBox("NO CANDY FOR YOU!", player)
    	end
    end)

     

    Does anybody have any suggestions/idea's/?? Or more experience than me with the WIKI + suggestions or improvements for the format?

    1. IIYAMA

      IIYAMA

      I also added the remaining wait time, which is the finish touch for this useful function. It is very awkward that you only notice `that it was missing something` after using it yourself. ?

      addCommandHandler("candy", 
      function ()
      	local status, remainingTime = checkPassiveTimer("candy timer 2", true, 5000) 
      	if status then
      		outputChatBox("YES, EAT!")
      	else
      		outputChatBox("NO CANDY FOR YOU! You will have to wait " .. math.ceil(remainingTime / 1000) .. " seconds.")
      	end
      end)

       

  24. local nextCommandTime = {} -- function () local key = getPlayerSerial(player) -- serial based -- or local key = player -- element based local timeNow = getTickCount() if timeNow > (nextCommandTime[key] or 0) then nextCommandTime[key] = timeNow + 10000 else -- You will have to wait! end -- end By comparing current operating time with a fixed operating time + future offset, can be used to limit executions. ACL Manually: - Shut down the server (important) Disable commands in ACL: (add to the group: <acl name="Default">) <right name="command.fabricar" access="false" /> Enable commands in ACL: (add to the group you want to have access to this command) <right name="command.fabricar" access="true" /> - Save file - Start the server Or use admin panel to add those rights. @~Sr.Victor
  25. You can only cancel the server variant. onClientVehicleStartExit If the wiki doesn't indicates that it can be cancelled, then you can't cancel it.
×
×
  • Create New...