Some addons for my server

My Ideas

-Comment it(optional name)
A lua addon where people can say what they think about our server and give it a rating(0 - 5)
The addon will store the comments at a txt file on the computer or it can store it at the computer but only be readdable by addons in-game
-Donator Tools
Restrict some tools for donators(later tell me what you think about this)
-Hat Maker Changed (optional name)
A update for hat maker, the tool will save what hats you were wearing and the model you were using the last time you were on the server, and the editor menu should be also interactive (move your hats(set pitch, rool, yaw and offsets) with your mouse).And also the original hat maker have a bug, you set the offsets the way you like but when you finish editing the offsets don’t stay the way you set it to be.
-Admin Statue Prop(optional name)
A stool for admins that transform people into statues (just like the normal tool but works with players), wich ones will have writed at they head a big and flashing noob.
-Addons Download(optional name)
The player say !addons and a window open up showing wich addons the server have, the player can click on the addons to download them to his own addons folder(but only the admin allowed addons), after he finishes he have 2 options rejoin the server (retry) or a geral reload.This would solve lots of problems with addons.
-Anti-Lag(prop protection adaptation)
This addon will watch the ping of the players, if someone get a pingh higher then 400 it will warn the player to make his ping lower,in 40 seconds if he ping dont change too much the addon will delete all his props, if his ping still higher or near 350 the addon will kick the player.

PS:Sorry by the bad english and thank you by your attention, I’ll be so happy if you do my addons, if you do pleaze give me a little credtis for the idea ;D.
Edit:
Don’t let this thread die! :c

reply deleted due to avoid problems

bump

The addons download thing is impossible, and the lag kicker is useless since when a player has higher ping he would not cause any lag.

It’s not only a high ping kicker, if the guy have a high ping he will cause some lag, and the addon will see if he can avoid kicking him, he first try deleting his props,etc.

[editline]10:45PM[/editline]

Bump> high ping cause lag most of the times, generally caused by the long distance between the server and the client, by his not-fast pc, or because his not-fast internet, and it causes lag…

Stop bumping. People will get to it eventually.

And I’ll code what I can tonight. I gotta go eat dinner though.

Ok… thank you so much by your help, have a good dinner/night.

[lua]local chatcommands = {}
local function AddChatCommand(name,cmd) table.Insert(chatcommands,{name,cmd}) end

hook.Add(“PlayerSay”,“Chatcommands”,function(ply,text,toall)
if string.Left(text,2) == “**” then
local str = string.sub(text,3,string.len(text))
for _,v in ipairs(chatcommands) do if str == v[1] then
if type(v[2]) == “string” then ply:ConCommand(v[2]…" "…str) else v2 end
end
else return text end
end)

