Zango

Members
  • Content Count

    618
  • Joined

  • Last visited

Community Reputation

2 Neutral

About Zango

  • Rank
    Pimp
  • Birthday 19/09/1993

Details

  • Location
    Denmark

Recent Profile Visitors

1,173 profile views
  1. 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?
  2. I remember having issues with the player as source element, try using resourceRoot triggerClientEvent(source,"showCharacters",resourceRoot,source,charCount)
  3. 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
  4. 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
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. Could you explain what you want to find in more detail? What type of element? What do you mean by last collision point?
  11. 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.
  12. 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.
  13. 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.
  14. 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?