Jump to content

Zango

Discord Moderators
  • Posts

    681
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zango

  1. It's the angle your gun is tilted upwards in your picture. Like this rx, ry, rz = getElementRotation(gun) rx = math.rad(rx) rz = math.rad(rz) x = x + 0.1 * math.cos(rx) * math.cos(rz) y = y + 0.1 * math.cos(rx) * math.sin(rz) z = z + 0.1 * math.sin(rx) What is your gun, is it an object or a custom weapon? It might be better for you to use a matrix, see the example in getElementMatrix
  2. It's because you're missing the colon exports["resource_Name"]:testExportF("Hello") Basically when you do table:method(arg), Lua passes along "table" as the first parameter, so it's effectively doing table.method(table, arg) If you just do exports.resource.function then it's expecting that first parameter. Even though you can do exports.resource_Name.testExportF(nil, "hello")
  3. You need more than just rotationZ to do that, if you want to find a point from the rotation of the gun. Assuming your weapon has a pitch and yaw, and roll is 0, you would do this to find your point, where yaw is your rotationZ (in radians) x = x + 0.1 * math.cos(pitch) * math.cos(yaw) y = y + 0.1 * math.cos(pitch) * math.sin(yaw) z = z + 0.1 * math.sin(pitch)
  4. Well it looks like you are already selecting the account data in the server code, so you could pass it to the client in the event?
  5. I remember having issues with the player as source element, try using resourceRoot triggerClientEvent(source,"showCharacters",resourceRoot,source,charCount)
  6. DX are not elements like the GUI elements which you create and destroy. Instead you call a function to draw something for 1 frame. 1 frame is not a very long time when you have 60 frames per second, so you use the event onClientRender to call the DX function every frame. In your code, use removeEventHandler to stop calling this function every frame. function HidePanel ( ) removeEventHandler ( "onClientRender", root, Panel ) end
  7. Zango

    help

    Do you want it disabled only for players, not admins? By source do you mean an admin calling this event? If so you can do this if inValidWeapons[tonumber(wep)] and (client ~= plr) then return end It's the same you do for ammo to give 5000 ammo instead of 90
  8. You haven't showed us the "Query" function in your resource MySQL so we can't tell for sure what's going on. Is "result" a table or a number? If it's a table you need to do #result to get the number of rows. Normally the results from queries are returned in a 2-dimensional table, with the rows being numerically indexed in order and each containing a table of key=value pairs corresponding to the columns in your SQL table. As you are selecting a user account, there should only be 1 row returned, or 0 if the user/password combination doesn't exist. So the length of "result" table should be 1, and the user you want is result[1]. The field you want is "skin", which is accessed like result[1].skin. You should post the code for mysql:Query or clarify what the variables are in this snippet.
  9. Unless it's absolutely necessary to recalculate something every frame, I don't recommend doing things onClientRender but rather in a timer and only draw and update things using onClientRender. You can do a lot of stuff every frame, and this script alone certainly wont impact performance, but with more and more scripts using that practice it eventually adds up and you get poor performance. I would use a timer with a few seconds interval or even more, and calculate the distance from the current position of the vehicle to the previous position. You could then store the distance in a table or you could save it to the vehicle's element data, so that if a new player becomes the driver, the tyre wear values are synchronised.
  10. You're right that it's a bad idea to have all the timers on the server side. Instead you place the timers client side, on the client who is driving the vehicle, and you trigger a server event to change the wheel states when it's time. One approach could be to use onClientVehicleDamage on the clientside to monitor for damage. This event has a parameter tyreID which shows what wheel specifically took damage. From there you could make it burst randomly or below a certain damage value. Another approach could be to monitor for how long the local player is driving the vehicle, and burst the tyres after a certain distance.
  11. Zango

    Crosshair

    function crosshair() local hitX,hitY,hitZ = getPedTargetEnd ( getLocalPlayer() ); local screenX1, screenY1 = getScreenFromWorldPosition ( hitX,hitY,hitZ ); dxDrawImage(screenX1-(32/2), screenY1-(32/2), 32, 32, "files/crosshair.png") end bindKey("aim_weapon", "both", function(key, keyState) local weaponID = getPedWeapon(localPlayer) if (weaponID == 34) or (weaponID == 35) or (weaponID == 36) then return end if keyState == "down" then addEventHandler("onClientRender", root, crosshair) else removeEventHandler("onClientRender", root, crosshair) end end) You get the current wielded weapon ID with getPedWeapon, and you use a return statement if you want to use default crosshair. The return statement means the rest of the code in the block is not executed. This code might fail if the weapon is changed to 34,35 or 36 while scoped in, as "onClientRender" will be running but won't stop then. I'm not sure if that's a problem. If it is, you can either implement a check to see if the event handler is added, and remove it, or you can add a check in onClientRender to not render.
  12. Set fourth argument in addEventHandler to false. Like this: addEventHandler( "onClientGUIClick", Adder.Button, sendData, false) By default the event propagates up and down, so when you click on a button it also triggers the event handler for the window, as the window is the parent of the button.
  13. Could you explain what you want to find in more detail? What type of element? What do you mean by last collision point?
  14. I've tried a few times and sometimes I can reproduce the issue. Try setting a 5th argument (after the coordinates) in setElementPosition to false. It moves the player instead of teleporting, which preserves the current animation, and apparently the rotation as well. It fixes the issue for me.
  15. seat_handler function must also have been serverside? Since it's called from the event handler for onColShapeHit which is a serverside event. I can't reproduce your issue. The rotation is set correctly for me. Rotation is relative to the world, so a value of 128 will always have the ped facing south west. For each of your seat positions, you need to find a rotation value. Not related to your issue, but you run math.random a few times to get a fresh value. math.random finds values from a seeded generator, so if you use the same seed (which is default) you'll get the same sequence of "random" numbers. Use math.randomseed (read about it here) at the start of your script to set a new seed. Use a new number as seed each time you run your script to get a new sequence. Use for example getRealTime().timestamp (seconds since 1970) as a seed.
  16. Is there any reason you're using the old mysql module and not MTA's database functions? Could you provide some more information on any errors you get? (use /debugscript 3) Is this the full code? When you run clientside code it runs in your MTA client, and when you run serverside code it runs in the MTA server. You can only communicate between these two by events and element data. So when you want to transfer the results from the database, you need to use triggerClientEvent to send it back to the client and put it into the text label.
  17. I can set rotation of both player and ped in animation fine. Could you post some more complete example code? And is this server or clientside?
  18. Joining the twenty most popular servers (sorted by playercount) I had to download 3,400MB One of the servers, not surprisingly Russian, had an astonishing 1.2GB of download on it's own. Not everyone is running on fiber yet and there's still a lot of people who are restricted by a monthly quote. I understand the importance of transferring models for your map, but complete visual modifications can be transferred optionally in-game. Functionality has been implemented to assist this issue, as you can prioritise the bandwidth spend transferring data in events (triggerLatentServerEvent)
  19. I usually don't enter the hardcore tokyo drift servers in fear that my PC collapses... Specific picture is from a roleplaying server I think. It's something to reflect on as a community though. If you go in the shoes of a new player you end up downloading 2GB of shit from the first 20 servers.
  20. About the best I could find haha It makes no sense, you're right, but at first glance it looked good. It was mostly to emphasize on the stuff with design coherency (colors). Removed it, please edit the post with a better example or reply. Added an example of a fabulous 820MB of download as well.
  21. Zango

    Help my script

    On line 10, you must declare vehicle as a parameter. function (vehicle) setVehicleOverrideLights(vehicle, 2) setVehicleHeadLightColor(vehicle, math.random(0,255), math.random(0,255), math.random(0,255) ) end,
  22. In [gameplay]/freeroam under resources, open up meta.xml change gamespeed/enabled to false Related note, if you haven't edited resources before, unzip it into a folder and delete the zip.
  23. Zango

    text

    The way I understand this - you want to disable the chatbox and use the topbarchat resource instead? According to this page on community, Serverside: addEventHandler ('onPlayerLogin', root, function () showChat (source, false) exports.topbarchat:sendClientMessage ('Thank you for logging in', source, 255, 255, 255) end )
  24. Zango

    text

    Don't wanna be that guy, but showChat is client and serverside. Blue highlighting in the [lua] markup indicates both variants.
×
×
  • Create New...