#how to check if player has enough money (dark rp)

1 messages · Page 1 of 1 (latest)

echo basalt
#

Hi uh i wanted to know if somebody could help me to know if there is way to check the players money to know if they can buy a weapon after pressing a buttton?

#

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

deep trench
#
Player:canAfford(number amount)
echo basalt
#

thanks daddy rusty

deep trench
#

<3

#

make sure you only run it on serverside code