Jump to content

arezu

Members
  • Posts

    446
  • Joined

  • Last visited

Everything posted by arezu

  1. local color = tocolor(255, 255, 255, 255) local red = bitExtract(color, 0, local green = bitExtract(color, 8, local blue = bitExtract(color, 16, local alpha = bitExtract(color, 24, (I couldn't use lua tag, because the text got formatted wrong because of '8)')
  2. Why not just create arrow and attach it to the player? like editor does.
  3. addEventHandler("onClientVehicleCollision", root, function(hitElement) if ( source == getPedOccupiedVehicle(localPlayer) and hitElement and getElementType(hitElement) == "vehicle") then local hitPlayer = getVehicleOccupant(hitElement) -- Get the player that is driving the vehicle you hit end end )
  4. arezu

    Race Cam.

    Do this: setCameraClip(true, false) and it will disable collision between camera and vehicle.
  5. If you can get the Z rotation, you can also get the X and Y rotation. It's just math with sins, cons and tans. For example if you are using two points as reference, like in the 'findRotation' function that IIYAMA provided, then you can only get Z and Y rotation. You need at least three points to get roll (X rotation) also, otherwise roll can only be 0.
  6. What exactly are you going to use it for? depending on what, you cant get X rotation, only Z and Y.
  7. Keep in mind that people can still get the code easily by packet sniffing, but I guess it's a good way to prevent noobs from stealing your scripts at least.
  8. I believe that happens when you try to change the element data of another player client sided. I believe it's supposed to be some kind of anti-hacking function, since if settings are correct for it, it will ban the player that attempted to change another players element data client sided with setElementData(thePlayer, key, newValue, true)
  9. You can return multiple values in lua and with different types. For example: function f() local player = localPlayer local playersFound = 3 return player, playersFound end local thePlayer, playersFound = f()
  10. guiSetInputMode("no_binds_when_editing") That function disables binds when writing in a textbox, not commands. The right way to do it is to use [url=https://wiki.multitheftauto.com/wiki/OnPlayerCommand]https://wiki.multitheftauto.com/wiki/OnPlayerCommand[/url] and cancel the event if source (the player that is trying to use a command) is not logged in.
  11. setCameraMatrix doesn't change hud in any way. You probably have another script that is hiding the HUD.
  12. onClientVehicleCollision is triggered everytime you collide with something (it will trigger if you drive straight into wall for example). You could check if the vehicle velocity is almost the opposite of the surface normal (the differences can be very big, since you can land with z velocity being very low, while x or y velocity being high).
  13. I tested a map with 8000 objects and it only caused freeze for around 0.2 sec, so the problem must be with your computer. You should try to ask others to test the script with you.
  14. From wiki for setElementVisibileTo: If it takes that long to create the objects, then you are doing something wrong. It works with no problem in our server without any delaying or anything like that.
  15. Ah, you got it wrong. normX, normY and normZ are together ONE 3d vector and they together tell what direction the vector is facing, and same for vecX, vecY and vecZ. You could think of vecX, vecY and vecZ as offsets in x, y and z direction. Which means that if you do local object = createObject(2811, 0, 0, 0) addEventHandler("onClientRender", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) local x, y, z = getElementPosition(vehicle) local m = getElementMatrix(vehicle) -- vecX, vecY and vecZ are values between -1 and 1, the same for normX, normY and normZ local vecX, vecY, vecZ = m[3][1], m[3][2], m[3][3] setElementPosition(object, x + vecX, y + vecY, z + vecZ) end) then the object (flower pot) will be above the vehicle, no matter your vehicle rotation. normX, normY and normZ work the same way, they are offset in the direction that the surface if facing. Also, onClientVehicleCollision is triggered before collision reaction, which means you dont need to check if vehicle was on ground the previous frame, also isVehicleOnGround is very inaccurate - doesn't work with all vehicles and only works on flat surfaces (doesn't work on slanted road, for example either). The easiest thing you could do if you dont understand vectors well, is to do local diffX, diffY, diffZ = math.abs(vecX - normX), math.abs(vecY - normY), math.abs(vecZ - normZ) and check if diffX, diffY and diffZ are smaller than small values, like 0.1 or something.
  16. addEventHandler("onClientVehicleCollision", root, function(hitElement, force, bodypart, colX, colY, colZ, normX, normY, normZ) -- normX, normY, normZ are the components of the normal vector that is the surface -- > the direction that the surface you hit is poiting in local vehicle = getPedOccupiedVehicle(localPlayer) -- Only check if vehicle landed on 4 wheels if the vehicle that collided was yours if(source ~= vehicle)then return end local m = getElementMatrix(vehicle) -- m[1] is vector pointing right (x vector), m[2] is the vector poiting forwards (y vector), -- and m[3] is the vector pointing up (z vector) local vecX, vecY, vecZ = m[3][1], m[3][2], m[3][3] -- compare vecX, vecY and vecZ with normX, normY, normZ to see how big the difference is between them end)
  17. The easiest way i can think of is to use getElementMatrix to get a vector that points up from the car, and compare that vector to the normal vector of the hit element you get from onClientVehicleCollision. ooooor, onClientVehicleCollision->use getElementMatrix with getElementBoundingBox to get the approximate position of the wheels, and use isLineOfSightClear to check if all the wheels are colliding with something. Start check from wheel position to inverted normal vector direction of the hit element (which you get from onClientVehicleCollision event).
  18. Are you using triggerClientEvent to send the table with the map data? if so, that is most likely the reason and you dont have to put a "sleep" timer in the creation loop if you instead use triggerLatentClientEvent (dont forget to add (can be lower version, but whatever) in the meta). TriggerClientEvent freezes the main thread while triggerLatentClient works on a different thread. Also another recommendation, instead of saving values in table as table.insert(objects, { ["posX"] = posX, ["posY"] = posY, ["posZ"] = posZ } -- etc you should instead do table.insert(objects, { posX, posY, posZ } -- etc and then client sided createObject(v[1], v[2], v[3]) -- etc Then the map size you are sending will be much smaller (much smaller than loading a map with startResource (http download). If done right, around 24% of original map size). Lua uses more memory in tables if you dont use numeric index values, and if the index you use are not in order, like table.insert(objects, { posX, posY, posZ } objects[#objects][10] = id -- etc instead of table.insert(objects, { posX, posY, posZ } objects[#objects][4] = id -- etc
  19. He is talking about that script that allows you to set camera position, or record vehicle and replay it (im not exactly sure which one of these the resource uses), which is actually 3min 36sec in the video
  20. I dont know what you want to achieve exactly with that code, but I guess you are trying to do something with animations, so you should use onClientRender and getKeyState (and/or bindKey and save the key state) instead in that case. onClientRender is called each frame, which means if you have 50 fps, then it will run each 1000/50 = 20ms.
  21. Pass root or resourceRoot, then you dont have to create and destroy a dummy element.
  22. There are currently 3 ways to do it triggerClientEvent/triggerLatentClientEvent -- Read file server sided and send the content fetchRemote downloadFile -- Only mta 1.4 though
  23. Yeah, I forgot that ^^. Updated the code in case somebody else needs it.
  24. -- The client script. Add in meta local text = "This text is going to rotate..." local fontScale, font = 2.0, "default-bold" local renderTarget = dxCreateRenderTarget(dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), fontScale, font), dxGetFontHeight(fontScale, font), true) local shader = dxCreateShader("textureReplace.fx") function updateRenderTarget() dxSetRenderTarget(renderTarget, true) dxDrawText(text, 0, 0, 0, 0, tocolor(255, 255, 255, 255), fontScale, font) dxSetRenderTarget() dxSetShaderValue(shader, "tex", renderTarget) end updateRenderTarget() addEventHandler("onClientRestore", root, function() updateRenderTarget() end) addEventHandler("onClientRender", root, function() dxSetShaderTransform(shader, 45, 0, 0) -- This is where the shader is rotated local width, height = dxGetMaterialSize(renderTarget) dxDrawImage(200, 200, width, height, shader) end) //textureReplace.fx shader file. Add this in meta as <file src="textureReplace.fx" /> texture tex; technique tech { pass p0 { Texture[0] = tex; } } Code not tested. If the quality looks bad, you can take a look at dxSetBlendMode
  25. Lol! trying to sell stolen script that you can find floating around the web anywhere.
×
×
  • Create New...