Am I putting these variables in the right function??
7 replies, posted
Hey I just need a pointer tell let me know if im putting the variables in the right functions. Thanks :) ( not 100% because of the Garrys Mod 13 changes )
[code]
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
function GM:PlayerSpawn( ply )
self.BaseClass:PlayerSpawn( ply )
ply:SetGravity ( 1 )
ply:SetMaxHealth( 100, true )
ply:SetWalkSpeed( 190 )
ply:SetRunSpeed ( 235 )
ply:SetTeam( 3 )
//Setting Team Models
if ply:Team() == 1 then
ply:SetModel("models/player/male03.mdl")
elseif ply:Team() == 2 then
ply:SetModel("models/player/male02.mdl")
elseif ply:Team() == 3 then
--Dont know what I want him to do?
end
//Evening Teams
local VTGG == math.random( 1, 2 )
if VTGG == 1 then
ply:SetTeam( 1 )
elseif VTGG == 2 then
ply:SetTeam( 2 )
end
GAN = team.NumPlayers ( 1 ) -- Do we need that long variable?
WHI = team.NumPlayers ( 2 ) -- Do we need that long variable?
if GAN > WHI them
ply:SetTeam( 2 )
elseif WHI > GAN
ply:SetTeam( 1 )
end
end
function GM:PlayerInitialSpawn( ply )
ply:PrintMessage( HUD_PRINTTALK, "Welcome, " .. ply:Name() .. "!" )
end
[/code]
And this is the init.lua
include( 'shared.lua' )
include( "shared.lua" ) ?
Your indents are fucked but as far as I can see everything looks good.
[QUOTE=Ducky3426;45809722]Your indents are fucked but as far as I can see everything looks good.[/QUOTE]
Why are my indents fucked :P I like organization :P
[editline]26th August 2014[/editline]
[QUOTE=bluebull107;45809714]include( 'shared.lua' )
include( "shared.lua" ) ?[/QUOTE]
Does it matter? I thought it really didnt yet i could be wrong :P
For the evening teams part there are some mistakes, I personally would group that check into one.
[CODE]local VTGG = math.random( 1, 2 )
local GAN = team.NumPlayers( 1 )
local WHI = team.NumPlayers( 2 )
if GAN > WHI then
ply:SetTeam( 2 )
elseif WHI > GAN then
ply:SetTeam( 1 )
elseif WHI == GAN then
ply:SetTeam( VTGG )
end[/CODE]
Take a look and if you don't get the differences just shout.
[QUOTE=goosey;45809754]For the evening teams part there are some mistakes, I personally would group that check into one.
[CODE]local VTGG = math.random( 1, 2 )
local GAN = team.NumPlayers( 1 )
local WHI = team.NumPlayers( 2 )
if GAN > WHI then
ply:SetTeam( 2 )
elseif WHI > GAN then
ply:SetTeam( 1 )
elseif WHI == GAN then
ply:SetTeam( VTGG )
end[/CODE]
Take a look and if you don't get the differences just shout.[/QUOTE]
So what im looking at if WHI = GAN then it will put it in another random team? I wanted to try and keep teams even. Unless your aware, then can you explain what the changes will do? :) Thanks for spotting that out tho :)
Here's an error from before: [QUOTE]local VTGG == math.random( 1, 2 )[/QUOTE]
If you're defining a variable it's a single '='.
The reason why I did that is, your script first puts people into randomly selected teams, then checks for imbalances and reassigns again. Whereas, in mine it checks for imbalances and if there is it will put you in the team with less, however if there isn't a stacked side it will randomly put you a team...
Ahh ok thats very useful :) thanks :) I understand your logic :) So just some im receiving it right. Lets do example. ( My code ) 1. Player Joins 2. Randomly puts in team. 3. Sees' if there is imbalances. 4. If so changes team......... ( Your code ) 1. Player Joins 2. Places team that is < than the other.
Sorry, you need to Log In to post a reply to this thread.