Problems using player.concommand ("ETC")

Hello, I seem to be having trouble using the player.concommand( “” ) here is what it says:

gamemodes\laststand\gamemode\init.lua:25: ‘=’ expected near ‘player’-init
–player.concommand( “PlayerInitialGear” )


gamemodes\laststand\gamemode\cl_init.lua:21: ‘then’ expected near ‘player’
-cl_init
–player.ConCommand( “sb_team1” )


Any idea what is wrong?

There’s no such function as player.concommand or player.ConCommand.

http://wiki.garrysmod.com/?title=Player.ConCommand ?

If not this how else should i run a console command?

You understood the wiki wrong.

The Player. is refering to the player metatable.

Its a object oriented function means this function can be used on any player.

Its used like Player:ConCommand(string)

Im still getting the same warnings. I am using the same code, but with : instead of .

What’s wrong?

[lua]RunConsoleCommand(“command”, “arg1”, “etc”)[/lua]

How would the arg affect it? Would it cause the errors? If so, how can I put in a value that won’t conflict with a command such as this:

function GM:PlayerLoadout( ply )
ply:Give( “weapon_crowbar” )

	end 
	concommand.add( "PlayerInitialGear", GM:PlayerLoadout )

I’m not using this function now, as it can be more easily done by the give command, but i have many more such as:

function sb_team1( ply )

ply:UnSpectate() 
ply:SetTeam( 1 ) 
ply:Spawn() Unused ATM
ply:PrintMessage( HUD_PRINTTALK, "[Ravenous Dead] Welcome," .. ply:Nick().. "can you survive the horde?" ) 

end

concommand.Add( “sb_team1”, sb_team1 )

RunConsoleCommand runs a console command, so if you wanted to do that player loadout thing, you would do
[lua]RunConsoleCommand(“PlayerInitialGear”)[/lua]
The additional arguments in my example just run the command with arguments. The one in my post would be as if you typed


command arg1 etc

into the console.

Ah, well that solved my problem, so onto the next:

The console keeps saying “Function argument expected at line 122 near the ‘)’”

Heres the code:

function GM:ZombieSpawn( tr ) 


local spawns = ents.FindByClass( "Zombie_Spawn_Point" ) 
 local random = math.random(#spawns)   

local ent = ents.Create( “npc_zombie” )
ent:SetPos( tr.HitPos )
ent:Spawn()
ent:Activate()

end

concommand.Add(“ZombieSpawn”, GM:ZombieSpawn) — Line 122

timer.Create( “ZombieSpawnTimer1”, 10, 0, function( ply )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
end )

Any ideas?

concommand.Add(“ZombieSpawn”, GM:ZombieSpawn)

the : can only be used when you’re calling metafunctions. Changing it to GM.ZombieSpawn will make it work.

This seems to work, thanks.

[lua]
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
player:concommand( “ZombieSpawn” )
[/lua]

Lua is case sensitive, so “concommand” ~= “ConCommand”