Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------------------
- Includes The Files Needed For This File To Run Correctly.
- ---------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------
- Gets the player's money.
- ---------------------------------------------------------------------------------------*/
- function GetMoney(ply)
- return ply:GetNWInt("Money")
- end
- /*---------------------------------------------------------------------------------------
- Sets the player's money.
- ---------------------------------------------------------------------------------------*/
- function SetMoney(ply, amount)
- ply:SetNWInt("Money", amount)
- end
- /*---------------------------------------------------------------------------------------
- Adds to the player's current money.
- ---------------------------------------------------------------------------------------*/
- function AddMoney(ply, amount)
- local current_money = ply:GetNWInt("Money")
- local mon = ply:GetNWInt("Money")
- ply:SetNWInt(current_money + amount)
- sql.Query("UPDATE player_data SET money = "..mon.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")
- end
- /*---------------------------------------------------------------------------------------
- Gives the player your looking at money.
- ---------------------------------------------------------------------------------------*/
- function GiveMoney(ply, text, public)
- local trace = ply:GetEyeTrace()
- local trace2 = ply:GetEyeTrace()
- local words = string.Explode(" ",text);
- local amount = tonumber(words[2]);
- if (string.sub(text, 1, 5) == "/give") then
- if ValidEntity(trace.Entity) and trace.Entity:IsPlayer() and trace.Entity:GetPos():Distance(ply:GetPos()) < 150 then
- AddMoney( ply, -1 * amount )
- AddMoney( trace.Entity, amount )
- ply:ChatPrint("You gave xxx player some money!")
- end
- end
- end
- hook.Add("PlayerSay", "/give", GiveMoney)
- /*---------------------------------------------------------------------------------------
- Saves the player's money.
- ---------------------------------------------------------------------------------------*/
- function SaveMoney(ply)
- local mon = ply:GetNWInt("Money")
- sql.Query("UPDATE player_data SET money = "..mon.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")
- end
Add Comment
Please, Sign In to add comment