Jump to content

IIYAMA

Moderators
  • Posts

    6,062
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. IIYAMA

    About SLUA

    Also it is not handy to give lua files different extensions, since text editors do rely on them for applying the syntax. (Even if your own editor does know what to do with it, your friends * editor might not)
  2. IIYAMA

    FPS drops

    function Switch(button,press) wep = getPedWeaponSlot(localPlayer) a= {} for z=0,12 do a[z] = exports.SMGsettings:getSetting(tostring(z)) end for z= 0,12 do if button == a[0] then if(press) then setPedWeaponSlot(localPlayer, 0) end end if a[0] == a[z+1] then addEventHandler("onClientKey", root, function (button, press) if button == a[0] then if (press) then if wep == 0 then setPedWeaponSlot(localPlayer, z+1) else setPedWeaponSlot(localPlayer,0) end end end end) end end for z= 0,12 do if button == a[2] then if(press) then setPedWeaponSlot(localPlayer, 2) end end if a[2] == a[z+3] then addEventHandler("onClientKey", root, function (button, press) if button == a[2] then if (press) then if wep == 2 then setPedWeaponSlot(localPlayer, z+3) else setPedWeaponSlot(localPlayer,2) end end end end) end end for z= 0,12 do if button == a[3] then if(press) then setPedWeaponSlot(localPlayer, 3) end end if a[3] == a[z+4] then addEventHandler("onClientKey", root, function (button, press) if button == a[3] then if (press) then if wep == 3 then setPedWeaponSlot(localPlayer, z+4) else setPedWeaponSlot(localPlayer,3) end end end end) end end for z= 0,12 do if button == a[4] then if(press) then setPedWeaponSlot(localPlayer, 4) end end if a[4] == a[z+5] then addEventHandler("onClientKey", root, function (button, press) if button == a[4] then if (press) then if wep == 4 then setPedWeaponSlot(localPlayer, z+5) else setPedWeaponSlot(localPlayer,4) end end end end) end end for z= 0,12 do if button == a[5] then if(press) then setPedWeaponSlot(localPlayer, 5) end end if a[5] == a[z+6] then addEventHandler("onClientKey", root, function (button, press) if button == a[5] then if (press) then if wep == 5 then setPedWeaponSlot(localPlayer, z+6) else setPedWeaponSlot(localPlayer,5) end end end end) end end for z= 0,12 do if button == a[6] then if(press) then setPedWeaponSlot(localPlayer, 6) end end if a[6] == a[z+7] then addEventHandler("onClientKey", root, function (button, press) if button == a[6] then if (press) then if wep == 6 then setPedWeaponSlot(localPlayer, z+7) else setPedWeaponSlot(localPlayer,6) end end end end) end end for z= 0,12 do if button == a[7] then if(press) then setPedWeaponSlot(localPlayer, 7) end end if a[7] == a[z+8] then addEventHandler("onClientKey", root, function (button, press) if button == a[7] then if (press) then if wep ==7 then setPedWeaponSlot(localPlayer, z+8) else setPedWeaponSlot(localPlayer,7) end end end end) end end for z= 0,12 do if button == a[8] then if(press) then setPedWeaponSlot(localPlayer, 8) end end if a[8] == a[z+9] then addEventHandler("onClientKey", root, function (button, press) if button == a[8] then if (press) then if wep ==8 then setPedWeaponSlot(localPlayer, z+9) else setPedWeaponSlot(localPlayer,8) end end end end) end end end addEventHandler("onClientKey", localPlayer, Switch) Adding infinity addEventHandlers, to new created functions and not clearing the Switch function block after every execution. That is what causing the lagg. Your friend should be the one posting the code. If he wants to fix his code, he should start with making a flowchart to figure out which steps he has to make to rewrite his code. Because it is extremely unoptimised and should be recreated.
  3. local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ?",targetAccount) if #playercar1 > 1 then local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ? LIMIT 1",targetAccount) if #playercar1 == 1 then LIMIT 1 = max 1 result, useful for optimisation of the queries.
  4. local playercar1 = executeSQLQuery("SELECT Model FROM vehicleSlot1 WHERE PlayerName = ?",targetAccount) if #playercar1 > 1 then outputChatBox(getVehicleNameFromModel(playercar2[1].Model),source) else outputChatBox("slot 1 empty",source) end Typo. And download a SQL viewer from internet to check your data.
  5. Press brake before hitting them, no binds required afaik. Note: You are posting on the wrong section.
  6. if col and #getElementsWithinColShape(col, "player") > 1 or getNetworkStats().packetlossLastSecond > 1 then You cannot get the elements within a colshape, if the colshape doesn't exist. So you have to check if it exist, before doing the rest. if col and #getElementsWithinColShape(col, "player") > 1 or getNetworkStats().packetlossLastSecond > 1 then
  7. IIYAMA

    Image

    Then do not scale it. But keep it the same size... If you are not satisfied with my help, then please ask somebody else to help you with this.
  8. IIYAMA

    Image

    @Tekken How is that different from the screenshots?
  9. IIYAMA

    Image

    De-increase, not increase. Which should happen when you move away. Check the screenshots. Image1 Image2 Image3 Image4 If this is not what you want, then you should rewrite the concept so I can understand what you want.
  10. IIYAMA

    Image

    This topic has the awnser:
  11. With: https://wiki.multitheftauto.com/wiki/SetWeaponOwner ? Then it is probably a bug. You could try to fix it with: https://wiki.multitheftauto.com/wiki/OnClientWeaponFire
  12. Why don't you search a little bit better? I am sure there are a lot of Ammunition scripts on the community you can edit.
  13. Login as Admin and write: /debugscript 3 Also: Check this topic, it will show you all possible debug functions.
  14. Ah thx. Everything is set up now. After testing I noticed that when I used my browser it returns the correct hostname. But for mta it returned the 'Standaardgateway' address of my router. That is obvious because I was testing it on a local server. (except for the API of course) This fixed that for me while testing, but it wouldn't work at a default server because it retrieves the server ip/hostname instead. <?php $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo $hostname; ?>
  15. That is impossible, there is always one internet packet first and after all LUA can only process one piece of code at the same time. If LUA could execute multiple pieces of the code at the exact same time, this would be devastated when the two executions influence each other.
  16. So I after reading everything, I do have to do this: Add the website file to the server to detect the host of the player. (website server folder) Add the resource to the server. Grand the resource the fetchRemote function usage permission. Change the url to the correct one. Optional: Search for VPN hostnames and add those to the list. Am I missing something?
  17. IIYAMA

    table sort

    local myTable = { {103, 42, 66 }, {204, 50, 10 }, {820, 22, 32 } } local myTableNewFormat = { --[[ [103] = {103, 42, 66 }, -- shared/linked with myTable [204] = {204, 50, 10 }, [820] = {820, 22, 32 } ]] } for i=1,#myTable do myTableNewFormat[myTable[i][1]] = myTable[i] end As you know tables are objects and they can exist at multiple places at the same time. Which means that myTable and myTableNewFormat contains exactly the same data, but with different indexes.
  18. IIYAMA

    table sort

    lol, you are changing the table format of the copy. Then you can better use two linked tables, saves you a lot of performance.
  19. Hmm, it is not that much of a pain if it only takes one button / command to make a compiled copy which ends up in 1 folder. But indeed, it will takes some management work.
  20. Or follow this tutorial, if you want to keep versions and not editing lua files in order to compile resources.
  21. Only custom commands. (security reasons) https://wiki.multitheftauto.com/wiki/ExecuteCommandHandler
  22. At the same link: https://wiki.multitheftauto.com/wiki/AttachEffect Which contains this: local attachedEffects = {} -- Taken from https://wiki.multitheftauto.com/wiki/GetElementMatrix example function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end function attachEffect(effect, element, pos) attachedEffects[effect] = { effect = effect, element = element, pos = pos } addEventHandler("onClientElementDestroy", effect, function() attachedEffects[effect] = nil end) addEventHandler("onClientElementDestroy", element, function() attachedEffects[effect] = nil end) return true end addEventHandler("onClientPreRender", root, function() for fx, info in pairs(attachedEffects) do local x, y, z = getPositionFromElementOffset(info.element, info.pos.x, info.pos.y, info.pos.z) setElementPosition(fx, x, y, z) end end ) By Sbx320
  23. The code of the function. It is not a MTA function, but a custom one. https://wiki.multitheftauto.com/wiki/AttachEffect
  24. You first have to do some research if it accepts the vehicles you want to simulate. https://wiki.multitheftauto.com/wiki/OnClientVehicleCollision bodyPart: the bodypart that hit the other element (the body part on the documentation is not the same for all vehicles) collisionX/Y/Z: the position the collision took place (Afaik this is the offset > excluded the vehicle orientation) Both could be used to locate the vehicle part. And this could be used for the damage simulation: https://wiki.multitheftauto.com/wiki/SetVehiclePanelState https://wiki.multitheftauto.com/wiki/SetVehicleDoorState https://wiki.multitheftauto.com/wiki/SetVehicleWheelStates
×
×
  • Create New...