6 Replies - 882 Views - Last Post: 20 May 2009 - 04:40 PM Rate Topic: -----

#1 A208  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 19-May 09

Need help with LUA

Posted 19 May 2009 - 09:47 AM

In particular with LUA for a gamemode for the game Garrysmod, i will post the code when i get home right now im at school i was just wondering if anyone here knows much LUA that would be helpful
Is This A Good Question/Topic? 0
  • +

Replies To: Need help with LUA

#2 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: Need help with LUA

Posted 19 May 2009 - 12:11 PM

I know some, and might be able to help you out, but more likely then not KYA will be here and beat me up with his superior Lua knowledge. :P So the answer is yes, someone will probably be able to help you :)
Was This Post Helpful? 0
  • +
  • -

#3 A208  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 19-May 09

Re: Need help with LUA

Posted 19 May 2009 - 04:02 PM

ok thank you and the main problem of my gamemode for garrysmod is that for some reason the teams arnt loading and i know not everyone that understands normal lua will be able to help me with this but here it goes and i have a couple of problems heres the 1st

1st problem which probly causes the 2nd
the teams wont work when you look at team menu it show everyone on team Unassigned and since Friendly fire is off because this is a team deathmatch game mode noone can kill
 function GM:PlayerInitialSpawn(ply)
  if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED) then
	ply:SetTeam(TEAM_BLUE)
  else
	ply:SetTeam(TEAM_RED)
  end
  self.BaseClass:PlayerInitialSpawn(ply)
end
 
function GM:PlayerLoadout(ply)
  return
end



2nd problem
For some reason it does not want to print the part about changing teams on game join and the f4 doesnt work which f4=showspare2
 function GM:KeyPress(p, key) 
	if ( key == ShowSpare2 ) then 
		if ( p:Team( )== TEAM_BLUE ) then
		p:SetTeam( TEAM_RED )
		p:Kill( )
		p:PrintMessage(HUD_PRINTTALK,"you don't want to be in the Red team? Press 'F4' to be one again!"); -- eg: Aliens (blue)
		p:SprintEnable ()
		p:AddFrags(1)
		else
		p:SetTeam( TEAM_BLUE )
		p:Kill( )
		p:PrintMessage(HUD_PRINTTALK,"you don't want to be in the Blue team? Press 'F4' to be one again!"); -- eg: Predator(red)
		p:SprintDisable ()
		p:AddFrags(1)
		end
	end
	self.BaseClass:KeyPress(p, key)
end



Edit: this might also be where the teams problem comes from but i dont think so
TEAM_RED = 1
TEAM_BLUE = 2
team.SetUp(TEAM_RED, "Red Team", Color(255, 0, 0, 255)) -- RED TEAM, It appear in scores
team.SetUp(TEAM_BLUE, "Blue Team", Color(0, 0, 255, 255)) -- BLUE TEAM, It appear in scores

This post has been edited by A208: 19 May 2009 - 04:05 PM

Was This Post Helpful? 0
  • +
  • -

#4 Jubb  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 88
  • Joined: 06-May 09

Re: Need help with LUA

Posted 20 May 2009 - 08:30 AM

Are TEAM_RED and TEAM_BLUE still in scope when you use them to assign players to each team? Check if they're nil before doing the condition:

if team.NumPlayers(TEAM_BLUE) <= team.NumPlayers(TEAM_RED)

Was This Post Helpful? 0
  • +
  • -

#5 A208  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 19-May 09

Re: Need help with LUA

Posted 20 May 2009 - 09:54 AM

yes i think they are still in scope but i just thought it might be better if the 3rd code is in init.lua with the 1st code lol right now the 3rd part is in shared.lua


but my friend gave me an idea what if i change

TEAM_RED = 1
TEAM_BLUE = 2
team.SetUp(TEAM_RED, "Red Team", Color(255, 0, 0, 255)) -- RED TEAM, It appear in scores
team.SetUp(TEAM_BLUE, "Blue Team", Color(0, 0, 255, 255)) -- BLUE TEAM, It appear in scores 


to
 TEAM_RED = 1
TEAM_BLUE = 2
team.SetUp(1, "Red Team", Color(255, 0, 0, 255)) -- RED TEAM, It appear in scores
team.SetUp(2, "Blue Team", Color(0, 0, 255, 255)) -- BLUE TEAM, It appear in scores 


i changed the team.setup(team_red to 1 which is team red as you can see that might be better but i have no clue if it will work any comments on that idea?? maybe it might fix my prob but for now i cant test as once again i am at school

This post has been edited by A208: 20 May 2009 - 09:56 AM

Was This Post Helpful? 0
  • +
  • -

#6 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Need help with LUA

Posted 20 May 2009 - 10:09 AM

The problem here isn't really a familiarity with Lua, but with how Garry's Mod uses its scripts. Isn't there a wiki or knowledge base on it somewhere?
Was This Post Helpful? 1
  • +
  • -

#7 A208  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 19-May 09

Re: Need help with LUA

Posted 20 May 2009 - 04:40 PM

View PostKYA, on 20 May, 2009 - 09:09 AM, said:

The problem here isn't really a familiarity with Lua, but with how Garry's Mod uses its scripts. Isn't there a wiki or knowledge base on it somewhere?


Yes there is but really it is the most usless "Help" site i have ever seen to tell you the truth i think how garrys set up garrysmod to use its scripts is stupid as hell and look this is how it tells you to do it for teams which this is exactly how i did it (with some modification of corse)
 
function GM:CreateTeams()
 
	if ( !self.TeamBased ) then return end
 
	TEAM_USSR = 1
	team.SetUp( TEAM_USSR, "USSR/Russia", Color( 255, 0, 0, 255 ) )
	team.SetSpawnPoint( TEAM_USSR, "info_player_terrorist" )
 
	TEAM_USA = 2
	team.SetUp( TEAM_USA, "USA", Color( 0, 0, 255, 255 ) )
	team.SetSpawnPoint( TEAM_USA, "info_player_counterterrorist" )
 
end	
 


Edit: Omg im so stupid i never called the function for createteams..its always those stupid little things that mess me up :v:

This post has been edited by A208: 20 May 2009 - 04:42 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1