Fist
Members-
Posts
433 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Fist
-
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
-
sure send me link in pm
-
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)
-
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
-
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.
-
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
-
well you can do same thing on server side only need to get who made that ped on mouse click.
-
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.
-
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
-
Then check out this subforum for Lithuanians, you can speak in there in your native langauge. https://forum.multitheftauto.com/forum/104-lithuanian-lietuvių/
-
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
-
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.
-
i made little mistake on getPedOccupiedVehicle i thought that it returns vehicle id but it returns vehicle userdata, so this is last and fully working code. Here you go dude. enjoy local playerColors = {} -- player color table local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value) -- this will get random color for every player (you can use your own system if you want to) function addNewPlayerColor(player) playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255)) end for _,player in pairs(getElementsByType("player")) do addNewPlayerColor(player) end addEventHandler("onClientPlayerJoin",root,function() addNewPlayerColor(source) end) addEventHandler("onClientPlayerQuit",root,function() playerColors[source] = {} end) -- this will get random color for every player (you can use your own system if you want to) addEventHandler("onClientRender",root,function() for _,players in pairs(getElementsByType("player")) do if (players ~= localPlayer) then -- check or players is not local player if (getVehicleName(getPedOccupiedVehicle(players)) == "Hydra") then -- check or player is on hidra local pX,pY,pZ = getElementPosition(players) local newX,newY = getScreenFromWorldPosition(pX,pY,pZ) local localX,localY,localZ = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ) if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters. -- this is Rectangle dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false) dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false) -- this is X (center one) dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false) dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false) -- this is player info dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025) end end end end end)
-
you can just comment those parts of code that checks or if "players" is local player and you will be able to see on yourself it. this version is that you have to use for everyone so it doesn't show yourself while you are doing it. local playerColors = {} -- player color table local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value) -- this will get random color for every player (you can use your own system if you want to) function addNewPlayerColor(player) playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255)) end for _,player in pairs(getElementsByType("player")) do addNewPlayerColor(player) end addEventHandler("onClientPlayerJoin",root,function() addNewPlayerColor(source) end) addEventHandler("onClientPlayerQuit",root,function() playerColors[source] = {} end) -- this will get random color for every player (you can use your own system if you want to) addEventHandler("onClientRender",root,function() for _,players in pairs(getElementsByType("player")) do if (players ~= localPlayer) then -- check or players is not local player if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra local pX,pY,pZ = getElementPosition(players) local newX,newY = getScreenFromWorldPosition(pX,pY,pZ) local localX,localY,localZ = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ) if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters. -- this is Rectangle dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false) dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false) -- this is X (center one) dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false) dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false) -- this is player info dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025) end end end end end) and this is that it works even with yourself local playerColors = {} -- player color table local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value) -- this will get random color for every player (you can use your own system if you want to) function addNewPlayerColor(player) playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255)) end for _,player in pairs(getElementsByType("player")) do addNewPlayerColor(player) end addEventHandler("onClientPlayerJoin",root,function() addNewPlayerColor(source) end) addEventHandler("onClientPlayerQuit",root,function() playerColors[source] = {} end) -- this will get random color for every player (you can use your own system if you want to) addEventHandler("onClientRender",root,function() for _,players in pairs(getElementsByType("player")) do --if (players ~= localPlayer) then -- check or players is not local player --if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra local pX,pY,pZ = getElementPosition(players) local newX,newY = getScreenFromWorldPosition(pX,pY,pZ) local localX,localY,localZ = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ) if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters. -- this is Rectangle dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false) dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false) -- this is X (center one) dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false) dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false) -- this is player info dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025) end --end --end end end)
-
idk i didn't have this error, i think its not my side of code and i accidently put greater than 500 distance to show that target to fix it change this if (newX and newY and dist >= 500) then -- check or newX newY exists and if dist is over than 500 meters. to this if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.
-
sorry for late reply, here you go i wrote it. Tested and its working. local playerColors = {} -- player color table local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value) -- this will get random color for every player (you can use your own system if you want to) function addNewPlayerColor(player) playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255)) end for _,player in pairs(getElementsByType("player")) do addNewPlayerColor(player) end addEventHandler("onClientPlayerJoin",root,function() addNewPlayerColor(source) end) addEventHandler("onClientPlayerQuit",root,function() playerColors[source] = {} end) -- this will get random color for every player (you can use your own system if you want to) addEventHandler("onClientRender",root,function() for _,players in pairs(getElementsByType("player")) do if (players ~= localPlayer) then -- check or players is not local player if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra local pX,pY,pZ = getElementPosition(players) local newX,newY = getScreenFromWorldPosition(pX,pY,pZ) local localX,localY,localZ = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ) if (newX and newY and dist >= 500) then -- check or newX newY exists and if dist is over than 500 meters. -- this is Rectangle dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false) dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false) dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false) -- this is X (center one) dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false) dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false) -- this is player info dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025) end end end end end)
-
Maybe you can post some code which doesn't work? Because we can't help you otherwise. p.s are you Latvian?
-
you can add that map in it's own resource folder and then only spawn/create other things only when map resource is started. Or just put map resource as first one to load in "mtaserver.conf" file. Or just make variable "isMapStarted' or anything like that and then set true when map starts and only then spawn everything. There are other ways doing it, only need to think a little,
-
yeah that's kinda what i wanted to write but thought about those renderTarget problems about memory. It actually sucks that there is no better function which doesn't require any memory usage.
-
and what you mean by that smart scripting, huh? And really, there is no other way making dx panes ? That sucks.
-
so as the title says how can i use dxSetRenderTarget properly? Because it uses memory to store. But what if player's computer is very :~ and memory is already full then how i will be able to create that render target in order to show it? Also is there other way to clip area what you dont want to show without using dxSetRenderTarget (like a window where things will only be showed if its in that window area)?
-
It's impossible to do that with default weapon models. But as @ThatsMe said above, you can make default weapon invisible and then attach your custom weapon model to hands. But there is 1 limitation that sucks with doing it, if you gonna aim then model rotation will delay if you move your cursor.
-
I better would encrypt every script, including server side because there are hostings that can steal your scripts if you host at :~ty hosting.