Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PLUGIN:Init()
- svr.AddFlag( "money" )
- self:Command( "money", self.Money, { FLAG_MONEY } )
- self:Hook( "player.connect", self.PlayerConnect )
- end
- function PLUGIN:Money( ply, args )
- if not args[1] then
- ply:Print("2^-------ZConomy-------")
- ply:Print("10^Your Balance: " .. self:GetMoney( ply ) .. " " .. svr.Config:GetString( "ZConomyCurrency" ))
- elseif args[1] then
- if args[1] == "pay" then
- if args[2] then
- if args[3] then
- local Amount = tonumber( args[3] )
- if Server.GetPlayer( args[2] ) then
- local ply2 = Server.GetPlayer( args[2] )
- local PlayerMoney = self:GetMoney( ply )
- local Player2Money = self:GetMoney( ply2 )
- if ply.Username == ply2.Username then
- ply:Print("4^You can't pay yourself.")
- else
- local NewPlayerMoney = PlayerMoney - Amount
- local NewPlayer2Money = Player2Money + Amount
- if PlayerMoney >= Amount then
- self:SetMoney( ply, NewPlayerMoney )
- self:SetMoney( ply2, NewPlayer2Money )
- ply:Print("2^-------ZConomy-------")
- ply:Print("10^You payed " .. Amount .. " " .. svr.Config:GetString( "ZConomyCurrency" ) .. " to " .. args[2])
- ply2:Print("2^-------ZConomy-------")
- ply2:Print("10^You got " .. Amount .. " " .. svr.Config:GetString( "ZConomyCurrency" ) .. " from " .. ply.Username)
- else
- ply:Print("4^You don't have that money!")
- end
- end
- else
- ply:Print("4^That Player doesnt exist or is offline.")
- end
- else
- ply:Print("4^Syntax: -/money pay <name> <amount> - Gives <amount> money to <name>.")
- end
- else
- ply:Print("4^Syntax: -/money pay <name> <amount> - Gives <amount> money to <name>.")
- end
- else
- ply:Print("4^Syntax: -/money - Shows your balance.")
- ply:Print("4^Syntax: -/money pay <name> <amount> - Gives <amount> money to <name>.")
- end
- else
- ply:Print("4^Syntax: -/money - Shows your balance.")
- ply:Print("4^Syntax: -/money pay <name> <amount> - Gives <amount> money to <name>.")
- end
- end
- function PLUGIN:SetMoney( ply, val )
- local data = svr.PlayerData( ply )
- data.Money = val
- svr.SetPlayerPData( ply, val )
- end
- function PLUGIN:GetMoney( ply )
- local data = svr.PlayerData( ply )
- return data.Money
- end
- function PLUGIN:PlayerConnect( ply )
- if (svr.Config:GetNumber( "ZConomyInstalled" ) ~= 1) then
- svr.Config:SetNumber( "ZConomyStartMoney", 500 )
- svr.Config:SetString( "ZConomyCurrency", "Dollars" )
- svr.Config:SetNumber( "ZConomyInstalled", 1 )
- return
- end
- if (svr.GetPlayerPDataN( ply, "ZConomyNoStartMoney" ) ~= 1) then
- svr.SetPlayerPData( ply, "ZConomyMoney", svr.Config:GetNumber( "ZConomyStartMoney" ) )
- svr.SetPlayerPData( ply, "ZConomyNoStartMoney", 1 )
- end
- local data = svr.PlayerData( ply )
- data.Money = svr.GetPlayerPDataN( ply, "ZConomyMoney" )
- end
- PLUGIN:FinishLoad()
Advertisement
Add Comment
Please, Sign In to add comment