mint3d Posted December 20, 2013 Share Posted December 20, 2013 Ok so I made this script but every time the script restarts the power resets can anyone help me please? mysql = exports.mysql function powerChange ( thePlayer, command, power ) if exports.global:isPlayerLeadAdmin(thePlayer) then power = tonumber ( power ) local veh = getPedOccupiedVehicle ( thePlayer ) if power and veh then local success = setVehicleHandling ( veh, "engineAcceleration", power ) if success then outputChatBox ( "Your vehicle's acceleration has been changed to: "..power.." ", thePlayer, 0, 255, 0 ) local dbid = getElementData(veh, "dbid") mysql:query_free("UPDATE vehicles SET power="..power.." WHERE id="..dbid) exports.logs:dbLog(thePlayer, 40, veh, "SETPOWER: "..power.."") else outputChatBox ( "Setting power failed.", thePlayer, 255, 0, 0 ) end elseif not veh then outputChatBox ( "You're not in a vehicle.", thePlayer, 255, 0, 0 ) elseif not power then outputChatBox ( "Syntax: /setpower [1 - 100000]", thePlayer, 255, 0, 0 ) end end end addCommandHandler ( "setpower", powerChange ) Link to comment
Renkon Posted December 21, 2013 Share Posted December 21, 2013 Whenever you are using elementData, you must know that elementData is lost whenever the vehicle is destroyed (I mean, destroyElement, not blowVehicle). So that makes dbid get lost. So whenever you do a query, you'll have the wrong dbid. What you should do then is to find the way to make some sort of vehicles system where the IDs are stored even after the server is shut down. That will probably do. Link to comment
tosfera Posted December 21, 2013 Share Posted December 21, 2013 Whenever you are using elementData, you must know that elementData is lost whenever the vehicle is destroyed (I mean, destroyElement, not blowVehicle). destroyElement, onVehicleExplode ( blowVehicle also triggers the function ) and restarting the source which spawned the vehicle destroys the vehicle. So it does also destroy the elementData. 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