Kdog549

Untitled

May 9th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. function transferSpeedMod( thePlayer, commandName, id)
  2. if exports.global:isPlayerLeadAdmin(thePlayer) then
  3. if not id then
  4. outputChatBox("SYNTAX: Get in the origin vehicle and use the ID of the vehicle you wish to send it to.", thePlayer, 255, 194, 14)
  5. outputChatBox("SYNTAX: /" .. commandName .. " [Send Mods to Vehicle ID]", thePlayer, 255, 194, 14)
  6. else
  7. local veh = getPedOccupiedVehicle( thePlayer )
  8. if veh then
  9. local dbid = getElementData(veh, "dbid")
  10. local result = mysql:query( "SELECT speed, power FROM vehicles WHERE id="..dbid )
  11. local row = mysql:fetch_assoc( result )
  12. local speed = tonumber(row['speed'])
  13. local power = tonumber(row['power'])
  14. if speed~=nil and power~=nil then
  15. local targetVehicle = exports.pool:getElement("vehicle", tonumber(id))
  16. if (targetVehicle) then
  17. mysql:query_free("UPDATE vehicles SET speed="..speed..", power="..power.." WHERE id="..tonumber(id))
  18. mysql:query_free("UPDATE vehicles SET speed=NULL, power=NULL WHERE id="..dbid)
  19. outputChatBox("Transfered SpeedMod of "..speed.." Speed and "..power.." Power from vehicle ID "..dbid.." to vehicle "..id..".", thePlayer, 0, 255, 0)
  20.  
  21. local ownerID = getElementData(veh, "owner")
  22. if tonumber(ownerID) > -1 then
  23. local findit = mysql:query("SELECT account FROM characters WHERE id="..tonumber(ownerID))
  24. local row3 = mysql:fetch_assoc(findit)
  25. if row3 then
  26. local userID = row3.account
  27. local query = mysql:query_free("UPDATE accounts SET credits=credits-1 WHERE id="..tonumber(userID))
  28. for k, v in ipairs(getElementsByType("player")) do
  29. if (getElementData(v, "account:character:id") == ownerID) then
  30. local query2 = mysql:query("SELECT credits FROM accounts WHERE id ="..tonumber(userID))
  31. if query2 then
  32. local row2 = mysql:fetch_assoc(query2)
  33. if row2 then
  34. exports['anticheat-system']:changeProtectedElementDataEx(v, "account:credits", (tonumber(row.credits)))
  35. outputChatBox("1 vPoint taken for Transfer.", v, 0, 255, 0)
  36. outputChatBox("1 vPoint Successfully Taken from Vehicle Owner", thePlayer, 0, 255, 0)
  37. end
  38. mysql:free_result(query)
  39. end
  40. end
  41. end
  42. else
  43. outputChatBox("Error Taking vPoints. Remove it manually + tell kdog so he fix.", thePlayer, 255, 0, 0)
  44. end
  45. mysql:free_result(findit)
  46. else
  47. outputChatBox("Warning: VIP not automatically taken as this is a faction vehicle.", thePlayer, 255, 0, 0)
  48. end
  49. exports['vehicle-system']:reloadVehicle(tonumber(dbid))
  50. exports['vehicle-system']:reloadVehicle(tonumber(id))
  51. else
  52. outputChatBox("Cannot find a vehicle with that target ID", thePlayer, 255, 0, 0)
  53. end
  54. else
  55. outputChatBox("You can only transfer a speedmod from a vehicle that is speedmodded! Noob.", thePlayer, 255, 0, 0)
  56. end
  57. else
  58. outputChatBox("You're not in a vehicle.", thePlayer, 255, 0, 0)
  59. end
  60. end
  61. end
  62. end
  63. addCommandHandler("transferspeedmod", transferSpeedMod)
Advertisement
Add Comment
Please, Sign In to add comment