Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function transferSpeedMod( thePlayer, commandName, id)
- if exports.global:isPlayerLeadAdmin(thePlayer) then
- if not id then
- outputChatBox("SYNTAX: Get in the origin vehicle and use the ID of the vehicle you wish to send it to.", thePlayer, 255, 194, 14)
- outputChatBox("SYNTAX: /" .. commandName .. " [Send Mods to Vehicle ID]", thePlayer, 255, 194, 14)
- else
- local veh = getPedOccupiedVehicle( thePlayer )
- if veh then
- local dbid = getElementData(veh, "dbid")
- local result = mysql:query( "SELECT speed, power FROM vehicles WHERE id="..dbid )
- local row = mysql:fetch_assoc( result )
- local speed = tonumber(row['speed'])
- local power = tonumber(row['power'])
- if speed~=nil and power~=nil then
- local targetVehicle = exports.pool:getElement("vehicle", tonumber(id))
- if (targetVehicle) then
- mysql:query_free("UPDATE vehicles SET speed="..speed..", power="..power.." WHERE id="..tonumber(id))
- mysql:query_free("UPDATE vehicles SET speed=NULL, power=NULL WHERE id="..dbid)
- outputChatBox("Transfered SpeedMod of "..speed.." Speed and "..power.." Power from vehicle ID "..dbid.." to vehicle "..id..".", thePlayer, 0, 255, 0)
- local ownerID = getElementData(veh, "owner")
- if tonumber(ownerID) > -1 then
- local findit = mysql:query("SELECT account FROM characters WHERE id="..tonumber(ownerID))
- local row3 = mysql:fetch_assoc(findit)
- if row3 then
- local userID = row3.account
- local query = mysql:query_free("UPDATE accounts SET credits=credits-1 WHERE id="..tonumber(userID))
- for k, v in ipairs(getElementsByType("player")) do
- if (getElementData(v, "account:character:id") == ownerID) then
- local query2 = mysql:query("SELECT credits FROM accounts WHERE id ="..tonumber(userID))
- if query2 then
- local row2 = mysql:fetch_assoc(query2)
- if row2 then
- exports['anticheat-system']:changeProtectedElementDataEx(v, "account:credits", (tonumber(row.credits)))
- outputChatBox("1 vPoint taken for Transfer.", v, 0, 255, 0)
- outputChatBox("1 vPoint Successfully Taken from Vehicle Owner", thePlayer, 0, 255, 0)
- end
- mysql:free_result(query)
- end
- end
- end
- else
- outputChatBox("Error Taking vPoints. Remove it manually + tell kdog so he fix.", thePlayer, 255, 0, 0)
- end
- mysql:free_result(findit)
- else
- outputChatBox("Warning: VIP not automatically taken as this is a faction vehicle.", thePlayer, 255, 0, 0)
- end
- exports['vehicle-system']:reloadVehicle(tonumber(dbid))
- exports['vehicle-system']:reloadVehicle(tonumber(id))
- else
- outputChatBox("Cannot find a vehicle with that target ID", thePlayer, 255, 0, 0)
- end
- else
- outputChatBox("You can only transfer a speedmod from a vehicle that is speedmodded! Noob.", thePlayer, 255, 0, 0)
- end
- else
- outputChatBox("You're not in a vehicle.", thePlayer, 255, 0, 0)
- end
- end
- end
- end
- addCommandHandler("transferspeedmod", transferSpeedMod)
Advertisement
Add Comment
Please, Sign In to add comment