– Comment it!
function AddComment(str,ply)
if not file.Exists(“comments.txt”) then file.Write(“comments.txt”,"") end
file.Write(file.Read(“comments.txt”)…"""…str…"" - “…ply:Name()…”
")
end
AddChatCommand(“comment”,AddComment)

– Donator Tools
hook.Add(“PlayerLoadout”,“Donations”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
/* if ply:HasPriv(DONATOR) then – You need some way of checking donator; how?
ply:Give(“custom_wep1”)
ply:Give(“custom_wep2”)
ply:Give(“custom_wep3”)
end */
return true
end)

– Hat maker: Talk to the makers oF that, not me

– Admin statue: You’d have to turn people into ragdolls and do all that shit, I dunno how to at the moment

– Addon download: The menu with a list of addons you could do…

local function AddonMenu()
local frame = vgui.Create(“DFrame”)
frame:SetSize(200,600)
frame:Center()
frame:MakePopup()
frame:SetTitle(“Addon List”)

local list = vgui.Create("DListView",frame)
list:SetPos(10,30)
list:SetSize(frame:GetWide()-20,frame:GetTall()-50)
list:AddColumn("Addon Name")
for _,v in ipairs(GetAddonList()) do list:AddLine(v) end

end
concommand.Add(“addon_menu”,AddonMenu)
AddChatCommand(“addonmenu”,“addon_menu”)

– …but you can’t force someone to download addons in or out of game. Sorry.

– Anti lag
hook.Add(“Think”,“CheckPing”,function()
for _,v in ipairs(player.GetAll()) do
local int = v:GetNWInt(“HasWarned”)
if v:Ping() >= 400 and int == 0 then
v:ChatPrint(“You must lower your ping in 40 seconds or face the consequences.”)
v:SetNWInt(“HasWarned”,1)
timer.Simple(40,function() v:SetNWInt(“HasWarned”,2) end)
elseif v:Ping() >= 350 and int == 2 then
v:ChatPrint(“I said fix your ping or else!”)
v:ConCommand(“gmod_cleanup”)
timer.Simple(10,function() v:SetNWInt(“HasWarned”,3) end)
elseif v:Ping() >= 350 and int == 3 then
v:Kick()
end
end
end)
[/lua]

Something like that. That’d go in /autorun/server, I think.

–Coment it
How can I see the coments?
–Donator tool
You just check if the guy is a donator looking for his steam id in a txt file, if his steamid is not there hes not a donator…And how can I make the tools donator only?Only tell me where to put their name.
–Addon Menu
How to do that addon menu? I don’t know any lua sorry…And I wouldn’t be forcing them, they would double click the addon in the addon list menu then start dwnloading it.And yes I can force adding this command to the server.ini file inside the ulx/cfg folder ex: “addForcedDownload addons/wire2”.
Thank you ;D

Well people don’t ignore this thread thinking everything is done because is not, still needing help ;D (pleaze).
[editline]01:38AM[/editline]

how can the addon/coment window be open?
[editline]01:42AM[/editline]
I just asked hatmaker owned, waiting for answer.

>>>Well people don’t ignore this thread thinking everything is done because is not, still needing help ;D (pleaze),but only help if you want to, in other words im not ordering you to do my stuff, do it with love :3 lol.<<<<<<<

To see the comments, read the “comments.txt” file in the /data directory.
The donator thing: give me a bit.
The addon thing: the point is, you can’t do it. You can list the addons, but you can’t force a download. Sorry.

There’s no comment window at the moment. To use any of the commands, prefix the command with two asterisks (**). The commands are…

**comment <comment>
**addonmenu (or addon_menu in console)
Not sure if the addon menu will work though since it’s the /autorun/server.

[lua]-- Donator Tools
if not file.Exists(“donators.txt”) then file.Write(“donators.txt”) end
hook.Add(“PlayerLoadout”,“Donations”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
local donators = string.Explode("
",file.Read(“donators.txt”)
for _,v in ipairs(donators) do if v == ply:SteamID() then
ply:Give(“custom_wep1”)
ply:Give(“custom_wep2”)
ply:Give(“custom_wep3”)
end
return true
end)[/lua]

Put that in place of the donator thing. To make someone a donator, then add their steam ID to the donators.txt file.

Thank you alot!
Doubts:
I took a look at that donator lua codes with my non-coder eyes and my doubt is did you block any weapons for non-donators, where do I put the tools that I want to be donator only?
That donator.txt file is in the data folder?
Thanks again

[editline]02:20AM[/editline]

Things to do:
Hat Maker Adaptation(pleaze do 1 adaptation that will resist to the svn updates :slight_smile: )(waiting for owner answer)
Admin Statue
Addon download(make it possible to the client download the addons directly from the addons folder of the server to the client(you can try using the advanced dup download/upload option as a reference thats this is possible some way)
Thank you By your help

[editline]02:53AM[/editline]

I puted it at the autorun/server and it didn’t work, tryed autorun/client, same… What I did wrong? Even the console command works, I think the lua didn’t load.
This is my lua file
[lua]
local chatcommands = {}
local function AddChatCommand(name,cmd) table.Insert(chatcommands,{name,cmd}) end

hook.Add(“PlayerSay”,“Chatcommands”,function(ply,text,toall)
if string.Left(text,2) == “**” then
local str = string.sub(text,3,string.len(text))
for _,v in ipairs(chatcommands) do if str == v[1] then
if type(v[2]) == “string” then ply:ConCommand(v[2]…" "…str) else v2 end
end
else return text end
end)

– Comment it!
function AddComment(str,ply)
if not file.Exists(“comments.txt”) then file.Write(“comments.txt”,"") end
file.Write(file.Read(“comments.txt”)…"""…str…"" - “…ply:Name()…”
“)
end
AddChatCommand(”**comment",AddComment)

– Donator Tools
if not file.Exists(“donators.txt”) then file.Write(“donators.txt”) end
hook.Add(“PlayerLoadout”,“Donations”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
local donators = string.Explode("
",file.Read(“donators.txt”)
for _,v in ipairs(donators) do if v == ply:SteamID() then
ply:Give(“custom_wep1”)
ply:Give(“custom_wep2”)
ply:Give(“custom_wep3”)
end
return true
end)

– Hat maker: Talk to the makers oF that, not me

– Admin statue: You’d have to turn people into ragdolls and do all that shit, I dunno how to at the moment

– Addon download: The menu with a list of addons you could do…

local function AddonMenu()
local frame = vgui.Create(“DFrame”)
frame:SetSize(200,600)
frame:Center()
frame:MakePopup()
frame:SetTitle(“Addon List”)

local list = vgui.Create("DListView",frame)
list:SetPos(10,30)
list:SetSize(frame:GetWide()-20,frame:GetTall()-50)
list:AddColumn("Addon Name")
for _,v in ipairs(GetAddonList()) do list:AddLine(v) end

end
concommand.Add(“addon_menu”,AddonMenu)
AddChatCommand("**addonmenu",“addon_menu”)

– …but you can’t force someone to download addons in or out of game. Sorry.

– Anti lag
hook.Add(“Think”,“CheckPing”,function()
for _,v in ipairs(player.GetAll()) do
local int = v:GetNWInt(“HasWarned”)
if v:Ping() >= 400 and int == 0 then
v:ChatPrint(“You must lower your ping in 40 seconds or face the consequences.”)
v:SetNWInt(“HasWarned”,1)
timer.Simple(40,function() v:SetNWInt(“HasWarned”,2) end)
elseif v:Ping() >= 350 and int == 2 then
v:ChatPrint(“I said fix your ping or else!”)
v:ConCommand(“gmod_cleanup”)
timer.Simple(10,function() v:SetNWInt(“HasWarned”,3) end)
elseif v:Ping() >= 350 and int == 3 then
v:Kick()
end
end
end)
[/lua]
Obs: Can I change the “**” to “!” ?

[editline]03:23AM[/editline]

I think it didn’t work cuz i name it mystuff.lua, how should it be named?

A few things:

  1. I can’t access Gmod for various reasons, so I’m relying on you to be able to tell me when something doesn’t work. To do this, type this in console:
    lua_openscript autorun/server/file.lua
    …except replace file.lua with the filename and use rcon if it’s a dedicated server. This shoud return an error of sort. If not, well, we’ll go from there.

  2. To change the chatcommand operator, look to the top of the code and find where it says “if string.Left(text,2) == “**” then”. Replace that with:
    if string.Left(text,1) == “!” then

Also, the whole menu thing isn’t going to work in /autorun/server, so you’d have to put the addon list in a new file in the /autorun/client.

[lua]-- Donator Tools
local donatorweps = {
“weapon_smg1”,
“weapon_frag”,
“weapon_shotgun”,
}

local donatortools = {
“igniter”,
“dynamite”,
“emitter”,
“wire_explosive”,
“wire_igniter”,
}

local function FindByName(str) for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),str) then return v end end end

