Jump to content

kieran

Members
  • Posts

    367
  • Joined

  • Last visited

Everything posted by kieran

  1. Thanks @Mr.Loki, one question though... why do you pass dt?
  2. @Mr.Loki Thanks, but I want it to rotate clockwise, not spin on the z axis...
  3. Hey, so I know how to make a 3D image in the GTA world, but I want to animate it to turn like a gif, I don't know any way of doing this though... Is there any suggestions/solutions to how I can move it when the client renders? Here is code to create the image size = 3 local img = dxCreateTexture("circle.png") --The image function createIMG() -- x,y,z, targetx,targety,targetz,texture,width,color,lookx,looky,lookz x,y,z = -2329.3, -1605.6, 483.2 --Coordinates image = dxDrawMaterialLine3D (x, y, z, x+size, y, z+size/2,img, size, tocolor(255,255,255,255), x, y+10, z) --draw the image --How would I rotate the image? end addEventHandler("onClientRender", root, createIMG) The only way I could think of is making the image an element somehow and then rotating it... But I don't know how I'd do that, thanks for any advice/help.
  4. Creates the image, but my second xyz for face toward won't let me rotate the image.... What am I doing wrong? local white = tocolor(255,255,255,255) function dxDrawImage3D(x,y,z,w,h,m,c,r,...) local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...) end local the_image = dxCreateTexture("image.png") function create_image() dxDrawImage3D(-2329.5, -1610, 485, 5, 5, the_image, tocolor(255,255,255,255), 1, -2330, -1633, 483 ) end addEventHandler("onClientRender", root, create_image)
  5. What do you mean? I am using the code from wiki, but it keeps returning the same debug, so I think it has trouble loading the image, tried 2 images...
  6. I am wanting to create a 3D image, but I am struggling to even get the image in the game. Here is the code, and error. Client side script local the_image = dxCreateTexture("image.png") addEventHandler("onClientRender", root, function() dxDrawImage3D(-2327, -1620, 483, 20, 20, the_image, tocolor(255,255,255,255)) end ) meta.xml <meta> <info author="kieran" type="script" name="3D_Images" /> <min_mta_version client="1.5.5" server="1.5.5" /> <script src="image.lua" type="client" /> <file src="image.png" /> </meta> Debug script 3: attempt to call global 'dxDrawImage3D' (a nil value) Any help would be appreciated, thanks.
  7. I didn't even notice that... Thanks bud
  8. I'm trying to make a really simple settings panel, check boxes are easy, but I have a problem setting the clients weather when they click the button, it shows the number in chat but won't set the weather, even if I use tonumber.... The idea is you type a number in edit box, click the button, it sets the weather. local screenW, screenH = guiGetScreenSize() function GUI() if ( window ) then if ( guiGetVisible( window )) then showCursor( false ) toggleAllControls(true) guiSetVisible( window, false ) else guiSetInputEnabled(false) showCursor(true) toggleAllControls(false) guiSetVisible( window, true ) end else window = guiCreateWindow((screenW - 275) / 2, (screenH - 203) / 2, 275, 203, "Settings", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetInputEnabled(false) showCursor(true) toggleAllControls(false) blur = guiCreateCheckBox(10, 99, 59, 21, "Blur", false, false, window) clouds = guiCreateCheckBox(69, 99, 59, 21, "Clouds", false, false, window) weather_lbl = guiCreateLabel(138, 102, 60, 15, "Weather: ", false, window) weather_edit = guiCreateEdit(190, 105, 44, 15, "", false, window) --edit box weather_button = guiCreateButton(242, 103, 23, 20, ">>", false, window) --button addEventHandler("onClientGUIClick",weather_button,setWeather) end end bindKey("F6", "down", GUI) function setWeather(button,state) --Function to change weather if(button == "left" and state == "up") then if (source == weather_button) then weather = guiGetText(weather_edit) --Getting the text setWeather(tonumber(weather)) --Doesn't set outputChatBox(""..weather) --Outputs the text so I can check --Checking weather that's set, returns same value every time local weatherID = getWeather() outputChatBox ( "The current weather ID is " .. weatherID ) end end end Thanks for any help can't see where I went wrong.
  9. Yes but I am beginning to learn 3 alongside it, so it just gets confusing
  10. ^^^Never mind that I forgot to start the script. Thanks again
  11. Thanks @IIYAMA, this helps, I need to learn C# and Python, so this is why I find lua so confusing at times, especially on MTA. Some things seem a little, backwards. Also I noticed a big problem, if I die miles out at sea off the map, I can't re-spawn.
  12. Thanks came up with the code below and works great! function getDistance(thePlayer) -- get the player position local px,py,pz = getElementPosition( thePlayer ) --Player location -- prepare 2 variables, but do not give them a value yet. local closestDistance local closestPoint -- loop through the tables for i=1,#hosp_loc do local hx, hy, hz = hosp_loc[i][1], hosp_loc[i][2], hosp_loc[i][3] --Hospital locations --if site:sub(0, 7) ~= "http://" then local distance = getDistanceBetweenPoints3D (hx, hy, hz, px, py, pz) --Get the distance between player and hospitals if not closestDistance or distance < closestDistance then -- If the closestDistance is nil/(false) OR the distance is smaller than the closestDistance. closestDistance = distance -- save the distance in closestDistance, which is located outside of the loop. closestPoint = hosp_loc[i] -- save the point in closestPoint, which is located outside of the loop. end end x = (inspect(closestPoint[1])) -- debug the closestPoint variable, should be a table! y = (inspect(closestPoint[2])) z = (inspect(closestPoint[3])) r = (inspect(closestPoint[4])) spawn = x..", "..y..", "..z..", "..r outputChatBox(spawn, thePlayer, 255, 170, 85) end addCommandHandler( "loc", getDistance, false )
  13. @IIYAMA Thanks, but um, final question on this... How can I get it to show only the numbers? Sorry... never used inspect before, and I can't think of a way to get length or use sub/gsub
  14. Thanks @IIYAMA, but do you know of a way to get the x y z position though? So instead of output being distance, it would be the closest 3D point x,y,z in table? instead of meters to point... Also is there any other way of getting minimum number? I can only use one value it will do it for all locations, I just want the closest locations x y z to be returned so I can use it on spawn...
  15. I want to make a script that will get distance between player and locations in a table, I have done this, but... I want to get the minimum distance and targets x, y, z. Basically, get distance between player and hospital, get the smallest distance only, then get the x, y, z of the targets distance from the table and output the x,y,z, so if I'm closest to all saints, it outputs those coordinates only. hosp_loc = { --Table of hospitals -- x, y, z, rot { 1173, -1323, 15, 270}, -- All Saints { 2038, -1411, 17, 130}, --Jefferson { 1242, 327, 19, 340}, -- Red County { 1609, 1816, 12, 360}, -- Las Venturas { -2655, 635, 14, 180}, -- San Fierro { -2200, -2311, 30, 320} -- Angel Pine } function getDistance(thePlayer) for i=1,#hosp_loc do local hx,hy,hz = hosp_loc[i][1],hosp_loc[i][2],hosp_loc[i][3] --Hospital locations local px,py,pz = getElementPosition( thePlayer ) --Player location distance = getDistanceBetweenPoints3D (hx, hy, hz, px, py, pz) --Get the distance between player and hospitals output = math.min(distance) --Trying to get the minimum distance of one hospital outputChatBox(""..output, thePlayer, 255, 170, 85) --Ouput the x,y,z of that specific hospital to the chat end end addCommandHandler( "loc", getDistance, false ) --To get the distance Anyone know how to do this? was one of the first things I tried to script and trying to come back to do it now I know a little more (just not enough to do it). Thanks.
  16. Believe it or not it's exactly what I wanted the idea is adding the /atm command for a player to find the closest ATM, not to set the blip visible when the player hits the marker.... Here's the code, trying to educate myself a little on distance so I can make a proper hospital script and other stuff needed on most servers for the community (once I find out why I can't upload images to my resources). local destroyTimer function blips() if isTimer (destroyTimer) then --If timer is active return --Do nothing end local blipGroupElement = createElement("blipGroupElement") --Create an element for the blip for i=1,#ATM_Locations do --For all the locations in the table --Get the ATM xyz local x,y,z = ATM_Locations[i][1],ATM_Locations[i][2],ATM_Locations[i][3]--We will get there x y z coordinates --Get the Players xyz local lx,ly,lz = getElementPosition( localPlayer ) --Get the distance between the ATM's and the Player distance = getDistanceBetweenPoints3D (x, y, z, lx, ly, lz) --If the distance is under 500 then create a blip for each location in the table if (distance) <= tonumber(500) then blip = createBlip ( x, y, z, 52, 1, 0, 0, 0, 255, -32767) setElementParent(blip, blipGroupElement) --Set the parent of the blip to the previously created element destroyTimer = setTimer( destroyBlips, 10000, 1, blipGroupElement)--And set a 10 second timer to destroy the blips end end end addCommandHandler( "ATM", blips, false )--Command function destroyBlips(blipGroupElement) --Honestly a little puzzled here, guess you carry this here so it can find all elements if isElement(blipGroupElement) then --If it's there destroyElement(blipGroupElement) --Destroy it. end end --See? It is simple! I just got a bit puzzled as I have never done a script like this, it's usually simple stuff. ^.^
  17. I tried setting visible distance, all blips are created on map, and visible distance works on HUD, but not on the map, every blip still shows on map... And what do you mean by add blips? I tried this and it failed. local destroyTimer function blips() if isTimer (destroyTimer) then return end local blipGroupElement = createElement("blipGroupElement") for i=1,#ATM_Locations do local x,y,z = ATM_Locations[i][1],ATM_Locations[i][2],ATM_Locations[i][3] blip = createBlip ( x, y, z, 52, 1, 0, 0, 0, 255, 0, 500) setElementParent(blip, blipGroupElement) destroyTimer = setTimer( destroyBlips, 10000, 1) end end addCommandHandler( "ATM", blips, false ) function destroyBlips() if isElement(blipGroupElement) then destroyElement(blipGroupElement) end end
  18. So I have been struggling with one thing in particular lately, I made a script for am ATM system, and added a command to show blips for all the ATM's, I have used getDistanceBetweenPoints3D and it works, showing the nearest blips, the only problem is they will not all go away when I use my function to destroy them, only a small amount go away after the timer is completed. local ATM_Locations = { --Location table, numbers are commented so I know what goes where {1505.16626, -1750.68909, 13.54688},--1 <-This one goes away after 10 seconds as well as 3 others close to it. {1690.0927734375, -2334.8369140625, 13.546875},--2 {1951.19543, -2175.53784, 13.55421},--3 {2041.50390625, -1430.728515625, 17.1640625},--4 <-Yet this one doesn't or any others north of it. {1878.06372, 2073.94067, 11.06250},--5 {2280.76465, 2431.10596, 10.82031},--6 {2020.86316, 1016.50653, 10.82031},--7 {-1210.31104, 1834.64917, 41.92969},--8 {174.82074, 1175.05469, 14.75781},--9 {1380.58093, 260.50055, 19.56693},--10 {1238.48145, 327.90039, 19.75551},--11 {1626.68469, 1815.06384, 10.82031}--12 } local Blips = {}--My table to store the blips local destroyTimer --So I can get the timer function blips() if isTimer (destroyTimer) then --If my timer exists I stop the function here return end for i=1,#ATM_Locations do --For all the locations in the table at the top of the script local x,y,z = ATM_Locations[i][1],ATM_Locations[i][2],ATM_Locations[i][3]--Get the x y z coordinates of ATM_Locations table local lx,ly,lz = getElementPosition( localPlayer ) --Get the Players x y z position distance = getDistanceBetweenPoints3D (x, y, z, lx, ly, lz) --Get the distance between the ATM's and the Player if (distance) <= tonumber(500) then --If the distance is under 500 then create a blip Blips[i] = createBlip ( x, y, z, 52, 1) --I create the blips destroyTimer = setTimer( destroyBlips, 10000, 1)--And set a 10 second timer to destroy the blips end end end addCommandHandler( "ATM", blips, false )--This is the command to show blips function destroyBlips() for i=1, #Blips do --For the blips in the table local blip = Blips[i] --Get the blips if isElement(blip) then --If the blip is in the table destroyElement(blip) --Destroy it. end end end So if you try it at LS airport you'll get 4 blips that will go away, but if it's anywhere else and distance is still 500, then the blips will stay anyone see where I went wrong? it's as if it only gets a select amount from the Blips table then stops. Thanks for any help, been struggling and don't know why it's doing this, all blips go after 10 seconds when it doesn't use distance...
  19. kieran

    [Help] Team

    Okay, instead of using that for your gate function, maybe try this... Oh and make use of using "not" in your if's, it can come in handy . local gate = createObject(2938, 1534.9000244141, -1451.3000488281, 15, 0, 0, 90)--The gate local marker = createMarker(1534.9000244141, -1451.3000488281,13, "cylinder", 10, 255, 255, 255, 100)--The marker IronJobBlip = createBlipAttachedTo ( marker, 56 ) is_gate_open = no --So we can check if gate is open. function moveGate(thePlayer, matchingDimension) if isElement(thePlayer) and getElementType(thePlayer) == "player" and matchingDimension then --If it's a player in the same dimension local checkTeam = getTeamFromName("Police") --We will get the police team if ( checkTeam ) then local playerTeam = getPlayerTeam(thePlayer) --We will then get the players team if ( playerTeam == checkTeam ) then --If the players team is Police outputChatBox ("You may not enter as police", thePlayer, 255,0,0 ) --Tell him return --And stop our script here end if not isPedInVehicle ( thePlayer ) then --if our player is not in a vehicle outputChatBox ("You need to be in vehicle, to enter.", thePlayer, 255,0,0 )--We will tell him if is_gate_open == no then --If our gate is not open moveObject(gate, 2000, 1534.9000244141, -1451.3000488281, 17, 0, -90, 0) --Move the gate is_gate_open = yes --Update our is_gate_open end end end end end addEventHandler("onMarkerHit", marker, moveGate) function GateClose ( thePlayer, matchingDimension ) if isElement(thePlayer) and getElementType(thePlayer) == "player" and matchingDimension then local detection = isElementWithinMarker ( thePlayer, marker ) --If a player is inside the marker detection = detection and getElementDimension( thePlayer ) == getElementDimension( gate ) --I honestly lost words and forgot how to explain this if is_gate_open == yes and not detection then --If gate is open and player isn't in the marker moveObject(gate, 2000, 1534.9000244141, -1451.3000488281, 15, 0, 90, 0) --Move it back is_gate_open = no --Our gate is no longer open end end end addEventHandler ( "onMarkerLeave", marker, GateClose ) Second function needs a little tweaking, maybe you'll want to consider using col shapes, here is an example of an old script I have using col shapes. This should help you, got any other questions feel free to send me a message! But if I can't help, there are smarter people on forums... Also you might want to look at some of the stuff in above 2 code sections on the wiki, then you should just about be set with moving objects when a player hits them
  20. kieran

    [Help] Team

    Untested function team(hitElement, matchingDimension) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then local checkTeam = getTeamFromName("Police") if ( checkTeam ) then local playerTeam = getPlayerTeam(hitElement) if ( playerTeam == checkTeam ) then outputChatBox ("text.", source, 255,0,0 ) cancelEvent() end end end end end addEventHandler("onMarkerHit", marker, team) Might work, might not, use debugscript 3 and tell me what happens, just quickly took it out an old script I had. By the way, source gets the source element, so when a player hits a marker, the player is the source, so you don't need to define source in your function.
  21. thanks @quindo, was thinking it would get the button instead of the image haha, makes sense now, if you want to get the button, you gotta declare it if you want to get the element, get the source.
  22. Hello, I know how to add, and get elements from a table, but I have made a GUI for a job script, when I click it triggers a function, and I want the clicked image to be destroyed once I click it and the function is triggered, code is below. Problem on line 20, debugscript 3 shows: Bad argument @ 'destoyElement' [Expected element at argument 1, got string 'table: 534E2AD0] So obviously it got the table as a string, but how can I get the clicked image from the table? Thanks for the help once GUI is neat and working going to put script on community
  23. It's to make links work on google search, I have the code to request blocked domains, and it works when I type the URL's in manually to my edit box, but I am trying to get the blocked URL when I am accessing a website with google search as it will not load when I click the link, but all elements in the browser, tabs, text boxes, even going to the next page of the search works, it's just accessing the pages I have a problem with, for example, you go to google, type mtasa.com in the search box, you can access this forum that way, I can not access it unless I type the exact URL.
  24. @idarrr worked for one URL, not any others also it keeps sending a warning basically telling me it got the URL when I click, not the button... I can't find a way to get the button, the explanation on the wiki isn't that clear... Don't know what I am doing wrong...
×
×
  • Create New...