Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/03/22 in all areas

  1. Both. function setFuelCar(thePlayer) local source = getPedOccupiedVehicle(thePlayer) -- (1) if getPedOccupiedVehicleSeat(thePlayer)==0 then -- (2) if getVehicleEngineState(source)==true then ---------if the engine it's on I start the timer -- (3) local x,y,z = getElementPosition(source) local fx,fy,fz = x+0.05, y+0.05,z+0.05 -- (4) local fuelConsumption = 0.900 local fuelVeh = getElementData(source, "Fuel") or 0 if (fuelVeh <= 0) then setVehicleEngineState(source, false) else timerF = setTimer( function () -- (5) local enginePlus = 0.200 local distance = getDistanceBetweenPoints3D(x,y,z,fx,fy,fz) -- (6) local newFuel = tonumber((fuelVeh - (fuelConsumption*(distance+enginePlus)))) setElementData(source, "Fuel", newFuel) end, 20000, 0) end end end end addEventHandler("onVehicleEnter", root, setFuelCar) You don't need to overwrite the source variable. It already exists thanks to the onVehicleEnter event. Have a look at: https://forum.multitheftauto.com/topic/33407-list-of-predefined-variables/#comment-337231 onVehicleEnter already gives you the seat number, you have to "grab" it too : function setFuelCar(thePlayer, seat) if seat == 0 then Here in your code, this check is only done once, when entering the vehicle. You have to change it so that you create the fuel timer anyway when entering the vehicle at seat 0 but inside the timer function, the 1st thing you do is to check the engine state. If it's ON, do the newFuel calculation thing. And if fuel is <= 0 then set it to OFF. (Why the +0.05 to each components ? seems totaly useless) You can't use a global variable on the server side or else if another player enters another vehicle, it will start his vehicle fuel timer and override the value in timerF so you have no way to kill the timer of your vehicle later. Must be local and "link it" with your vehicle element: setElementData(source, "fuelTimer", timerF, false) (false because there is no need to sync this value with all connected clients, only the server needs to know and manipulate it). You have to update the value of fx,fy,fz with the current x, y, z at the end to calculate the new distance traveled between point B and point C (20 secs later). Again, use element data to store that position for the next fuel consumption calculations (you can't use global variables).
    2 points
  2. In this video I'm going over creating a road using splines, and then texturing it with help of a checker image to ensure the UVs are nice and uniform all the way through. In the video I'm using the texture sf_road5 found in roadsanfranse.txd, which needs to be mirrored onto the opposite lane to map correctly. If you have a double-lane texture, this guide will also work for you
    1 point
  3. 2. And even 1 more info if you check the wiki https://wiki.multitheftauto.com/wiki/OnVehicleEnter. It also can give you the player that you are kicking out of the vehicle to take its place (if there was a player already in ofc) as 3rd argument of your event handler. 3. and 4. okay perfect 5. Yes you can totally do that, even though the place this data takes on the server is very tiny. Even if you multiply that by 5,000+ potential vehicles. But yes, it's better and you are right. if isTimer(timerF) then killTimer(timerF) end -------Don't know if this is neccesary if I set the timer as you said ('setElementData(source,"fuelTimer", timerF') Yes you still have to kill it. removeElementData will only remove the timer from element (kind of unlinking) but the timer will still run in background. Note: My setElementData for the fuelTimer had a 4th argument which was false (it's true by default if you omit it) and it's important to prevent it to be automatically sent to all clients connected to the server (if you have 500 players, this only call will make 500 calls to triggerClientEvent (well, not exactly but almost like if) which is a waste of CPU and bandwidth as we only need it on the server side). Also, make sure you get your timerF using getElementData(source, "fuelTimer") 6. perfect You are doing good by the way (understanding and implementing the suggestions), keep it up ?
    1 point
  4. كلامك صحيح اكيد يستخدم setMinuteDuration الا ما كنت اعرف عن وجوده
    1 point
  5. As has been said we do not accept appeals for temp bans I'm afraid, please see the advice Vinyard left you
    1 point
  6. Multi Theft Auto: San Andreas been around for quite some time indeed! The official launch of Multi Theft Auto: SA 1.0 was August 21, 2009 - prior to then we also had Multi Theft Auto: SA Race and Deathmatch, released January 22, 2006 & January 3, 2008 respectively. Multi Theft Auto's first release version was Grand Theft Auto: Alternative Multiplayer, all the way back in February 9, 2003 Version history
    1 point
  7. - To locate which DFF models use a certain TXD file or vice-versa: check out - If you're looking for a resource to load SAMP maps (Pawn code) directly: check out https://github.com/Fernando-A-Rocha/mta-samp-maploader
    1 point
  8. use dgsCreateLabel - Multi Theft Auto: Wiki dgsCreateLabel
    0 points
×
×
  • Create New...