Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.93 KB | None | 0 0
  1. ----------------------
  2. -- Header / Prework --
  3. ----------------------
  4.  
  5. ESX = nil
  6. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  7.  
  8. ------------------------
  9. -- Usage and Provides --
  10. ------------------------
  11.  
  12. -- This script provides the following Commands in-game:
  13. -- /invoiceid     <PlayerID> <Amount>
  14. -- /seizeid       <PlayerID> <Amount>
  15. -- /invoiceplayer <Amount>
  16. --
  17. -- /invoiceplayer is proximity based, so you have to be very careful when using it.
  18.  
  19. --------------------------
  20. -- Todo for this script --
  21. --------------------------
  22.  
  23. -- Ensure that the Player doesn't fine themselves
  24. -- Ensure that in all instances where the user inputs an ID, that person exists
  25.  
  26.  
  27. ----------
  28. -- Main --
  29. ----------
  30.  
  31. -- /invoiceid <PlayerID> <Amount>
  32. RegisterCommand('invoiceid', function(source, args)
  33.  
  34.     local src = source
  35.  
  36.     -- Get our fine amount from the parameter inputs
  37.     local amount   = tonumber(args[2])
  38.     local playerID = tonumber(args[1])
  39.     local verbose  = args[3]
  40.     local xGiver   = ESX.GetPlayerFromId(src)
  41.     local xPlayer  = ESX.GetPlayerFromId(playerID)
  42.  
  43.    
  44.    --                                              --
  45.    -- Debugging section to print out all values    --
  46.    --                                              --
  47.     if verbose == 'debug' then
  48.       print("Debug amount: "           .. amount)
  49.       print("Debug PlayerID: "         .. playerID)
  50.       print("Debug src: "              .. src)
  51.       print("Debug xPlayer: " .. inspect(xPlayer))
  52.       print("Debug playerID (getPlayerFromServerID): " .. ESX.GetPlayerFromServerId(playerID))
  53.       print("Debug playerID (GetPlayerServerId): " .. ESX.GetPlayerServerId(playerID))
  54.       print("Debug xPlayer (getPlayerFromServerID): " .. ESX.GetPlayerFromServerId(xPlayer))
  55.       print("Debug xPlayer (GetPlayerServerId): " .. ESX.GetPlayerServerId(xPlayer))
  56.     end
  57.  
  58.     -- Let's make sure the person running /fineid is a police officer
  59.     -- Debug: Trying GetPlayerFromServerId, GetPlayerServerId,  getPlayerID
  60.     if xGiver.job.name == 'police' then
  61.         if amount ~= nil then
  62.             TriggerClientEvent('mythic_notify:client:SendAlert', src,     { type = 'inform', text = 'You have fined ID - [' .. playerID .. '] for $' .. amount .. '.' })
  63.             TriggerClientEvent('mythic_notify:client:SendAlert', playerID, { type = 'inform', text = 'You have been sent a Fine for $' .. amount .. '.'})
  64.             TriggerClientEvent('prp-fineid:Anim', src)
  65.             TriggerServerEvent('esx_billing:sendBill', playerID, 'society_police', 'Police Fine', amount)
  66.         end
  67.     end
  68. end)
  69.  
  70.  
  71. -- /seizeid <PlayerID> <Amount>
  72. -- (Takes directly from the player bank!)
  73. RegisterCommand('seizeid', function(source, args)
  74.  
  75.     local src = source
  76.  
  77.     -- Get our fine amount from the parameter inputs
  78.     local amount   = tonumber(args[2])
  79.     local playerID = tonumber(args[1])
  80.     local verbose  = args[3]
  81.     local xGiver   = ESX.GetPlayerFromId(src)
  82.     local xPlayer  = ESX.GetPlayerFromId(playerID)
  83.  
  84.    --                                              --
  85.    -- Debugging section to print out all values    --
  86.    --                                              --
  87.     if verbose == 'debug' then
  88.       print("Debug amount: "   .. amount)
  89.       print("Debug PlayerID: " .. playerID)
  90.       print("Debug src: "      .. src)
  91.     end
  92.  
  93.     -- Let's make sure the person running /fineid is a police officer
  94.     if xGiver.job.name == 'police' then
  95.         if amount ~= nil then
  96.             TriggerClientEvent('mythic_notify:client:SendAlert', src,     { type = 'inform', text = 'You have seized ID - [' .. playerID .. '] for $' .. amount .. '.' })
  97.             TriggerClientEvent('mythic_notify:client:SendAlert', playerID, { type = 'inform', text = 'Your money has been seized by the DOJ: $' .. amount .. '.'})
  98.             TriggerClientEvent('prp-fineid:Anim', src)
  99.             xPlayer.removeAccountMoney('bank', amount)
  100.         end
  101.     end
  102. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement