TheMaysTRo Posted June 13, 2014 Share Posted June 13, 2014 hello. I made a progress bar using guiCreateProgressBar and its 0% my problem is how to make it move ._. Thanks. progressBar = guiCreateProgressBar( 0.75, 0.3, 0.3, 0.01, true, nil ) Link to comment
Max+ Posted June 13, 2014 Share Posted June 13, 2014 you Can Check this Function , and learn form it , guiProgressBarSetProgress Link to comment
TheMaysTRo Posted June 13, 2014 Author Share Posted June 13, 2014 i tried it . my script is farmer job and the progress bar appear when you get in the tractor so its says the "progress bar not found" all what i want to do is that the progress bar increases when the tractor move . (and im not seeing the progress bar increasing in game) Link to comment
Max+ Posted June 13, 2014 Share Posted June 13, 2014 Try like this , progressBar = guiCreateProgressBar( 0.75, 0.3, 1, 1, true, nil ) guiProgressBarSetProgress(progressBar,tonumber(guiProgressBarGetProgress(progressBar))+1) Link to comment
TheMaysTRo Posted June 13, 2014 Author Share Posted June 13, 2014 Try like this , progressBar = guiCreateProgressBar( 0.75, 0.3, 1, 1, true, nil ) guiProgressBarSetProgress(progressBar,tonumber(guiProgressBarGetProgress(progressBar))+1) it worked , but i want to increase the value of progress bar when the car move only Link to comment
Et-win Posted June 13, 2014 Share Posted June 13, 2014 Maybe some useful information can be found here: viewtopic.php?f=91&t=52825 Try to use Google next time EDIT: Also, if you want to detect the tractor, you can detect the vehicle where the player is in currently: getPedOccupiedVehicle Link to comment
mint3d Posted June 13, 2014 Share Posted June 13, 2014 New to scripting.. but try this.. function () local vehicle = getPedOccupiedVehicle( localPlayer ) if vehicle == 531 then if vehicle and getVehicleOccupant( vehicle, 0 ) == localPlayer and getVehicleEngineState( vehicle ) == true and getElementSpeed( vehicle ) > 1 then guiProgressBarSetProgress(progressBar , +1) else outputChatBox ("progressbar not found!") end end end ) Link to comment
Max+ Posted June 14, 2014 Share Posted June 14, 2014 These are the functions to make your script , getVehicleEngineState --- if the vehicle are on getPedOccupiedVehicle ----- if ped in the vehicle [url=https://wiki.multitheftauto.com/wiki/GetElementSpeed]https://wiki.multitheftauto.com/wiki/GetElementSpeed[/url]---- get the vehicle speed guiProgressBarGetProgress ---- get the bar valute form 0 guiProgressBarSetProgress --- set it for an example 100 Link to comment
TheMaysTRo Posted June 14, 2014 Author Share Posted June 14, 2014 New to scripting.. but try this.. function () local vehicle = getPedOccupiedVehicle( localPlayer ) if vehicle == 531 then if vehicle and getVehicleOccupant( vehicle, 0 ) == localPlayer and getVehicleEngineState( vehicle ) == true and getElementSpeed( vehicle ) > 1 then guiProgressBarSetProgress(progressBar , +1) else outputChatBox ("progressbar not found!") end end end ) not working Link to comment
mint3d Posted June 14, 2014 Share Posted June 14, 2014 What are the errors? /debugscript 3 Link to comment
Max+ Posted June 14, 2014 Share Posted June 14, 2014 What are the errors? /debugscript 3 Your Code is Wrong , Check the functions that i post , and try make it for him , Link to comment
TheMaysTRo Posted June 14, 2014 Author Share Posted June 14, 2014 What are the errors? /debugscript 3 i didn't get any error its on client side . Link to comment
MannPro Posted June 14, 2014 Share Posted June 14, 2014 These are the functions to make your script , getVehicleEngineState --- if the vehicle are on getPedOccupiedVehicle ----- if ped in the vehicle [url=https://wiki.multitheftauto.com/wiki/GetElementSpeed]https://wiki.multitheftauto.com/wiki/GetElementSpeed[/url]---- get the vehicle speed guiProgressBarGetProgress ---- get the bar valute form 0 guiProgressBarSetProgress --- set it for an example 100 This thing is perfect go for it Link to comment
TheMaysTRo Posted June 15, 2014 Author Share Posted June 15, 2014 These are the functions to make your script , getVehicleEngineState --- if the vehicle are on getPedOccupiedVehicle ----- if ped in the vehicle [url=https://wiki.multitheftauto.com/wiki/GetElementSpeed]https://wiki.multitheftauto.com/wiki/GetElementSpeed[/url]---- get the vehicle speed guiProgressBarGetProgress ---- get the bar valute form 0 guiProgressBarSetProgress --- set it for an example 100 This thing is perfect go for it i Can't do it (i tried) Link to comment
tosfera Posted June 15, 2014 Share Posted June 15, 2014 You said you tried, show us what you tried. Link to comment
TheMaysTRo Posted June 15, 2014 Author Share Posted June 15, 2014 You said you tried, show us what you tried. function move (player, seat, jacked ) local vehicle = getPedOccupiedVehicle( localPlayer ) if vehicle == 531 then if vehicle and getVehicleOccupant( vehicle, 0 ) == localPlayer and getVehicleEngineState( vehicle ) == true and getElementSpeed( vehicle ) > 1 then guiProgressBarSetProgress(progressBar , +1) end end end ) addEventHandler( "onClientVehicleEnter", getRootElement(), move ) this is not working. Link to comment
Castillo Posted June 15, 2014 Share Posted June 15, 2014 There are many problems in that script. 1: 'vehicle' is a element, not a number, you must use getElementModel to get it's model. 2: getElementSpeed is not defined anywhere, since this is not a MTA native function, you must define it. 3: At guiProgressBarSetProgress, you forgot to get the current bar progress, in order to increase it. Link to comment
Max+ Posted June 15, 2014 Share Posted June 15, 2014 There are many problems in that script.1: 'vehicle' is a element, not a number, you must use getElementModel to get it's model. 2: getElementSpeed is not defined anywhere, since this is not a MTA native function, you must define it. 3: At guiProgressBarSetProgress, you forgot to get the current bar progress, in order to increase it. i have a question about getElementSpeed it's like removed from mta ? how to define it as you said ? Link to comment
TheMaysTRo Posted June 16, 2014 Author Share Posted June 16, 2014 whats wrong ? function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.8 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function speed(element, unit, speed) if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) guiProgressBarSetProgress(progressBar,tonumber(guiProgressBarGetProgress(progressBar))+1) outputChatBox ( "Red #FFFFFFWhite", getRootElement(), 255, 0, 0, true ) return true end return false end addEventHandler( "onClientVehicleEnter", getRootElement(), getElementSpeed ) addEventHandler( "onClientVehicleEnter", getRootElement(), speed ) setTimer ( speed, 1000, 100) help please Link to comment
TheMaysTRo Posted June 16, 2014 Author Share Posted June 16, 2014 whats wrong ? function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.8 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function speed(element, unit, speed) if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) guiProgressBarSetProgress(progressBar,tonumber(guiProgressBarGetProgress(progressBar))+1) outputChatBox ( "Red #FFFFFFWhite", getRootElement(), 255, 0, 0, true ) return true end return false end addEventHandler( "onClientVehicleEnter", getRootElement(), getElementSpeed ) addEventHandler( "onClientVehicleEnter", getRootElement(), speed ) setTimer ( speed, 1000, 100) help please no one ? Link to comment
diesel974 Posted June 17, 2014 Share Posted June 17, 2014 firstly this is wrong : addEventHandler( "onClientVehicleEnter", getRootElement(), getElementSpeed ) you are trying to call the function getElementSpeed with the parameters : player and seat that the event onClientVehicleEnter gives to the function (sorry for my bad english). Therefore, erase this line. Secondly; same mistake here too addEventHandler( "onClientVehicleEnter", getRootElement(), speed ) heres a tip of how you should do it : function speed(player, seat) local vspeed = getElementSpeed(source,"mph") if vspeed then .... -- now you continue with the function end addEventHandler("onClientVehicleEnter",getRootElement(),speed) Link to comment
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