• Hud question
    2 replies, posted
How would I put the the amount the player has on the hud? I've very new to Glua. [B]Here is the server side code.[/B] [lua] local Meta = FindMetaTable("Player"); // Money System ------------------------------------------------------- -- GLOBAL VARS ------------------------------------------------------- PDataTable = "Currency"; NWIntTable = "Money"; ------------------------------------------------------- -- PLAYER META ------------------------------------------------------- local Meta = FindMetaTable("Player"); -- pl:SetMoney( 3 ) function Meta:SetMoney( int ) self:SetPData( PDataTable, tonumber( int ) ); self:SetNWInt( NWIntTable, tonumber( int ) ) --print( "GCUR - Set " .. self:Nick() .. "'s money to " .. int .. "." ); end -- pl:GetMoney() function Meta:GetMoney() return self:GetPData( PDataTable ); end -- update the NWint here in a sec, function Meta:AddMoney( int ) self:SetPData( PDataTable, self:GetPData("Currency") + tonumber( int ) ); --print( "GCUR - added to " .. self:Nick() .. "'s money by " .. int .. "." ); end -- pl:TakeMoney( 2 ) function Meta:TakeMoney( int ) self:SetPData( PDataTable, self:GetPData("Currency") - tonumber( int ) ); --print( "GCUR - added to " .. self:Nick() .. "'s money by " .. int .. "." ); end -- pl:ResetMoney() function Meta:ResetMoney() self:SetPData( PDataTable, 0 ); self:SetNWInt( NWIntTable, 0 ) --print( "GCUR - set " .. self:Nick() .. "'s money to 0." ); end -- pl:RefreshMoney() function Meta:RefreshMoney() self:SetMoney( self:GetMoney() ) self:SetNWInt( NWIntTable, tonumber( self:GetMoney() ) ) --print( self:Nick() .. "'s money was refreshed." ) end ------------------------------------------------------- -- CONSOLE COMMANDS ------------------------------------------------------- concommand.Add("gc_SetMoney", function( pl, cmd, args ) pl:SetMoney( args[1] ) end) concommand.Add("gc_GetMoney", function( pl ) print( "GetMoney Called : " .. pl:GetMoney() ) end) concommand.Add("gc_AddMoney", function( pl, cmd, args ) pl:AddMoney( args[1] ) end) concommand.Add("gc_TakeMoney", function( pl, cmd, args ) pl:TakeMoney( args[1] ) end) concommand.Add("gc_RefreshMoney", function( pl ) pl:RefreshMoney() end) concommand.Add("gc_ResetMoney", function( pl ) pl:ResetMoney() end) concommand.Add("gc_PrintCCs", function( pl, cmd, args ) print("GCURRENCY CONCOMMANDS LIST:"); print("Command Prefix: gc_"); print("Command Format: command[ args[1], args[2], args[3], args[4], etc.]"); print("SetMoney[ amount ]"); print("GetMoney[ none ]"); print("AddMoney[ amount ]"); print("TakeMoney[ amount ]"); print("RefreshMoney[ none ]"); print("ResetMoney[ none ]"); print("PrintCCs[ none ]"); end) [/lua]
[lua]hook.Add("HUDPaint","DrawMyMoney",function() draw.DrawText( LocalPlayer():GetNWInt( "Money" ), "ScoreboardText", ScrW() - 20, ScrH() - 20, color_white, 2 ) end)[/lua] Basic example.
[QUOTE=Entoros;25233811][lua]hook.Add("HUDPaint","DrawMyMoney",function() draw.DrawText( LocalPlayer():GetNWInt( "Money" ), "ScoreboardText", ScrW() - 20, ScrH() - 20, color_white, 2 ) end)[/lua] Basic example.[/QUOTE] Thanks for the fast rply and yes it worked perfectly Thank you
Sorry, you need to Log In to post a reply to this thread.