Jump to content

Lpsd

Administrators
  • Posts

    319
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Lpsd

  1. I guess I thought, that because the spawnpoint was being treated like an object through "getElementsByType", checking whether the element was an object wouldn't have any effect. and yeah I guess that's the only way to do it in this situation. Much appreciated
  2. Sounds like it should work, but doesn't. Maybe my logic is wrong here: local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do if getElementType( objData ) == "spawnpoint" then --donothing else local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) end end
  3. Would have edited my other post to include this, but seems the option isn't available. I have the following code: function objSelect ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) if clickedElement and getElementType( clickedElement ) == "spawnpoint" then outputChatBox("--element clicked") end end addEventHandler ( "onClientClick", getRootElement( ), objSelect) What this is supposed to do, basically, is output "--element clicked" in the chatbox whenever you click an element with the type of "spawnpoint" This works great when I change the second line to say "object" instead of "spawnpoint", however with spawnpoint it doesn't work. Is this just a problem in MTA? or is something wrong with the code? As far as I know spawnpoints still have collisions, so therefore can be detected by clicking on them with the cursor.
  4. I'm currently trying to put both objects, and spawnpoints, both in separate lists. Here's what I have so far: local curSpawns = getElementsByType ( "spawnpoint" ) for i,spawnData in ipairs(curSpawns) do local spawn_name = getElementData( spawnData, "id") local row = guiGridListAddRow( spawnList ) guiGridListSetItemText( spawnList, row, spawnColumn, i .. ": " .. spawn_name, false, true ) end local curObj = getElementsByType ( "object" ) for i,objData in ipairs(curObj) do local obj_name = getElementData( objData, "id") local row = guiGridListAddRow( objList ) guiGridListSetItemText( objList, row, objColumn, i .. ": " .. obj_name, false, true ) end However, the spawnpoints are appearing inside the objects list. Here's the result: Are spawnpoints handled as an 'object' type as well as 'spawnpoint'?
  5. Quick question. When I'm already at the top-level (gui isn't contained in anything else), what am I positioning relatively to? The screen itself? edit: nevermind, found a whole topic explaining absolute vs relative positioning
  6. Works fine, thanks. So it was just the relative positioning that messed it up? & I'm guessing guiSetVisible isn't needed either.
  7. Hi, I'm having a slight problem with "guiCreateWindow", it just doesn't appear at all. Here's my client.lua: x, y = guiGetScreenSize () function createGUI () local guiWidth, guiHeight = 500, 300 local centerX, centerY = (x / 2) - (guiWidth / 2), (y / 2) - (guiHeight / 2) myWindow = guiCreateWindow(centerX, centerY, 500, 300, "Information", true) guiSetVisible(myWindow, true) end addEventHandler( "onClientResourceStart", getRootElement( ), createGUI) and here's my meta.xml <meta> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> </meta> I can't see a single reason for it not to work, checked in debug and no errors there. I think I'm not fully understanding how the different types of positioning work. Earlier on I used the "centerX, centerY" variables on a "dxDrawImage" element, to position it in the exact center of the screen, and it worked fine. The Wiki explains about the position arguments of the "dxDrawImage" function: posX: the absolute X coordinate of the top left corner of the image posY: the absolute Y coordinate of the top left corner of the image However the explanation for the arguments of positioning on the "guiCreateWindow" function are slightly different: x: A float of the 2D x position of the GUI window on a player's screen. This is affected by the relative argument. y: A float of the 2D y position of the GUI window on a player's screen. This is affected by the relative argument. Maybe that's where I'm going wrong. Thanks for reading, hope I've provided enough info.
×
×
  • Create New...