if not file.Exists(“donators.txt”) then file.Write(“donators.txt”) end
hook.Add(“PlayerLoadout”,“DonationsWep”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
local donators = string.Explode("
“,file.Read(“donators.txt”)
for _,v in ipairs(donators) do if v == ply:SteamID() then
for _,q in ipairs(donatorweps) do v:Give(q) end
end end
return true
end)
hook.Add(“CanTool”,“DonationsTool”,function(ply,tr,tool)
for _,v in ipairs(donatortools) do if tool == v then
local donators = string.Explode(”
“,file.Read(“donators.txt”)
for _,q in ipairs(donators) do if ply:SteamID() == q then return true
else ply:ChatPrint(“You must be a donator to use this weapon.”) return false end
end
end
return true
end)
AddChatCommand(“donator”,function(str,ply) file.Write(“donators.txt”,file.Read(“donators.txt”)…FindByName(str):Name()…”
") end)[/lua]

To edit this, you’re going to edit donatortools or donatorweps. Any weapons you put in donatorweps are additional weapons they will get on spawn. Any tools you put in donatortools are restricted for everyone but donators.

Also, to add a donator, use ! or **donator <name> to add adonator.

EDIT Ah, you made a mistake. You misunderstand the code. When adding a chatcommand, you don’t include the prefix, as it already checks for that in the code.

So in summary, your /autroun/client/mystuff.lua file should look like this:
[lua]local chatcommands = {}
local function AddChatCommand(name,cmd) table.Insert(chatcommands,{name,cmd}) end

hook.Add(“PlayerSay”,“Chatcommands”,function(ply,text,toall)
if string.Left(text,2) == “**” then
local str = string.sub(text,3,string.len(text))
for _,v in ipairs(chatcommands) do if str == v[1] then
if type(v[2]) == “string” then ply:ConCommand(v[2]…" "…str) else v2 end
end
else return text end
end)

– Comment it!
function AddComment(str,ply)
if not file.Exists(“comments.txt”) then file.Write(“comments.txt”,"") end
file.Write(file.Read(“comments.txt”)…"""…str…"" - “…ply:Name()…”
")
end
AddChatCommand(“comment”,AddComment)

– Donator Tools
local donatorweps = {
“weapon_smg1”,
“weapon_frag”,
“weapon_shotgun”,
}

local donatortools = {
“igniter”,
“dynamite”,
“emitter”,
“wire_explosive”,
“wire_igniter”,
}

local function FindByName(str) for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),str) then return v end end end

if not file.Exists(“donators.txt”) then file.Write(“donators.txt”) end
hook.Add(“PlayerLoadout”,“DonationsWep”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
local donators = string.Explode("
“,file.Read(“donators.txt”)
for _,v in ipairs(donators) do if v == ply:SteamID() then
for _,q in ipairs(donatorweps) do v:Give(q) end
end end
return true
end)
hook.Add(“CanTool”,“DonationsTool”,function(ply,tr,tool)
for _,v in ipairs(donatortools) do if tool == v then
local donators = string.Explode(”
“,file.Read(“donators.txt”)
for _,q in ipairs(donators) do if ply:SteamID() == q then return true
else ply:ChatPrint(“You must be a donator to use this weapon.”) return false end
end
end
return true
end)
AddChatCommand(“donator”,function(str,ply) file.Write(“donators.txt”,file.Read(“donators.txt”)…FindByName(str):Name()…”
") end)

– Anti lag
hook.Add(“Think”,“CheckPing”,function()
for _,v in ipairs(player.GetAll()) do
local int = v:GetNWInt(“HasWarned”)
if v:Ping() >= 400 and int == 0 then
v:ChatPrint(“You must lower your ping in 40 seconds or face the consequences.”)
v:SetNWInt(“HasWarned”,1)
timer.Simple(40,function() v:SetNWInt(“HasWarned”,2) end)
elseif v:Ping() >= 350 and int == 2 then
v:ChatPrint(“I said fix your ping or else!”)
v:ConCommand(“gmod_cleanup”)
timer.Simple(10,function() v:SetNWInt(“HasWarned”,3) end)
elseif v:Ping() >= 350 and int == 3 then
v:Kick()
end
end
end)
[/lua]

Nice, repaired it, but when i try number 1 it says " 07/15/2009 - 02:30:49: Lua Error: autorun/server/mystuff.lua:10: ‘end’ expected (to close ‘for’ at line 7) near ‘else’
autorun/server/mystuff.lua:10: ‘end’ expected (to close ‘for’ at line 7) near ‘else’"
I think the same error happens when it runs with the server

[editline]07:39AM[/editline]

forgot to tell… still not working ^^

[lua]
local chatcommands = {}
local function AddChatCommand(name,cmd) table.Insert(chatcommands,{name,cmd}) end

hook.Add(“PlayerSay”,“Chatcommands”,function(ply,text,toall)
if string.Left(text,2) == “**” then
local str = string.sub(text,3,string.len(text))
for _,v in ipairs(chatcommands) do if str == v[1] then
if type(v[2]) == “string” then ply:ConCommand(v[2]…" "…str) else v2 end
end
else return text end
end
end)

– Comment it!
function AddComment(str,ply)
if not file.Exists(“comments.txt”) then file.Write(“comments.txt”,"") end
file.Write(file.Read(“comments.txt”)…"""…str…"" - “…ply:Name()…”
")
end
AddChatCommand(“comment”,AddComment)

– Donator Tools
local donatorweps = {
“weapon_smg1”,
“weapon_frag”,
“weapon_shotgun”,
}

local donatortools = {
“igniter”,
“dynamite”,
“emitter”,
“wire_explosive”,
“wire_igniter”,
}

local function FindByName(str) for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),str) then return v end end end

if not file.Exists(“donators.txt”) then file.Write(“donators.txt”) end
hook.Add(“PlayerLoadout”,“DonationsWep”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
local donators = string.Explode("
“,file.Read(“donators.txt”)
for _,v in ipairs(donators) do if v == ply:SteamID() then
for _,q in ipairs(donatorweps) do v:Give(q) end
end end
return true
end)
hook.Add(“CanTool”,“DonationsTool”,function(ply,tr,tool)
for _,v in ipairs(donatortools) do if tool == v then
local donators = string.Explode(”
“,file.Read(“donators.txt”)
for _,q in ipairs(donators) do if ply:SteamID() == q then return true
else ply:ChatPrint(“You must be a donator to use this weapon.”) return false end
end
end
return true
end)
AddChatCommand(“donator”,function(str,ply) file.Write(“donators.txt”,file.Read(“donators.txt”)…FindByName(str):Name()…”
") end)

– Anti lag
hook.Add(“Think”,“CheckPing”,function()
for _,v in ipairs(player.GetAll()) do
local int = v:GetNWInt(“HasWarned”)
if v:Ping() >= 400 and int == 0 then
v:ChatPrint(“You must lower your ping in 40 seconds or face the consequences.”)
v:SetNWInt(“HasWarned”,1)
timer.Simple(40,function() v:SetNWInt(“HasWarned”,2) end)
elseif v:Ping() >= 350 and int == 2 then
v:ChatPrint(“I said fix your ping or else!”)
v:ConCommand(“gmod_cleanup”)
timer.Simple(10,function() v:SetNWInt(“HasWarned”,3) end)
elseif v:Ping() >= 350 and int == 3 then
v:Kick()
end
end
end)

[/lua]

That should fix that error

[lua]local chatcommands = {}
local function AddChatCommand(name,cmd) table.Insert(chatcommands,{name,cmd}) end

hook.Add(“PlayerSay”,“Chatcommands”,function(ply,text,toall)
if string.Left(text,2) == “**” then
local str = string.sub(text,3,string.len(text))
for _,v in ipairs(chatcommands) do if str == v[1] then
if type(v[2]) == “string” then ply:ConCommand(v[2]…" "…str) else v2 end end
end
else return text end
end)

– Comment it!
function AddComment(str,ply)
if not file.Exists(“comments.txt”) then file.Write(“comments.txt”,"") end
file.Write(file.Read(“comments.txt”)…"""…str…"" - “…ply:Name()…”
")
end
AddChatCommand(“comment”,AddComment)

– Donator Tools
local donatorweps = {
“weapon_smg1”,
“weapon_frag”,
“weapon_shotgun”,
}

local donatortools = {
“igniter”,
“dynamite”,
“emitter”,
“wire_explosive”,
“wire_igniter”,
}

local function FindByName(str) for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),str) then return v end end end

if not file.Exists(“donators.txt”) then file.Write(“donators.txt”) end
hook.Add(“PlayerLoadout”,“DonationsWep”,function(ply)
ply:Give(“weapon_physgun”)
ply:Give(“weapon_physcannon”)
ply:Give(“gmod_tool”)
ply:Give(“gmod_camera”)
local donators = string.Explode("
“,file.Read(“donators.txt”)
for _,v in ipairs(donators) do if v == ply:SteamID() then
for _,q in ipairs(donatorweps) do v:Give(q) end
end end
return true
end)
hook.Add(“CanTool”,“DonationsTool”,function(ply,tr,tool)
for _,v in ipairs(donatortools) do if tool == v then
local donators = string.Explode(”
“,file.Read(“donators.txt”)
for _,q in ipairs(donators) do if ply:SteamID() == q then return true
else ply:ChatPrint(“You must be a donator to use this weapon.”) return false end
end
end
return true
end)
AddChatCommand(“donator”,function(str,ply) file.Write(“donators.txt”,file.Read(“donators.txt”)…FindByName(str):Name()…”
") end)

– Anti lag
hook.Add(“Think”,“CheckPing”,function()
for _,v in ipairs(player.GetAll()) do
local int = v:GetNWInt(“HasWarned”)
if v:Ping() >= 400 and int == 0 then
v:ChatPrint(“You must lower your ping in 40 seconds or face the consequences.”)
v:SetNWInt(“HasWarned”,1)
timer.Simple(40,function() v:SetNWInt(“HasWarned”,2) end)
elseif v:Ping() >= 350 and int == 2 then
v:ChatPrint(“I said fix your ping or else!”)
v:ConCommand(“gmod_cleanup”)
timer.Simple(10,function() v:SetNWInt(“HasWarned”,3) end)
elseif v:Ping() >= 350 and int == 3 then
v:Kick()
end
end
end)
[/lua]

You put the end in the wrong place, Fish.

Also, the code’s getting a little big to keep copypasting in the thread. Let’s use pastebin from now on.

Still not working : /, when i try to load the file from the console give the same error as before.
Pastebin for my actual lua file
http://pastebin.ca/1496093
Error when loading by console:
L 07/15/2009 - 15:57:16: Lua Error: autorun/server/almostover.lua:44: ‘)’ expected (to close ‘(’ at line 43) near ‘for’
autorun/server/almostover.lua:44: ‘)’ expected (to close ‘(’ at line 43) near ‘for’

http://pastebin.com/m34d1b5d2

Didn’t work yet
] lua_openscript autorun/server/almostover.lua
Running script autorun/server/almostover.lua…
L 07/15/2009 - 16:37:29: Lua Error: autorun/server/almostover.lua:52: ‘)’ expected (to close ‘(’ at line 51) near ‘for’
autorun/server/almostover.lua:52: ‘)’ expected (to close ‘(’ at line 51) near ‘for’

Oh yeah i forgot to ask, could you friendly make that the addon list addon(repetitive name lol) detects when the addon is svn and put beside it name [SVN]

http://pastebin.com/m49f660a9

And I don’t think you can detect whether it’s SVN, since you can’t read files outside of the /data directory.