Hey,
This is in my shared.lua
[QUOTE]timer.Create("TeamChosing", 10, 1,TCeamT, ply)[/QUOTE]
This is in my init.lua
[QUOTE]function TCeamT(ply)
local TeamChosing = math.random( 1, 2 )
if TeamChosing == 1 then
ply:SetTeam( 1 )
elseif TeamChosing == 2 then
ply:SetTeam( 2 )
end
CIVS = team.NumPlayers( 1 )
COPS = team.NumPlayers( 2 )
if CIVS > COPS then
ply:SetTeam( 1 )
end
ply:GodDisable()
timer.pause("TCeamT")
end [/QUOTE]
And i get Error Bad Argument #4
[url=http://wiki.garrysmod.com/page/timer/Create]Timers don't work like that anymore[/url], you can't pass additional arguments to the function. Change the shared.lua line to:
[code]
timer.Create("TeamChosing", 10, 1, function() TCeamT(ply) end)
[/code]
Ok thanks.
How can i make a value + / - one?
Like this:
[QUOTE]
shared.lua
ActualPlayers = 0;
init.lua
function GM:PlayerDeath( Victim, Inflictor, Attacker )
ActualPlayers - 1 // This gave me the Error
if ActualPlayers == 1 then
for i=1, MaxPlayers do
ActualPlayers = 0
Msg(""..Attacker.." hat "..Victim.." getötet und damit die Runde gewonnen!")
end
end
Victim:AddDeaths( 1 )
end
[/QUOTE]
[code]
function GM:PlayerDeath( Victim, Inflictor, Attacker )
ActualPlayers = ActualPlayers - 1
if ActualPlayers == 1 then
for i=1, MaxPlayers do
ActualPlayers = 0
Msg("%s hat %s getötet und damit die Runde gewonnen!\n", tostring(Attacker), tostring(Victim))
end
end
Victim:AddDeaths( 1 )
end
[/code]
Also use [noparse][code]...code...[/code][/noparse] tags to put your code in, or use this button:
[img]http://i.imgur.com/J5Xzyrc.png[/img]
Thank you very much :)
(Are you german, you write my Death Code in German and right "positions" of grammar)
[editline]26th December 2013[/editline]
Well... @Ronny: Next Error :(
[code]
[ERROR] gamemodes/cnr/gamemode/init.lua:68: attempt to index local 'ply' (a nil value)
function GM:PlayerLoadout( ply )
ply:StripWeapons()
ply:GodEnable()
ply:SetGravity( 1 )
ply:SetWalkSpeed ( 300 )
ply:SetRunSpeed ( 500 )
ply:SetTeam ( 0 )
ActualPlayers = ActualPlayers + 1
if ActualPlayers == 2 then
timer.Start("TCeamT")
end
end
function TCeamT(ply)
local TeamMaker = math.random( 1, 2 )
ply:SetTeam( TeamMaker )
end
CIVS = team.NumPlayers( 1 )
COPS = team.NumPlayers( 2 )
if CIVS > COPS then
ply:SetTeam( 1 )
end
ply:GodDisable()
timer.pause("TCeamT")
end
[/code]
No, I'm not German. Also, I'm not going to solve every error for you, if you're going to attempt to write code yourself you can't ask someone else to fix every bug. I'd recommend you use the wiki and learn how to code in lua first.
Well, thanks i fixed it myself.
Sorry, you need to Log In to post a reply to this thread.