The folders can be setup in a number of ways, the only mandatory file is gamemode/init.lua
Everything else is included or AddCSLuaFile'd from that.
I don't think you understand what I mean by blank gamemode.
[url]https://github.com/FPtje/DarkRP[/url]
[QUOTE=>>;39540962][url]https://github.com/FPtje/DarkRP[/url][/QUOTE]
How is DarkRP a blank gamemode?
[QUOTE=jaooe;39540985]How is DarkRP a blank gamemode?[/QUOTE]
Use your [b]imagination[/b] to the remove the useless shit.
[QUOTE=Science;39540670]Thanks a tonne.
Has anyone else noticed the old wiki is down?
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html[/url][/QUOTE]
[url]http://maurits.tv/data/garrysmod/wiki.garrysmod.com/wiki.garrysmod.com/index4875.html[/url]
[QUOTE=jaooe;39540864]Can someone send me a link to a rar of a blank gamemode? So I can compare everything with what I've got?[/QUOTE]
Here, inside you will find BLANK_GAMEMODE_GMOD13
[url]http://www.garrysmod.org/downloads/?a=view&id=130522[/url]
[QUOTE=jaooe;39540890]I don't think you understand what I mean by blank gamemode.[/QUOTE]
[url]http://glua.me/bin/?path=/gamemodes/base[/url]
That's pretty much as blank as you get, everything should be based on base, or based on something that's based on base
[QUOTE=my_hat_stinks;39541095][url]http://glua.me/bin/?path=/gamemodes/base[/url]
That's pretty much as blank as you get, everything should be based on base, or based on something that's based on base[/QUOTE]
Yeah, I should have been more specific. I need a blank gamemode that derives from sandbox with the spawnmenu intact.
Cheers though guys, gonna look at the one from garrysmod.org now.
If you derive from Sandbox, the menu stays. It's basically putting functions you haven't created with existing game mode ones.
- snip -
How would I go through with adding custom chat commands that run console commands? What I was trying was completely wrong.
[CODE][lua]hook.Add("PlayerAuthed", "checkgroup", function(ply)
local id = ply:SteamID64()
http.Fetch("http://steamcommunity.com/groups/DeviatedGaming/memberslistxml/?xml=1", function(result, size) --Alternatively, use "http://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1"
if size > 0 then
for w in string.gmatch(result, "<steamID64>(%d+)</steamID64>") do
if w == id then
ULib.ucl.addUser( ply:SteamID(), {}, {}, "regular" )
end
end
end
end)
end)
[/lua][/CODE]
Found this code a buncha posts back, trying to get it to work but it doesn't seem to be updating playerstatus and assigning the user to the group. It worked at first, but it overrided any previous rank they had.
Hi,
I'm trying to prevent players from being able to use the act command in console. I have the following code in /lua/autorun/server/blockact.lua:
[code]
function GM:PlayerShouldAct( ply, actname, actid )
return false;
end
[/code]
But I get a really strange error:
[quote]
[ERROR] lua/autorun/server/blockact.lua:1: attempt to index global 'GM' (a nil value)
1. unknown - lua/autorun/server/blockact.lua:1
[/quote]
Any idea why this might be? AFAIK the GM metatable should ALWAYS be there. Using hook.Add doesn't give an error, but it also never calls the function. (Tested using print("test");)
Thanks!
GM is for gamemodes, before the gamemode finishes loading (when Initialize is called it becomes GAMEMODE). You're looking for..
[lua]hook.Add( "PlayerShouldAct", "no actin' foo", function( objPl, strAct, iAct ) return false; end );[/lua]
[QUOTE=Banana Lord.;39544056]GM is for gamemodes, before the gamemode finishes loading (when Initialize is called it becomes GAMEMODE). You're looking for..
[lua]hook.Add( "PlayerShouldAct", "no actin' foo", function( objPl, strAct, iAct ) return false; end );[/lua][/QUOTE]
Thanks, but like I said earlier, using hook.Add causes it to not be fired. The code you kindly provided does nothing, and changing it to
[lua]hook.Add( "PlayerShouldAct", "no actin' fool", function( objPl, strAct, iAct ) print("test"); return false; end );[/lua] results in no output to the console.
[QUOTE=jackg904;39543049]
Found this code a buncha posts back, trying to get it to work but it doesn't seem to be updating playerstatus and assigning the user to the group. It worked at first, but it overrided any previous rank they had.[/QUOTE]
IIRC it works but it overrides other usergroups? Or it stopped working entirely
[editline]10th February 2013[/editline]
[QUOTE=YoshieMaster;39544401]Thanks, but like I said earlier, using hook.Add causes it to not be fired. The code you kindly provided does nothing, and changing it to
[lua]hook.Add( "PlayerShouldAct", "no actin' fool", function( objPl, strAct, iAct ) print("test"); return false; end );[/lua] results in no output to the console.[/QUOTE]
Is it in a serverside script and are you sure the script is being ran?
Try adding print("this hook is running") above that line and restart the server; if it prints to the server console then we can explore other possible problems.
[QUOTE=>>;39544421]IIRC it works but it overrides other usergroups? Or it stopped working entirely
[editline]10th February 2013[/editline]
[/QUOTE]
It worked upon first server restart after installing it. It gave the title "regular" to all the users who were a part of the given group(Even those who were already part of a higher group, it overriding their prior group). Anyone who joined AFTER that though, didn't receive a rank whether they were part of the steamgroup or not.
[QUOTE=jackg904;39544609]It worked upon first server restart after installing it. It gave the title "regular" to all the users who were a part of the given group(Even those who were already part of a higher group, it overriding their prior group). Anyone who joined AFTER that though, didn't receive a rank whether they were part of the steamgroup or not.[/QUOTE]
Well the addUser function doesn't check permissions to see whose higher; you could alternatively add a similar line to this at the beginning of the hook
[lua]if ply:IsAdmin() or ply:IsSuperAdmin() or ply:IsUserGroup("moderator") then return; end[/lua]
that way it wouldn't do anything if the player was a higher rank
[QUOTE=>>;39544421] Is it in a serverside script and are you sure the script is being ran?[/QUOTE]
that's what I assume is happening here
I don't quite understand the PlayerSpawn hook... for example if I use
[lua]
function Something( ply )
ply:SetHealth(125)
end
hook.Add("PlayerSpawn", "Something", Something)[/lua]
This does nothing. However, if I do
[lua]
function GM:PlayerSpawn( ply )
ply:SetHealth(125)
end[/lua]
It will set the player's health to 125, but it does not spawn them with any of their SWEPs anymore?
[QUOTE=Gaming_Unlim;39545152]I don't quite understand the PlayerSpawn hook... for example if I use
[lua]
function Something( ply )
ply:SetHealth(125)
end
hook.Add("PlayerSpawn", "Something", Something)[/lua]
This does nothing. However, if I do
[lua]
function GM:PlayerSpawn( ply )
ply:SetHealth(125)
end[/lua]
It will set the player's health to 125, but it does not spawn them with any of their SWEPs anymore?[/QUOTE]
If I remember correctly, hooks are executed before gamemode functions. The base gamemode will most likely override the player's health back to 100.
If you're writing a gamemode, try this:
[code]function GM:PlayerSpawn( ply )
self.BaseClass.PlayerSpawn( self, ply )
ply:SetHealth( 125 )
end[/code]
If you're writing an addon, try this:
[code]local function PlayerSpawn( ply )
timer.Simple( 0, function() ply:SetHealth( 125 ) end )
end
hook.Add( "PlayerSpawn", "something", PlayerSpawn )[/code]
[QUOTE=thomasfn;39545860]
[lua]function GM:PlayerSpawn( ply )
self.BaseClass.PlayerSpawn( self, ply )
ply:SetHealth( 125 )
end[/lua]
If you're writing an addon, try this:
[lua]local function PlayerSpawn( ply )
timer.Simple( 0, function() ply:SetHealth( 125 ) end )
end
hook.Add( "PlayerSpawn", "something", PlayerSpawn )[/lua][/QUOTE]
Why is the setHealth method in a timer? Could you explain that to me?
[QUOTE=DoubleElite;39546118]Why is the setHealth method in a timer? Could you explain that to me?[/QUOTE]
Setting a timer to run in 0 seconds means it will run in the next frame. Since the base gamemode will SetHealth the player to 100 no matter what right after your hook runs, and there's no way to stop that, you can use a (slightly hacky) timer to run your SetHealth a frame later.
Hey guys I got a question for a script regarding attacking another player. How can I make a statement or check that only runs a certain part of the script for only the attacker and the victim. My goal is to run the script for only the players that are involved in the fight.
Don't know if this is a hard question, but thanks if you got a solution for me :D
I got a timer, that keeps erroring on me. I suck at timers to be honest, what is wrong with these?
[code]
timer.Create( "Reload_" .. self.Weapon:EntIndex(), 0.75, 9- self.Weapon:Clip1(), self.PerformReload, self)
timer.Destroy( "Reload_" .. self.Weapon:EntIndex())
[/code]
Thanks!
Is it at all possible in lua to auto-generate new variables? What I have in mind is that the code auto-generates a new variable every time you run a function and a variable is already present, e.g. if var1 exists create var2, if var2 exists create var3 and so on. This way it will procedurally create new variables without you having to manually create them.
[QUOTE=buu342;39547986]I got a timer, that keeps erroring on me. I suck at timers to be honest, what is wrong with these?
[code]
timer.Create( "Reload_" .. self.Weapon:EntIndex(), 0.75, 9- self.Weapon:Clip1(), self.PerformReload, self)
timer.Destroy( "Reload_" .. self.Weapon:EntIndex())
[/code]
Thanks![/QUOTE]
Give us the error man...
[QUOTE=buu342;39547986]I got a timer, that keeps erroring on me. I suck at timers to be honest, what is wrong with these?
[code]
timer.Create( "Reload_" .. self.Weapon:EntIndex(), 0.75, 9- self.Weapon:Clip1(), self.PerformReload, self)
timer.Destroy( "Reload_" .. self.Weapon:EntIndex())
[/code]
Thanks![/QUOTE]
Timers don't accept var-args anymore. Change your timers to:
[lua]
timer.Create( "Reload_" .. self.Weapon:EntIndex(), 0.75, 9- self.Weapon:Clip1(),function() self:PerformReload() end)
timer.Destroy( "Reload_" .. self.Weapon:EntIndex())
[/lua]
How does one make a new line in draw.WordBox() ? using \n will make space for a new line in the box, but it places the text in the 1st line
edit: also, I created a ClientConVar that i want to open a window when called (frame:MakePopup()) how would i do this?
Sorry, you need to Log In to post a reply to this thread.