DarkByte Posted September 20, 2015 Posted September 20, 2015 Hi i tried to make a script and its not working. I wanna add laser at the tank. function laser ( creator) if getElementType(creator) == "vehicle" then if getElementModel(creator) == 432 then local x, y = getVehicleComponentPosition( creator, "misc_c" ) local x1, y1 = getVehicleComponentPosition( creator, "misc_a" ) dxDrawLine ( x, y, x1, y1, tocolor ( 255, 0, 0, 255 ) end end end end addEventHandler("onClientVehicleEnter", getRootElement(), laser) When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
HUNGRY:3 Posted September 20, 2015 Posted September 20, 2015 yes ofc it will not work since you didn't add the event "onClientRender" because it's very important for dx functions so it should be like this local x, y local x1, y1 function laser () local theVeh = getPedOccupiedVehicle(localPlayer) if getElementModel(theVeh) == 432 then x, y = getVehicleComponentPosition( theVeh, "misc_c" ) x1, y1 = getVehicleComponentPosition( theVeh, "misc_a" ) addEventHandler("onClientRender",root,add) end end addEventHandler("onClientVehicleEnter", getRootElement(), laser) function add() dxDrawLine ( x, y, x1, y1, tocolor ( 255, 0, 0, 255 ) ) end and what the hell is creator
DarkByte Posted September 20, 2015 Author Posted September 20, 2015 Not working. When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
HUNGRY:3 Posted September 20, 2015 Posted September 20, 2015 (edited) your code doesn't make sense what's misc? Edited September 20, 2015 by Guest
DarkByte Posted September 20, 2015 Author Posted September 20, 2015 NOt working When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
DarkByte Posted September 20, 2015 Author Posted September 20, 2015 http://imgur.com/f7rfz6r To Look this this When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
DarkByte Posted September 20, 2015 Author Posted September 20, 2015 Anyone help me? When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
BluntZ Posted September 20, 2015 Posted September 20, 2015 Any error in debugscript ? Skype : Mohd.hamza35 facebook : https://www.facebook.com/MrBluntZ Still looking for any server to work on!
JR10 Posted September 20, 2015 Posted September 20, 2015 You want it to look like the picture? And how does it look right now? Are you sure the components are correct? Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
DarkByte Posted September 20, 2015 Author Posted September 20, 2015 YES, i want like in the picture. I tried to make it. But i cant. Can someone help me? When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 Anyone? When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted September 21, 2015 Moderators Posted September 21, 2015 Get the function extendLine from the stealth resource, to extend the line... Which you probably can find in the main client file from stealth. And don't forget that the z variable is required from getVehicleComponentPosition to make this work. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 I found it. Can you help me futher. local laserWeapons = {} function drawLasers() for k,player in ipairs(getElementsByType"player") do local playerWeapon = getPedWeapon ( player ) if ( laserWeapons[playerWeapon] ) then local startX,startY,startZ,targetX,targetY,targetZ local boneX,boneY,boneZ = getPedBonePosition ( player, 25 ) startX,startY,startZ = getPedWeaponMuzzlePosition ( player ) if boneX and startX then if getPedControlState(player, "aim_weapon") then targetX, targetY, targetZ = getPedTargetEnd(player) else targetX,targetY,targetZ = extendLine ( boneX,boneY,boneZ,startX,startY,startZ - 0.1,500 ) end local bool,hitX,hitY,hitZ = processLineOfSight ( startX,startY,startZ,targetX,targetY,targetZ, true, true, true, true, true, false, false, true ) if not bool or not hitX then hitX,hitY,hitZ = targetX,targetY,targetZ end dxDrawLine3D ( startX,startY,startZ, hitX,hitY,hitZ, tocolor(255,0,0,50), 1, false, 1 ) end end end end When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted September 21, 2015 Moderators Posted September 21, 2015 In the code you posted there is only a reference to that function. You have to get the full function. function extendLine ( .... ... .. .. end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 function extendLine ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted September 21, 2015 Moderators Posted September 21, 2015 It is not really optimised based on when it renders. But it should be working. I added dxDrawLine3D instead of dxDrawLine because it is easier to use for 3D. But if you want to keep the line the same thickness, you will have to study this function: https://wiki.multitheftauto.com/wiki/Ge ... ldPosition in order to use dxDrawLine > 3D. function extendLine ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a" ) if x and x1 then local endX,endY,endZ = extendLine(x,y,z,x1,y1,z1,300) dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0)) end end end addEventHandler("onClientRender",root,renderTankLine) Update 19:35 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 Not working When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 http://imgur.com/tRQkshJ When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted September 21, 2015 Moderators Posted September 21, 2015 Did you copied the code after 19:35? I didn't add those red letters for nothing. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 YEs still nothing When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
Moderators IIYAMA Posted September 21, 2015 Moderators Posted September 21, 2015 Any errors or warnings? Because exactly those from that screenshot shouldn't be visible any more. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DarkByte Posted September 21, 2015 Author Posted September 21, 2015 http://imgur.com/6S3SZky When I hear someone saying Mac is better than PC. w0t?w0t? w0t? Great minds discuss ideas, average minds discuss events and small minds discuss people.
HUNGRY:3 Posted September 21, 2015 Posted September 21, 2015 function renderTankLine() local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a" ) if x and x1 then local endX,endY,endZ = extendLine(x,y,z,x1,y1,z1,300) dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0)) end end end addEventHandler("onClientRender",root,renderTankLine)
Moderators IIYAMA Posted September 21, 2015 Moderators Posted September 21, 2015 That warning you see is not from me. @HUNGRY:3 what did you change? I don't see any differences. @-Lemonade- Try to make the line a little bit thicker, because it must be somewhere. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
HUNGRY:3 Posted September 21, 2015 Posted September 21, 2015 That warning you see is not from me.@HUNGRY:3 what did you change? I don't see any differences. @-Lemonade- Try to make the line a little bit thicker, because it must be somewhere. Line 1 you did local renderblalala = function() It's from you :- ) IIYAMA-SENPAI That's why it's give error addEventHandler expected function
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now