How do i get this down
i already have some code but theres errors with them dont know the problem
sh_player.lua
[CODE]include( 'sh_player.lua' )
AddCSLuaFile( "sh_player.lua" )
local meta = FindMetaTable("Player") --Get the meta table of player
function meta:AddMoney(amount)
local current_cash = self:GetMoney()
self:SetMoney( current_cash + amount )
end
function meta:SetMoney(amount)
self:SetNetworkedInt( "Money", amount )
self:SaveMoney()
end
function meta:SaveMoney()
local cash = self:GetMoney()
self:SetPData("money", cash)
end
function meta:SaveMoneyTXT()
file.Write(gmod.GetGamemode().Name .."/Money/".. string.gsub(self:SteamID(), ":", "_") ..".txt", self:GetMoneyString())
end
function meta:TakeMoney(amount)
--Add money function here
self:AddMoney(-amount)
end
function meta:GetMoney()
return self:GetNetworkedInt( "Money" )
end[/CODE]
it crashes my game
[CODE]function GM:PlayerShouldTakeDamage( victim, pl )
if pl:IsPlayer() then -- check the attacker is player
if( pl:Team() == victim:Team() and GetConVarNumber( "mp_friendlyfire" ) == 0 ) then -- check the teams are equal and that friendly fire is off.
return false -- do not damage the player
end
end
return true -- damage the player
end
MONEY_STARTAMOUNT = 1000 --Can be changed to your starting amount
function FirstSpawn( ply )
local cash = ply:GetPData("money") --Get the saved money amount
if cash == nil then --If it doesn't exist supply the player with the starting money amount
ply:SetPData("money", MONEY_STARTAMOUNT) --Save it
ply:SetMoney( MONEY_STARTAMOUNT ) --Set it to the networked ints that can be called from the client too
else
ply:SetMoney( cash ) --If not, set the networked ints to what we last saved
end
end
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )
function PrintCash( ply )
ply:ChatPrint("Your cash is: " .. ply:GetMoney())
end
function fPlayerDisconnect( ply )
print("Player Disconnect: Money saved to SQLLite and TXT")
ply:SaveMoney()
ply:SaveMoneyTXT()
end
concommand.Add("cash_get",PrintCash)[/CODE]
[editline]24th July 2014[/editline]
sorry wrong place
Sorry, you need to Log In to post a reply to this thread.