Advertisement
Pewca

Untitled

Dec 22nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- autorun/server/sv_stuffed_printers.lua
  2.  function( size, person )
  3.     local npc = net.ReadEntity()
  4.     local cart = net.ReadTable()
  5.     local spawnPos, spawnAng = LocalToWorld( Vector( 25, 0, 25 ), Angle( 0, 0, 0 ), npc:GetPos(), npc:GetAngles() )
  6.     local totalCost = 0
  7.     local contains = {}
  8.  
  9.     for item, cost in pairs( cart ) do
  10.         for _, shopItem in pairs ( sp.config.shopItems ) do
  11.             if shopItem.class == item then
  12.                 if cost ~= shopItem.cost then
  13.                     person:Ban( 360, true )
  14.                     person:Kick( "Kicked for attempting to exploit Stuffed Printers" )
  15.                     return
  16.                 end
  17.             end
  18.         end
  19.     end
  20.  
  21.     for item, cost in pairs ( cart ) do
  22.         totalCost = totalCost + cost
  23.         contains[ #contains + 1 ] = item
  24.     end
  25.  
  26.     if totalCost == 0 then
  27.         return
  28.     end
  29.  
  30.     if totalCost <= person.DarkRPVars.money then
  31.         person:addMoney( -totalCost )
  32.         DarkRP.notify( person, 0, 4, "You have spent $" .. totalCost .. " on shopping!")
  33.         local p = ents.Create( "sp_shopping_pack" )
  34.         p:SetPos( spawnPos )
  35.         p:SetAngles( spawnAng )
  36.         p:Spawn()
  37.         p.contains = contains
  38.         p.dt.itemAmount = #p.contains
  39.         p.dt.owning_ent = person
  40.     else
  41.         person:SendLua( 'chat.AddText( "Nice try!' )
  42.     end
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement