Hello, I am making a gamemode and I created a ConCommand BUT :
[b]If I put the ConCommand in shared.lua :[/b]
[CODE][ERROR] gamemodes/jeepwarz/gamemode/shared.lua:16: attempt to call field 'Create' (a nil value)
1. unknown - gamemodes/jeepwarz/gamemode/shared.lua:16
2. unknown - lua/includes/modules/concommand.lua:69
[/CODE]
[b]If I put the ConCommand in init.lua :[/b]
[CODE]Unknown command : "jw_jeep_spawn'[/CODE]
Here is the CMD if you need it :
[CODE]concommand.Add( "jw_jeep_spawn",function( ply,cmd,args )
if !ply:IsSuperAdmin() then
print( ply:Nick().." tried to spawn a Combat Jeep but he isn't a superadmin !" )
return end
if args[1]=="multi" then
jeep = ents.Create("combat_jeep1")
jeep:SetPos(ply:GetPos() + Vector(0,100,0))
jeep:Spawn()
jeep:Activate()
print( ply:Nick().." spawned a Multi Combat Jeep !" )
elseif args[1]=="single" then
jeep = ents.Create("combat_jeep2")
jeep:SetPos(ply:GetPos() + Vector(0,100,0))
jeep:Spawn()
jeep:Activate()
print( ply:Nick().." spawned a Single Combat Jeep !" )
elseif args[1]=="double" then
jeep = ents.Create("combat_jeep3")
jeep:SetPos(ply:GetPos() + Vector(0,100,0))
jeep:Spawn()
jeep:Activate()
print( ply:Nick().." spawned a Double Combat Jeep !" )
end
end, nil, "This command simply spawn the desired Combat Jeep type near you." )[/CODE]
Are you running this code serverside?
[QUOTE]Are you running this code serverside? [/QUOTE]
I don't use it via the server console cause It can't work but I use it from my console when I am on the server.
[QUOTE=Dominator56;43496666]I don't use it via the server console cause It can't work but I use it from my console when I am on the server.[/QUOTE]
That's not what he was asking, put the console command into your init.lua. it should be working from there. Make sure you put it outside of any other function.
[QUOTE=Robotboy655;43496675]That's not what he was asking, put the console command into your init.lua. it should be working from there. Make sure you put it outside of any other function.[/QUOTE]
Okay,thanks, I gonna reload the server and try again. I'll see if it works.
Exactly what robot said. You put it in Shared. When a console command is shared; if the client types it, it's run on the client where ents.Create doesn't exist. When the rcon/server executes it, it's run on the server.
This should be server-side only. The client will still be able to execute it, but the command will be hidden ( won't show as autocomplete in the console )
Sorry, you need to Log In to post a reply to this thread.