Hello There i Made This Money Script But Emh How Do i Make an Hud That Shows my Amount of money
[Lua]
local pmeta = FindMetaTable("Player")
function pmeta:CanAfford( amount )
if ( self:GetNWInt("<span class="highlight">Money</span>") - math.floor(amount) < 0 ) then
return false
else
return true
end
end
function MoneyInitialSpawn( ply )
local <span class="highlight">Money</span> = "Money/" .. ply:UniqueID() .. ".txt"
if file.Exists( <span class="highlight">Money</span> ) then
ply:SetNWInt( "<span class="highlight">Money</span>", tonumber( file.Read( <span class="highlight">Money</span> ) ) )
else
file.Write( <span class="highlight">Money</span>, 0 )
end
end
hook.Add( "PlayerInitialSpawn", "MoneyInitialSpawn", MoneyInitialSpawn )
function pmeta:AddMoney( amount )
self:SetNWInt( "<span class="highlight">Money</span>", self:GetNWInt("<span class="highlight">Money</span>") + math.floor(amount or 0) )
file.Write( "Money/" .. self:UniqueID() .. ".txt" , self:GetNWInt("<span class="highlight">Money</span>") )
end
[/Lua]
To get the variable client side, do this:
[lua]
Money = LocalPlayer():GetNWInt("money")
[/lua]
Obviously you didn't make the script as it has [I]<span class="highlight">Money</span>[/I] all over it. Replace all instances of [I]<span class="highlight">Money</span>[/I] with [I]Money[/I].
What's this all about?"<span class="highlight">Money</span>". If you're trying to highlight the text then you're going about it the wrong way.
If that's the name of your networked variable then you need to properly escape your string.
[lua]strs = {"<span class=\"highlight\">Money</span>",
'<span class="highlight">Money</span>',
[[<span class="highlight">Money</span>]]}
assert(strs[1] == strs[2] and strs[2] == strs[3])[/lua]
[QUOTE=fishface60;19704784]What's this all about?"<span class="highlight">Money</span>". If you're trying to highlight the text then you're going about it the wrong way.
If that's the name of your networked variable then you need to properly escape your string.
[lua]strs = {"<span class=\"highlight\">Money</span>",
'<span class="highlight">Money</span>',
[[<span class="highlight">Money</span>]]}
assert(strs[1] == strs[2] and strs[2] == strs[3])[/lua][/QUOTE]
He didn't write it, he searched for it and copied it the wrong way.
Protip: When you search for code, change [URL="http://www.facepunch.com/showthread.php?t=495940&highlight=blah"]http://www.facepunch.com/showthread.php?t=495940&highlight=searchwords[/URL] to [URL]http://www.facepunch.com/showthread.php?t=495940&highlight=[/URL]
Sorry, you need to Log In to post a reply to this thread.