• Lua Gamemode Help (command disabling + icon drawing)
    20 replies, posted
Is there a way I can disable the use of certain console commands and noclip? I also need to know how to get icons to appear on the right side of the screen when certain flags on an object are set (with a 50 pixel space between eachother and the ends of the screen).
Set sv_cheats to 0. I believe you can also override engine concommands with lua alternatives that do nothing, or use cvar3 to add the FCVAR_CHEAT flag to the serverside version.
I would like to do the lua replacement, as I want to keep certain sv_cheats commands such as thirdperson (is there anyway to print text in the console when the command is typed?). But what about the icon part?
[QUOTE=NostalgicBird;52363469]I would like to do the lua replacement, as I want to keep certain sv_cheats commands such as thirdperson (is there anyway to print text in the console when the command is typed?). But what about the icon part?[/QUOTE] You can't just replace commands, unless they're added through [URL="http://wiki.garrysmod.com/page/concommand/Add"]concommand.Add[/URL]. If you want thirdperson in your gamemode you can make your own with a [URL="http://wiki.garrysmod.com/page/GM/CalcView"]CalcView[/URL] hook. For the icon part I'd take a look at [URL="http://wiki.garrysmod.com/page/Derma_Basic_Guide"]derma[/URL].
Can you disable commands?
[QUOTE=NostalgicBird;52363655]Can you disable commands?[/QUOTE] You can't do anything to commands added by the engine.
Can I set it so that sv_cheats is 0 by default.
[QUOTE=NostalgicBird;52367764]Can I set it so that sv_cheats is 0 by default.[/QUOTE] It is 0 by default.
Can only admins enable it? Also how do I disable noclip?
[QUOTE=NostalgicBird;52368022]Can only admins enable it? Also how do I disable noclip?[/QUOTE] People with access to the server can change it. sbox_noclip 0.
thanks! do you know how to do random playermodel selection (the game will choose a random Playermodels out of three).
Set the model in a PlayerSpawn hook to a random model from a table.
I tried that, this is the code I used (Note: these playermodels are nonexistant, I was expecting to see an error model, but it shows the HL2 thirdperson model [CODE] function GM:PlayerSetModel( ply ) playermodel_autochoose = { "bmb_player_01", "bmb_player_02", "bmb_player_03" } ply:SetModel( "models/bmb_player/table.Random( playermodel_autochoose ) ) end [/CODE] I put this in shared.lua, but i'll change it to init.lua
That's not valid syntax. Store the table as a local outside of the function, use PlayerSpawn (NOT PlayerSetModel), and choose a random model with its full path out of the table. Ex. [code]local tModels = {"models/blah.mdl", "models/blah/foo.mdl"} local iModelCount = #tModels -- In the hook/function pPlayer:SetModel(tModels[math.random(1, iModelCount)])[/code]
This is the code I put [CODE] local tModels = {"models/bmb_player/bmb_player_01", "models/bmb_player/bmb_player_02", "models/bmb_player/bmb_player_03"} local iModelCount = #tModels function GM:PlayerSpawn pPlayer:SetModel(tModels[math.random(1, iModelCount)]) end [/CODE]
You have two p's on line 5.
[QUOTE=MrGeekabit;52381225]You have two p's on line 5.[/QUOTE] that's code_gs's fault lol [editline]20th June 2017[/editline] still won't work
Player should be given as a parameter to GM:PlayerSpawn. The current code should give an error because Player doesn't exist in the current scope. Also remember even if you wanted to have a function with no parameters it still needs (). [CODE]local tModels = {"models/bmb_player/bmb_player_01", "models/bmb_player/bmb_player_02", "models/bmb_player/bmb_player_03"} local iModelCount = #tModels function GM:PlayerSpawn(Player) Player:SetModel(tModels[math.random(1, iModelCount)]) end[/CODE] [url]https://wiki.garrysmod.com/page/GM/PlayerSpawn[/url]
This doesn't have much to do with this, but I didn't think it deserves its own thread+I don't know what forum to put it in, but where is the Half-Life 2 icon located at
In root folder
You mean Steam/steamapps/common/Half-Life 2? I looked in there and it isn't there. [editline]20th June 2017[/editline] nvm found it
Sorry, you need to Log In to post a reply to this thread.