looking for a script


(Rogan21) #1

Hello i’m looking for a lua script that automaticly adds to the clan members/admins the clan tag only when the members have their level does a script like this exist?if yes can you give me a link for that?Thanks in advance


(kyle26189) #2

Don’t know of anything with auto tag, but i made something real quick for you. I can’t test it to tell you if it works, but let me know :slight_smile: (make sure you edit clantag and minlevel

–[[
Auto Tag Lua made by Purple/DRiVJ
4-21-2015

version 0.1

]]

– Put your clan tag here with color codes.
clantag = “faketag”
– Your clans lowest ADMIN level.
minlevel = “3”

function et_InitGame(levelTime, randomSeed, restart)
et.RegisterModname(“AutoTag By Purple”)
end

function et_ClientBegin( clientNum )
local level = et.G_shrubbot_level(clientNum)
local name = et.Info_ValueForKey(et.trap_GetUserinfo(client), “name”)
if level >= minlevel then
if not string.find(name, “”…clantag…"") then
et.trap_SendConsoleCommand(et.EXEC_APPEND, “!rename “…clientNum…” “…clantag…””…name…"" )
end
end
end


(Rogan21) #3

Thanks i apreciate the help


(Rogan21) #4

also if there are more useful lua scripts for server just give me a link i’m interested in those scripts


(Rogan21) #5

i tested the autotag script nope something it’s not working corectly the erros says the following:
Lua API:et_ClientBegin error running lua script: [string “autotag.lua”]:20: bad argument #1 to ‘trap_GetUserinfo’ (number expected, got nil)


(kyle26189) #6

Ahh sorry about that was a mistake i overlooked anyways here is a working (i hope?) one.

Also take a look at LESM ( lua enhanced server mod) has a lot of nice features for servers and is compatible with most mods.
https://bitbucket.org/zelly/lua-enhanced-server-mod/wiki/Home

–[[
Auto Tag Lua made by Purple/DRiVJ
4-21-2015

version 0.2
changelog:
0.2: fixed small error

]]

– Put your clan tag here with color codes.
clantag = “faketag”
– Your clans lowest ADMIN level.
minlevel = “3”

function et_InitGame(levelTime, randomSeed, restart)
et.RegisterModname(“AutoTag 0.2 By Purple”)
end

function et_ClientBegin( clientNum )
local level = et.G_shrubbot_level(clientNum)
local name = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), “name”)
if level >= minlevel then
if not string.find(name, “”…clantag…"") then
et.trap_SendConsoleCommand(et.EXEC_APPEND, “!rename “…clientNum…” “…clantag…””…name…"" )
end
end
end


(Rogan21) #7

the script is loaded but won’t rename the members the error is
Lua API: et_ClientBegin error running lua script: [string “autotag.lua”]:23: attempt to compare string with number


(kyle26189) #8

i feel really stupid but remove the “” from minlevel

E.g should be minlevel = 3
not minelevel “3”
and i know this works because i went and got my server **** from my pc in states.


(Rogan21) #9

the script works but something is weird some member are named like .DMG|playername!rename or like .DMG|.DMG|.DMG| they told me that server renamed them like that


(stealth6) #10

I guess it’s because you’re clantag has a “.” in it which is a magic character. I took a stab at fixing it:


--[[
Auto Tag Lua made by Purple/DRi*VJ*
4-22-2015

version 0.3
changelog:
0.3:
removed unnecessary "
changed string.find to check for nil
escaped clantag
0.2: fixed small error

]]

-- Put your clan tag here with color codes.
clantag = "faketag"
-- Your clans lowest ADMIN level.
minlevel = 3

local matches =
{
	["^"] = "%^";
	["$"] = "%$";
	["("] = "%(";
	[")"] = "%)";
	["%"] = "%%";
	["."] = "%.";
	["["] = "%[";
	["]"] = "%]";
	["*"] = "%*";
	["+"] = "%+";
	["-"] = "%-";
	["?"] = "%?";
}

function escape_lua_pattern(s)
	return (s:gsub(".", matches))
end

function et_InitGame(levelTime, randomSeed, restart)
	et.RegisterModname("AutoTag By Purple")
	
	clantag = escape_lua_pattern(clantag)
end

function et_ClientBegin( clientNum )
	local level = et.G_shrubbot_level(clientNum)
	local name = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), "name")
	if level >= minlevel then
		if string.find(name, clantag) != nil then
			et.trap_SendConsoleCommand(et.EXEC_APPEND, "!rename "..clientNum.." "..clantag..name )
		end
	end
end


(Rogan21) #11

now it won’t load the script the error says the following line:
Lua API: syntax error during pre-compilation: [string “autotag.lua”]:50: ‘then’ expected near ‘!’


(kyle26189) #12

meh here just retarded mistakes guess i should stop trying to half ass everything. @ stealth you fixed my mistake instantly which was on string.find i used the variable like …clantag… should of just been clantag everything else in your script is non-needed + the expression =! is not valid in lua it would be ~= but nice try :smiley:

this one works i tried multiple names multiple colors and different tags including .$@&*! chars.
sorry for the sloppyness just tried to put it together real quick.

--[[
Auto Tag Lua made by Purple/DRi*VJ*
4-22-2015

version 0.3
changelog:
	0.2: fixed small error
	0.3 if not string.find had chat strings instead of the variable.. derp
		also added ^7 color code white after the tag just in case if the users name is white
		and the tag color codes are different it wont effect the clients name.

]]

-- Put your clan tag here with color codes.
clantag = ".DMG|"
-- Your clans lowest ADMIN level.
minlevel = 0

function et_InitGame(levelTime, randomSeed, restart)
	et.RegisterModname("AutoTag 0.3 By Purple")
end

function et_ClientBegin( clientNum )
local level = et.G_shrubbot_level(clientNum)
local name = et.Info_ValueForKey(et.trap_GetUserinfo(clientNum), "name")
	if level >= minlevel then
		if not string.find(name, clantag) then
			et.trap_SendConsoleCommand(et.EXEC_APPEND, "!rename "..clientNum.." "..clantag.."^7"..name.."" )
		end
	end
 end

(Rogan21) #13

still there is one thing that still bothers me,when clan members are connecting to the server with the name and both tag the server adds another tag.Can this be fixed?


(kyle26189) #14

This should be fixed as said i test many different names etc and it was not adding extra tags to me. thats what this “if not string.find(name, clantag) then” is for it checks to see if they have the clan tag in the name or not. if they dont it gives em it.