#how to check if player has enough money (dark rp)
1 messages · Page 1 of 1 (latest)
Here's the code on init
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
include("shared.lua")
function ENT:Initialize()
self:SetModel( "models/props_c17/Lockers001a.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )
self:DropToFloor()
end
local weapon = nil
local pos, angle = nil
local price = 50
ENT.Once = false
function ENT:Use( ply, activator )
if self.Once then return end
activator:ConCommand("open_vending_machine")
self.Once = true
self:CreateWepon()
end
function ENT:CreateWepon()
self.Once = false
pos, angle = LocalToWorld( Vector( 0, 50, 5 ), Angle( 0, -90, 90 ), self:GetPos(), self:GetAngles())
local item = ents.Create("weapon_ak472")
item:SetPos( pos )
item:SetAngles( angle )
end
util.AddNetworkString("buy_weapon_ak472")
-- Función para soltar el AK-47
local function drop_object(selected_object)
local weapon = ents.Create(selected_object)
if IsValid(weapon) then
weapon:SetPos(pos)
weapon:Spawn()
end
end
net.Receive("buy_weapon_ak472", function(len, ply)
selected_object = "weapon_ak472"
drop_object(selected_object)
end)
And this is the one on the client
thanks daddy rusty