Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. try something like this: local mapRoot = resourceRoot -- temporary adding to resourceRoot addEventHandler("onResourceStart",resourceRoot, function () local resourceOfMap = export.mapmanager:getRunningGamemodeMap ( ) if resourceOfMap then mapRoot = getResourceRootElement(resourceOfMap) end end) addEventHandler( "onGamemodeMapStart", root, function (startedMap) mapRoot = getResourceRootElement(startedMap) end) function ramp ( thePlayer, commandName ) if ( thePlayer ) then local ramp = createObject ( 1634, 0, 0, 0, 0, 0, 0 ) if ramp then attachElements ( ramp, getPedOccupiedVehicle(thePlayer), 0, 1, 0, 0, 0, 180 ) setObjectScale ( ramp, 0.7) outputChatBox ( "Ramp Added", thePlayer ) if isElement(mapRoot) then local setToParent = setElementParent(ramp, mapRoot) if setToParent then -- debug -- outputDebugString("Set ramp parent successfully!") end end end end end addCommandHandler ( "ramp", ramp )
  2. IIYAMA

    Vehicle blow

    You can cancel the bullet explosion like this: addEventHandler("onClientExplosion",root, function (x,y,z,explosionType) if source == localPlayer and explosionType == 10 then local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getElementMode(vehicle) == 432 then cancelEvent() end end end) But how you want to check if it hits an object is up to you.
  3. and yes, you can sort by characters/words: outputChatBox(tostring("a" < "b")) -- true outputChatBox(tostring("b" < "a")) -- false
  4. local tablex = { [1] = {"900","WonderfulNick52"}, [2] = {"100","WonderfulNick52"}, [3] = {"1","WonderfulNick52"}, [4] = {"69","WonderfulNick52"} } table.sort(tablex, function(a,b) return a[1] < b[1] end) for i=1,#tablex do outputChatBox(tablex[i][1]) end That is because you are using strings, not numbers. 1 100 69 900 So sort it like this: table.sort(tablex, function(a,b) return tonumber(a[1]) < tonumber(b[1]) end)
  5. That is: "???" = "aim_weapon" You can find those names on: https://wiki.multitheftauto.com/wiki/Control_names
  6. local circleRotation = 21 addEventHandler("onClientRender",root, function () dxDrawImage(689, 280, 116, 115, "circlebar.png", circleRotation) end) bindKey("backspace","down", -- see next line > function (key,keyState) -- key = "backspace", keyState = "down"(if "both" it can be "down" or "up") circleRotation = (circleRotation+90)%360 -- % <<< 456%360 = 96 (removes a value till the rest value remains, which is lower than that ) end) Ik kan het ook op zijn Nederlands/Belgisch uitleggen, mocht je er niks van snappen.
  7. IIYAMA

    line move

    local myTable = {} -- Create an empty table. local amountOfItems = #myTable -- # < Will return the highest position in this table. -- When the table is empty it will be 0. -- When there is 1 item in it, it will be most likely 1, but not always when the array/table isn't clean. What is the array? local positionOfLastItem = amountOfItems -- This is most likely the position of the last item in the table. local dataThatIsInside = {345,57567,5777} -- x,y,z This is what you are going to save. local nextItemPosition = positionOfLastItem +1 -- Get the next position in the table, where you want to store your item. myTable[nextItemPosition] = dataThatIsInside -- Saving in the Table. The table will look like this at the end: (in the lua memory) myTable = { {345,57567,5777} } There are also table.insert and table.remove. But those have more functionality. You should first understand the array before you start using those.
  8. IIYAMA

    Heli blade ID

    It belongs to deathreason/weapon 50, which is the same as getting rammed by a car. See deathReasons. Use the event onClientPlayerHeliKilled like GTX said.
  9. This function returns somtimes NaN https://wiki.multitheftauto.com/wiki/Ge ... ldPosition in combination with https://wiki.multitheftauto.com/wiki/GetPedTargetEnd There is not much I can do about it Afaik. Also I get sometimes NaN values when I am playing around with vectors of my serverside bullet collision system. (checking the distance between 2 lines in 3D)
  10. tweak When there are 0 players the while loop will still be executed. A simple > if #thirdpart > 0 then < on line 4 would do the fix. Also count i = i+1 some where else...
  11. thx, I will try.
  12. What is the best way to detect a NaN value? I found this: (but it doesn't seems to work, I still get warnings in the rest of the code when I check it like that) function isnan(x) return x ~= x end
  13. Yet I think he should first do that. Because to prevent tables that overflow like you mentioned, is mostly by fixing error and warnings so incorrect data will not enter the systems. Error and warnings and fps Error and warnings is lagg that will not be visible by fps, unless it takes longer than the frame time. But players will feel the lagg even if the fps doesn't drop. Error and warnings give a longer frame time. When you have 60 fps and the lua code hasn't finished with in 16,666 ms the fps will drop. (1sec/60fps)
  14. Make sure there are 0% errors/warnings in your debugscript. Those are the ones that cause the most lagg in servers. I have sometimes 1 or 2 of those in my server caused by a NaN value, yet I can't prevent those very well. But other servers have 100 of those in 1 min, which is... (and will fill up your server logs)
  15. That is possible, when the mta functions are changed and using more memory when extra features are added. But I put my bets on the new/rewritten sync features, since those are the stuff that you have to multiply by the amount of players. Yet, I think mta 1.5 is great. Especially the new light feature, which I hope will also work on objects in the future.
  16. There is probably a moment when the player isn't in the vehicle. You should always check the nil's. And reduce the amount of executions of functions to the minimal where possible. Especially when rendering them. sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) -- Speed sx, sy, sz = getElementVelocity (playerVehicle) -- Speed
  17. Well, you want the minigun aiming to a location somewhere in mta. (pointX2,pointY2,pointZ2 ) You also have the location of the minigun. (which you can fill in on line 31) (pointX1,pointY1,pointZ1) When you get the direction vector from those 2 locations you can make a matrix(table). This matrix can be used on your minigun element: https://wiki.multitheftauto.com/wiki/SetElementMatrix How to find this vector? local pointX1,pointY1,pointZ1 local pointX2,pointY2,pointZ2 local vectorX,vectorY,vectorZ = pointX2-pointX1,pointY2-pointY1,pointZ2-pointZ1 I am not a pro at matrix and vectors, so it is kinda hard to explain it to you.
  18. This piece of code will give you the matrix of 1 point which has a direction vector. local rx, ry, rz = 0,0,0 local vectorX,vectorY,vectorZ = -- fill in... (the vector) local rz = -math.deg( math.atan2(vectorX,vectorY ) ) local rx = math.atan2(vectorZ,math.sqrt(math.pow(vectorY,2) + math.pow(vectorX,2)))*(180/math.pi) local rx,ry,rz = math.rad(rx), math.rad(ry),math.rad(rz) local matrix = {} matrix[1] = {} matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry) matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry) matrix[1][3] = -math.cos(rx)*math.sin(ry) matrix[1][4] = 1 matrix[2] = {} matrix[2][1] = -math.cos(rx)*math.sin(rz) matrix[2][2] = math.cos(rz)*math.cos(rx) matrix[2][3] = math.sin(rx) matrix[2][4] = 1 matrix[3] = {} matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx) matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx) matrix[3][3] = math.cos(rx)*math.cos(ry) matrix[3][4] = 1 matrix[4] = {} matrix[4][1], matrix[4][2], matrix[4][3] = -- fill in... (position) matrix[4][4] = 1
  19. IIYAMA

    gun tower

    yup, https://wiki.multitheftauto.com/wiki/Se ... etPosition But it is probably not easy.
  20. np.
  21. Remove that: if use == 0 then < it is from the old code (line 31 and it's "end" on line 56)
  22. IIYAMA

    Anti teamkill

    There is no need to cancel anything. 1: trigger directly after onClientExplosion event. (no looping through the vehicles because that is what you are going to do at serverside) 2: Loop through the vehicles at serverside and check if the owners are in the same team. It is just combining and adjusting those scripts, no big deal.
  23. It seems you are spawning players when they are still alive. I now added the event onPlayerSpawn too. local vipItemsSetLimiter = {} function useAgain() if vipItemsSetLimiter[source] then -- check vipItemsSetLimiter[source] = nil -- remove end end addEventHandler("onPlayerWasted", root , useAgain) -- added -- addEventHandler("onPlayerSpawn",root, function () if vipItemsSetLimiter[source] then -- check vipItemsSetLimiter[source] = nil -- remove end end) ------------- -- clean up -- addEventHandler("onPlayerQuit",root, function () if vipItemsSetLimiter[source] then -- check vipItemsSetLimiter[source] = nil -- remove/clean up end end) -------------- function giveVipItems(thePlayer) if not vipItemsSetLimiter[thePlayer] then -- check if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("VIP")) then if use == 0 then setElementData(thePlayer, "Map", 1) setElementData(thePlayer, "GPS", 1) setElementData(thePlayer, "Box of Matches", 1) setElementData(thePlayer, "Toolbox", 1) setElementData(thePlayer, "Watch", 1) setElementData(thePlayer, "Night Vision Goggles", 1) setElementData(thePlayer, "Infrared Goggles", 1) setElementData(thePlayer, "M4 Mag", 150) setElementData(thePlayer, "M4", 1) setElementData(thePlayer, "CZ 550 Mag", 25) setElementData(thePlayer, "CZ 550", 1) setElementData(thePlayer, "Medic Kit", 1) setElementData(thePlayer, "Morphine", 1) setElementData(thePlayer, "Painkiller", 2) setElementData(thePlayer, "CZ 550", 1) setElementData(thePlayer, "CZ 550 Mag", 30) setElementData(thePlayer, "Milk", 2) setElementData(thePlayer, "Camouflage Clothing", 1) setElementData(thePlayer, "Pizza", 2) setElementData(thePlayer, "Infrared Goggles", 1) setElementData(thePlayer, "Night Vision Goggles", 1) setElementData(thePlayer, "MAX_Slots" , 26 ) outputChatBox("VIP: Items set !", thePlayer, 50, 255, 0, false) vipItemsSetLimiter[thePlayer] = true -- store end else outputChatBox("VIP: Only VIP users can use this command!", thePlayer, 255, 0, 0, false) end else outputChatBox("VIP: You can only use this command ones in a lifetime.", thePlayer, 255, 0, 0, false) end end addCommandHandler("vipitems", giveVipItems , thePlayer)
  24. IIYAMA

    Anti teamkill

    Then you have to edit that one...
  25. You can circa see how many they use when you type: /shownetstat When I compared those two I got this result. Which one uses more bandwidth: Triggering uses much more bandwidth than elementdata when it is just you and the server. But when there are more players in the server, you have to multiply the elementdata with the amount of players. So for example (the elementdata will be set serverside): elementdata uses 1 kb, 1 kb X 8 players = using 8 kb total. If you have a server with 1000 players in it(like sometimes CIT), you will be using 1000kb. Which one is faster? Triggering is much faster than using elementdata, you can probably compare the speed of elementdata with triggerLatentClientEvent, but I do not know the exact speed of both.
×
×
  • Create New...