Crosshair Posted June 14, 2012 Share Posted June 14, 2012 Hello. I have a question about vehicle id`s. I want to add all the vehicles in sql(add and delete in game). Adding is easy, but let`s say i want to delete a vehicle. How do i do that ? Using set/getElementData should do it, but there will be dozens of vehicles in the database. Anyone has some idea ? Link to comment
Lloyd Logan Posted August 11, 2012 Share Posted August 11, 2012 Hello.I have a question about vehicle id`s. I want to add all the vehicles in sql(add and delete in game). Adding is easy, but let`s say i want to delete a vehicle. How do i do that ? Using set/getElementData should do it, but there will be dozens of vehicles in the database. Anyone has some idea ? Are you using any specific script, (Vg etc), does the cars id come up, and yes setElementData Link to comment
Dev Posted August 12, 2012 Share Posted August 12, 2012 If you wish to permanently delete it from the database you will have to execute an SQL query to the database for the removal of the row which holds the vehicle's data. Something like this, if you're using the vG/Vedic script. local mysql = exports.sql function deleteVehicle( thePlayer, commandName, vehicleID ) if ( vehicleID ) then local vehicleID = tonumber( vehicleID ) local didFind = false for key, theVehicle in ipairs ( getElementsByType("vehicle") ) do if ( tonumber( getElementData( theVehicle, "id" ) ) == vehicleID ) then destroyElement( theVehicle ) didFind = true break end end if ( didFind ) then local delete = mysql:query_free("DELETE FROM `vehicles` WHERE `id`=".. mysql:escape_string( tostring( vehicleID ) ) .."") if ( delete ) then outputChatBox("The vehicle was successfully deleted!", thePlayer, 0, 255, 0) else outputChatBox("MySQL Error!", thePlayer, 255, 0, 0) end else outputChatBox("Couldn't find vehicle with ID ".. vehicleID, thePlayer, 255, 0, 0) end else outputChatBox("SYNTAX: /".. commandName .." [ Vehicle ID ]", thePlayer, 255, 194, 14) end end addCommandHandler("delveh", deleteVehicle, false, false ) 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