• Announcements

    • jhxp

      Forums are online again after a maintenance.   18/03/17

      MTA Forums maintenance is completed, although some automatic time-heavy tasks are still in process and will be finished eventually in background. Expect some features such as Forum Search to not display all results until all processes are finished. Please let us know if you spot a forum feature that worked correctly before the maintenance but does not work anymore now. Thanks. --MTA Team
    • jhxp

      Multi Theft Auto: San Andreas 1.5.4 is out!   21/04/17

      Click the link in the announcement for more details.  

Fist

Members
  • Content count

    283
  • Joined

  • Last visited

Community Reputation

22 Decent

1 Follower

About Fist

Details

  • Gang
    Scripting
  1. Everytime you press E it will call this function generateRandomGroupNumbers() and everytime it calls it, it will delete previous numbers and get new ones. So solution for this is that you have to call it only once. local table = generateRandomGroupNumbers() function checkBar(source) local check1 = guiScrollBarGetScrollPosition ( bar ) for _,v in ipairs(table) do if (v == check1) then guiSetVisible(Window,false) showCursor(false) removeEventHandler("onClientRender", getRootElement(), openLockedCrate) --triggerServerEvent () end end end bindKey ( "E", "down", checkBar )
  2. oh didn't pay attention on that. here is working version. client: function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end addEventHandler("onClientRender",root,function() for _,v in pairs(getElementsByType("player")) do if (getElementData(v,"isVIP")) then dxDrawTextOnElement(v,"VIP",1,50,255,20,20,255,1,"arial") end end end) server: addEventHandler("onPlayerLogin",root,function() if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Vip"))) then setElementData(source,"isVIP",true) end end)
  3. client side function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end addEventHandler("onClientRender",root,function() for _,v in pairs(getElementsByType("player")) do if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)),aclGetGroup("Vip"))) then dxDrawTextOnElement(v,"VIP",1,50,255,20,20,255,1,"arial") end end end)
  4. you have to loop through table like this for _,v in pairs(tableVariableHere) do -- this code here will execute as many times as items are in table so you just need to add check variable if v == check1 then once it found it and then we can return true or any variable back or even set any other variable if you need if (v == check1) then -- this code will be executed once check1 matches one of numbers that is in table end end
  5. sure send me link in pm
  6. ah that's 'cause startingPosition is more than 10. I didn't think this would affect that 'cause never used it in such way but here is working code. function generateRandomGroupNumbers() local randomNumbers = {} -- create temporary table to store numbers local startingNumber = math.random(90) -- get random starting position for i=startingNumber,startingNumber+10 do -- add 10 numbers from starting position table.insert(randomNumbers,i) end return randomNumbers; -- returns table with numbers when numbers have been generated end addCommandHandler("do",function(source,cmd) local table = generateRandomGroupNumbers(); iprint(table) end)
  7. maybe try with pairs instead, sometimes it just doesn't work with ipairs happend to me before but in theory it should anyway print numbers out in correct order, but if they don't then you gonna need use table.sort but i'm pretty sure it will work any way. for i,number in pairs(numbers) do iprint(number) end
  8. Is there any working version completed map for MTA which is downloadable today and has no bugs in it or works great without any performance issue? Because i want to make something different, kinda sick with that default map already.
  9. ah i think i understood you, here this should do the trick. Haven't tested it but should work. function generateRandomGroupNumbers() local randomNumbers = {} -- create temporary table to store numbers local startingNumber = math.random(90) -- get random starting position for i=startingNumber,10 do -- add 10 numbers from starting position table.insert(randomNumbers,i) -- insert them to table end return randomNumbers; -- returns table with numbers when numbers have been generated end -- this is an example how to use function local numbers = generateRandomGroupNumbers(); -- now lets loop through table (You should use ipairs for this if you want them to be exactly in correct order) for i,number in ipairs(numbers) do iprint(number) end
  10. well you can do same thing on server side only need to get who made that ped on mouse click.
  11. yeah but you can create ped with 0 alpha for 1 mili second where mouse clicks once you are close enough to marker and then handle all that through onClientColShapeHit. This will make clickable markers possible really easy.
  12. You want to get 10 random numbers from specified value? If i understood you correctly then you can do this. local randomNumbers = {} -- create table. for i=1,10 do -- loop through function beloew 10 times. table.insert(randomNumbers,math.random(100)) -- insert them to table end -- now when you need those random numbers you can just loop through them like this. for _,number in pairs(randomNumbers) do iprint(number) -- this will show all numbers in '/debugscript 3' menu. end -- if you dont need anymore those 10 random numbers and want to clear them to insert other 10 random numbers just do this randomNumbers = {} -- this will empty the table
  13. Then check out this subforum for Lithuanians, you can speak in there in your native langauge. https://forum.mtasa.com/forum/104-lithuanian-lietuvių/
  14. will i get what? For me works perfect. Btw i think your problem is that you are using this script on server side. That's why it gave you tocolor global error. lol Put it on CLIENT side
  15. what? I'm using latest version and what does that matter with it lol. That latest version won't show local player (yourself) only other players once you are in hydra and if only nearest players that are in radius of 500 meters will be shown. You can change how long distance is in code.