Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- autorun/server/sv_stuffed_printers.lua
- 'sp_purchaseFromNpc', function( size, person )
- local npc = net.ReadEntity()
- local cart = net.ReadTable()
- local spawnPos, spawnAng = LocalToWorld( Vector( 25, 0, 25 ), Angle( 0, 0, 0 ), npc:GetPos(), npc:GetAngles() )
- local totalCost = 0
- local contains = {}
- for item, cost in pairs( cart ) do
- for _, shopItem in pairs ( sp.config.shopItems ) do
- if shopItem.class == item then
- if cost ~= shopItem.cost then
- person:Ban( 360, true )
- person:Kick( "Kicked for attempting to exploit Stuffed Printers" )
- return
- end
- end
- end
- end
- for item, cost in pairs ( cart ) do
- totalCost = totalCost + cost
- contains[ #contains + 1 ] = item
- end
- if totalCost == 0 then
- return
- end
- if totalCost <= person.DarkRPVars.money then
- person:addMoney( -totalCost )
- DarkRP.notify( person, 0, 4, "You have spent $" .. totalCost .. " on shopping!")
- local p = ents.Create( "sp_shopping_pack" )
- p:SetPos( spawnPos )
- p:SetAngles( spawnAng )
- p:Spawn()
- p.contains = contains
- p.dt.itemAmount = #p.contains
- p.dt.owning_ent = person
- else
- person:SendLua( 'chat.AddText( "Nice try!' )
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement