Jump to content

ShayF2

Members
  • Posts

    230
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ShayF2

  1. Elements with different interiors will be invisible to each other, this is because of GTA:SA using the same dimension for use of houses, shops, and other things of the sorts so that world objects don't interfere with each other. It's best if you want these elements to see each other to use the same interior. Dimensions work a little differently. When elements have different dimensions, they have little to no interaction what so ever. This is helpful when separating a group of elements to give them their own world. It works great with servers that want to have multiple game modes and or sessions/worlds. I hope that my explanation has helped you, have a nice day.
  2. rx,ry,rz are not declared. run it all serverside and use local rx,ry,rz = getElementRotation(player) for those values.
  3. Aspect ratio wont matter, this math is based off the users screen.
  4. This is a simple function designed to take absolute values, like 400,600,200,150 and such, and turn them into relative values. This is useful when creating gui and dx elements to match them up with every screen. That way different resolutions can resize and reposition accordingly. MTA has its own method of calculating relative values, however it does not reposition, it only resizes. So here you go. Be sure to change 1360,780 to your own resolution. And here is an example of using this: local x,y,w,h = relative(500,500,100,200); dxDrawRectangle(x,y,w,h,tocolor(255,255,255,255)) local sx,sy = guiGetScreenSize() local sw,sh = 1360,780 function relative(x,y,w,h) local x,y,w,h = x/sx*sw,y/sy*sh,w/sx*sw,h/sy*sh return x,y,w,h end I hope this is of some help to you.
  5. name the resource something else, as well as try using relative values. This may help you when getting relative values, just take the values that you have already to draw the element and replace the resolution with your own resolution. example is this, local x1,y1,w1,h1 = relative(200,200,50,50) local sx,sy = guiGetScreenSize() local sw,sh = 1360,780-- if u change the values in the relative() funcs, be sure to set this to your res and change the other ones as well. function relative(x,y,w,h) -- this allows for perfect relative values, mta only sizes them to your res so it would be funky for other resolutions. local x,y,w,h = x/sx*sw,y/sy*sh,w/sx*sw,h/sy*sh return x,y,w,h end Good Luck.
  6. Edit the photo, making it round with transparent background.
  7. local sx,sy = guiGetScreenSize() local sw,sh = 1360,780-- if u change the values in the relative() funcs, be sure to set this to your res and change the other ones as well. function relative(x,y,w,h) -- this allows for perfect relative values, mta only sizes them to your res so it would be funky for other resolutions. x = x/sx*sw y = y/sy*sh w = w/sx*sw h = h/sy*sh return x,y,w,h end -- then input absolute values into the relative function like so local x,y,w,h = relative(300,400,100,200)-- whatever u want, x,y,w,h, will be relative values for every res, just be sure to change the res above to your res.
  8. -- Made by Jonty / First Lua code for Tables. local sx,sy = guiGetScreenSize() local sw,sh = 1360,780-- if u change the values in the relative() funcs, be sure to set this to your res and change the other ones as well. function relative(x,y,w,h) -- this allows for perfect relative values, mta only sizes them to your res so it would be funky for other resolutions. x = x/sx*sw y = y/sy*sh w = w/sx*sw h = h/sy*sh return x,y,w,h end data = { {'CJ','Infernus',0,411} } local x1,y1,w1,h1 = relative(204,253,952,261) spawnScreenMenu = guiCreateWindow(x1,y1,w1,h1,'Find the IDs you want!',false) guiWindowSetMovable(spawnScreenMenu,false) guiWindowSetSizable(spawnScreenMenu,false) local x2,y2,w2,h2 = relative(9,26,933,195) spawnScreenGridList = guiCreateGridList(x2,y2,w2,h2,false,spawnScreenMenu) guiGridListAddColumn(spawnScreenGridList,'Skins',0.5) guiGridListAddColumn(spawnScreenGridList,'Vehicle',0.48) local x3,y3,w3,h3 = relative(381,222,190,30) spawnScreenOKButton = guiCreateButton(x3,y3,w3,h3,'Done',false,spawnScreenMenu) guiSetVisible(spawnScreenMenu,false) for i=1,#data do local row = guiGridListAddRow(spawnScreenGridList) guiGridListSetItemText(spawnScreenGridList,row,1,data[i][1],false,false) guiGridListSetItemText(spawnScreenGridList,row,2,data[i][2],false,false) end -- Command to launch the GUI addCommandHandler('idselection',function() if guiGetVisible(spawnScreenMenu) then guiSetVisible(spawnScreenMenu,false) showCursor(false) else guiSetVisible(spawnScreenMenu,true) showCursor(true) end end) addEventHandler('onClientGUIClick',spawnScreenOKButton,function() guiSetVisible(spawnScreenMenu,false) showCursor(false) end) I've added a relative function, you'll have to change the resolution as well as the numbers in the relative() functions to match your resolution, after that they should be working just fine, inputting absolute values and getting relative values, I just tested this code and it is working perfectly. I did this whole relative thing because MTA relative values are only based off of your resolution, I made it so its based off of all resolutions, that way you wont have any problems with resizing or moving the GUI on another persons screen. It'll look the same on your screen as a phone screen haha. Have a nice day.
  9. function getVehicleFromPlate(text) local vehicles = getElementsByType('vehicle') for i=1,#vehicles do if string.lower(getVehiclePlateText(vehicles[i])) == string.lower(text) then return vehicles[i] end end return false end
  10. I've compacted your code for you, removing any unnecessary things. I always do this with code, so nothing to worry about. I hope it helps.
  11. You can use this, this only works so long as the script is running. There's no way to permanently remove the trees, but what you could do is put this in a script and put the script in auto launch in the mta server config. local trees = {881,882,883,884,885,889,891} addEventHandler('onResourceStart',resourceRoot,function() for i=1,#trees do removeWorldModel(trees[i],10000,0,0,0,0) removeWorldModel(trees[i],10000,0,0,0,13) end end)
  12. I'm not trying to change what the code does Cody. I'm just making the code simpler and cleaner than it was.
  13. onClientResourceStart runs 1 time, all the code is unloaded when the script stops, so it runs a loop through the table 1 time. meaning it uses the information 1 time. And so on, simply put the whole thing runs once and only once. All you need for customization is the table above. It includes dff name, txd name, and col name, as well as the element id you want to replace. I'm not quite sure what other customization you're including. What i posted is customizable, clean, and functional. You've made cool :~ Cody, I wont deny your skill, you've got a lot more potential than I do. However your code is not 'clean', it becomes hard to understand. I ask that you don't contradict me because I find it insulting.
  14. models = { {'object.dff','object.col','object.txd',18633}, } addEventHandler('onClientResourceStart',resourceRoot,function() for i=1,#models do local dff = engineLoadDFF(models[i][1],models[i][4]) engineReplaceModel(dff,models[i][4]) local col = engineLoadCOL(models[i][2]) engineReplaceCOL(col,models[i][4]) local txd = engineLoadTXD[models[i][3]] engineImportTXD(txd,models[i][4]) end end) Formatted code. Same result. If this does not work, it is either your model or the element id is not valid, have a nice day.
  15. ShayF2

    Lessons

    I made this in VS Community 2015, I'm not sure how to properly publish it as an exe, so your pc may flag it, due to it not having publishing information. But it contains everything one would need to learn lua, I have implemented a lessons script to my website, which allows people to visit and learn what things do. I will be eventually upgrade the program, add more lessons, and so on. This program is in beta stage, so please let me know what you think of it. http://www.mediafire.com/file/lwoc24rebuwus3l/lessons.exe
  16. Locations = { {-1351.5205078125,-503.66796875,14.171875,"SF Airport"}, -- Locations[1] {2838.658203125,999.6708984375,10.75,"East LV"}, -- Locations[2] {2262.89453125,2792.927734375,10.8203125,"Near KACC"}, -- Locations[3] {2763.138671875,-2421.6845703125,13.486039161682,"Test"}, -- Locations[4] {-576.53063964844,-550.34674072266,25.529611587524,"Fallen Tree"} -- Locations[5] } Markers = { {2762.677734375,-2431.4296875,12.5}, -- Markers[1] {2747.6467285156,-2410.5747070313,13.45193195343} -- Markers[2] } Use better format, you don't need those numbers to define things in the table. Tables have index numbers, which is what you're trying to use. Unless u move [5] where [1] should be u won't need those.
  17. its not jpeg format, its png, however jpeg will still open it's not advised.
  18. I already am working on my own dxlib, with its own functionality and personalization. Im not reinventing dx like you said, instead id be making a different brand of bike. The idea is the same, the result is different. I always prefer something i myself make over any other.
  19. I make my own dx elements, buttons, windows, gridlists, etc. I find it better to have your own code than someone else's.
  20. Lemme know what you think in the comments. This is a sped up gif, home screen works perfectly.
  21. god i hate it when people format code in a :Oed up way
  22. I was working on a script getting nearest elements, maybe someone will find this of use. This code is NOT tested, so it may need some modifications, but it's a basic platform. Note it contains a lot of looping and is set clientside so it may suck quite a bit of work out of a users computer, causing an fps drop. However I made it so that only rendered elements are checked, so that should reduce the amount of work. Here's the code. local timers = {} local positions = {} local objectids = {'1221'} function checkElements(element,x1,y1,z1) local x2,y2,z2 = getElementPosition(v) local distance = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) table.insert(postions,{element,x2,y2,z2,distance}) end function getNearestElement(element) if isElement(element) then local elementTypes = {'vehicle','player','ped','object'} local x1,y1,z1 = getElementPositon(element) positions = {} for i=0,#elementTypes do for k,v in pairs(getElementsByType(elementTypes[i])) if isElementOnScreen(element) then if elementTypes[i] == 'object' then for l=0,#objectids do if getElementModel(v) == objectids[l] then checkElements(v,x1,y1,z1) end end else checkElements(v,x1,y1,z1) end end end end end local distances = {} for s,t in ipairs(positions) do table.insert(distances,t[5]) end table.sort(distances) for c,d in pairs(positions) do if d[5] == distances[1] then return d end end end addEventHandler('onClientPlayerJoin',root,function() source = source timers[source] = setTimer(function() getNearestElement(source) end,1000,0) end) addEventHandler('onClientPlayerQuit',root,function() if isTimer(timers[source]) then killTimer(timers[source]) end end)
  23. Whenever there's a script I like that's compiled or one i found on a server I either get rid of it, or rescript it myself and add some cool new features.
×
×
  • Create New...