Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. IIYAMA

    Moon??

    It might also be one of the shader resources on your server, which overwrites the moon texture.
  2. local findRotation = function ( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end local findPitch = function (camerax,cameray,cameraz,pointx,pointy,pointz) local dX=camerax-pointx local dY=cameraz-pointz local dZ=cameray-pointy local pitch=math.atan2(dY,math.sqrt(math.pow(dZ,2) + math.pow(dX,2))); return pitch end local targetX, targetY, targetZ = 0, 0, 0 local elementX, elementY, elementZ = getElementPosition(projectile) local rotZ = findRotation(targetX, targetY, elementX, elementY) + 180 local pitch = findPitch(targetX, targetY, targetZ, elementX, elementY, elementZ) local rotX = pitch*(180/math.pi) These are the global math functions you need, which I ripped out of my own script. You probably need some adjustments to them in order to make it work for your script. The variable names do speak for them self, so good luck with it!
  3. The easiest way would be creating an object on the map(server-side strongly recommended because of the synchronization). And let a heat seeking rocket fly to it.
  4. @CleyzChan How about you write the things in JavaScript, then I will explain you how to write those in Lua?
  5. If you know JavaScript, then lua is just a little kid. Start running some basic code at a demo for example: https://www.lua.org/demo.html JavaScript The syntax is different, but the rules are almost the same. The most confusing part in lua compared to JS might be the fact that: `let` variables which are written down with the `local` key word. Variables without declaration are available in every script (within the same resource). (also known as globals) `const` and `var` variable types do not exist in lua. There are document code blocks. (which in Javascript you need iffy's to do this.) Arrays and objects do not exist in lua. But tables can be used as an array, object and both at the same time. Tables used as arrays start at the index 1 instead of 0.
  6. You might attach a function as string on to the root and load per resource the string? Resource 1. setElementData(root, "allFunctions", "function newFunction() end", false) triggerEvent("allFunctions", root) Resource 2, 3, 4, 5, etc. addEvent("allFunctions", false) local function loadAllFunctions () local allFunctions = getElementData(root, "allFunctions") if allFunctions then loadstring(allFunctions)() removeEventHandler("allFunctions", root, loadAllFunctions) end end addEventHandler("onResourceStart", resourceRoot, function () addEventHandler("allFunctions", root, loadAllFunctions) loadAllFunctions() end) I do not recommend it muhahahah but maybe it works for you lol. really bad practice
  7. IIYAMA

    topbarchat

    I do not understand the decisions you made in your code either, especially if you do not write comments. So I do recommend you to rewrite your code or at least write some comments in it. AFAIK you can use the same Y start point of the text for your rectangle. How about you give it a try? (sY / 900) * (dxMessagesY[index] * 2) + 1
  8. A ped isn't a player or a vehicle(with syncer). So no they are not synced in case of a ped. And this is about: Optional Arguments NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments. posX, posY, posZ: float starting coordinates for the projectile. They are coordinates of creator by default. force: float representing the starting force for throwable projectiles. target: element target used for heat seeking rockets. rotX, rotY, rotZ: float starting rotation for the projectile. velX, velY, velZ: float starting velocity for the projectile. model: Integer representing the projectile's model, uses default model for weaponType if not specified. https://wiki.multitheftauto.com/wiki/CreateProjectile With other words, if you change projectiles in to houses(objects), they will not look like houses for the remote-players*. *(other players than the creator of the projectile) yea yea, I know, you can also make cows fly as in age of empire 1. /Jack be Nimble
  9. IIYAMA

    topbarchat

    There is no need to do complex stuff. It can be very simple if you spend some time on finding a logic solution. Untested code. local blockSize = (sY / 900) * 10 Define the block size local index = #dxMessages + 1 dxMessages[index] = {message = "hi"} -- set position data dxMessages[index].positionY = blockSize * (index - 1) Define it's position if item is added last local index = 1 -- move all items 1 down for i=1, #dxMessages do dxMessages[i].positionY = dxMessages[i].positionY + blockSize end -- insert at the start of the table and push all other items to the next index. table.insert(dxMessages, index, {message = "hi"}) -- set position data dxMessages[index].positionY = blockSize Define it's position(s) if item is added first. While rendering: for index = 1, #dxMessages do local messageData = dxMessages[index] end --reverse for index = #dxMessages, 1, -1 do local messageData = dxMessages[index] end Just use a normal loop. So you have full control over it. And now you can rock! Box/text from bottom to top. Please edit to your layout. dxDrawRectangle(sX / 4 + 1, sX - blockSize, (sX / 4) * 3 + 1, 0, tocolor(0, 0, 0, 93), false) Loop local startX, startY = sX / 4 + 1, sY - messageData.positionY - blockSize local endX, endY = (sX / 4) * 3 + 1, startY - blockSize * #dxMessages dxDrawText(messageData.message, startX, startY, endX, endY, tocolor(0, 0, 0, 255), (sX / 1440) * 1.1, "default-bold", "center", "center", false, true, false) Something like that...
  10. It is indeed a big problem. Optional. You can tell all players that are closeby that a projectile is created. (Which you can attach to an element serverside to get full control. ) When it blows up at one of the clients, you can tell all other clients to move their projectile to the right position and detonate it. It is not 100/100, but it can be considered as a kind of synchronization/validation.
  11. IIYAMA

    topbarchat

    Where is your rectangle?
  12. @LeroY https://wiki.multitheftauto.com/wiki/GetElementBoundingBox Bounding box. Please read the information carefully.
  13. IIYAMA

    XML Join

    @anufis_ok Check if a player is logged-in with: https://wiki.multitheftauto.com/wiki/IsGuestAccount
  14. The maps that are exported from the map editor do have a script to make this possible. But of course without understanding lua, you will not be able to achieve this if the end format isn't the same.
  15. Maybe it is related to the protocol. (Http/https) Or try to define the head, as they both might try to request different formats. That is all I can think of.
  16. When using the variables like playerName inside of the loop, you will have to redeclare the as a local variable in order to prevent them from being overwritten. (The variable name can be the same) local playerName = "iiyama" do -- in your case your loop local playerName = playerName .. "-alex" -- modifi iprint(playerName) -- iiyama-alex end iprint(playerName) -- iiyama
  17. yea you can do that. Or just using 1 table. And start looping at a different index. for i=math.max(#chatbox - 13, 1), #chatbox do local v = chatbox[i] end (not sure if you have to use: - 12, - 13 or - 14 to accomplish this)
  18. elseif (i > 13) then table.remove(chatbox, 1)-- delete the first item, and move all higher items one down. end I thought you wanted to insert items at the beginning.
  19. You are filling your table with infinity items. elseif (i > 13) then local value = chatbox[i] -- get the value chatbox[i] = nil -- delete the item table.insert(chatbox, 1, value) -- re-insert end
  20. table.insert(chatbox, 1, newItem) This is how you can insert items in to the first index and move the rest of the items up. (Couldn't merge anymore with previous post)
  21. chatbox[#chatbox + 1] = newItem #chatbox returns the table lengte. See table.insert for inserting on to the first item.
  22. IIYAMA

    Anti-Cheat Corner

    @ccw In case of a competitive game mode. Which special detections would you recommend to turn on? And would enable #31 #32 make it impossible for some players to play the game? This looks like it is blocking of people with macro/binding tools. Not sure if it also would block macro's created by hardware. (like the logitech g502)
  23. function replacepaintjob() local paintjob1 = engineLoadTXD ( "elegy1.txd" ) engineImportTXD (paintjob1, 562) local paintjob2 = engineLoadTXD ( "elegy2.txd" ) engineImportTXD (paintjob2, 562) local paintjob3 = engineLoadTXD ( "elegy3.txd" ) engineImportTXD (paintjob3, 562) end I haven't replaced paintjobs myself, but this will solve some syntax errors in your code. And make sure that all 3 files are written down in the meta.xml: https://wiki.multitheftauto.com/wiki/Meta.xml <file src="elegy1.txd" /> <file src="elegy2.txd" /> <file src="elegy3.txd" />
  24. 1. Not error proof: if getElementType ( attacker ) == "ped" then 2. More error proof: if attacker and getElementType ( attacker ) == "ped" then 3. 100/100 error proof if isElement(attacker) and getElementType ( attacker ) == "ped" then But the function isElement isn't always needed, because sometimes MTA functions/events give you either an element back or false/nil back. Which means I would rather pick option 2, for the optimization of my code. In some cases while using variables/elementdata to store data for later, only option 3 will work. Yet sometimes you do not want to check for the element type, if you know what you have stored. So in the end, lets strip it to the basic: 1. Not error proof: --nothing 2. More error proof: if element then 3. 100/100 error proof if isElement(element) then
  25. If that is the case, then start with asking permission first. And if they do not reply, then you do not have permission to: View / edit / etc. their code And yes, it is about respect when you do something without the owner their permission.
×
×
  • Create New...