• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Codenames to replace names on GM broadcasts

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
629
Location
Canada
Ello ello!
I was wondering if, so people don't know which Gamemasters are online, I could set up some sort of script with codenames (For example, since my server is called Avenged Eternity, I figured I'd call staff members the Eternity Team... So I would use a codename like E14 or ET36 or something along those lines...) I want to make it so when a Gamemaster broadcasts, it'd say something like "18:32 ET9: Hello everyone, ..." instead of something like "18:32 GM Monkeysworth: Hello everyone, ..."
If scripted, I would want to be able to make a list of Gamemasters and put in the codename they choose or I choose for them. If this would be possible, could someone help me out? ;D <3

RazorBlade
 
Execute this query in your database:
Code:
ALTER TABLE `players` ADD `code_name` VARCHAR( 32 ) NOT NULL;

Change broadcast.lua to this:

LUA:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end

	codeNameTemp = db.getResult("SELECT `code_name` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";")
	local codeName = codeNameTemp:getDataInt("code_name")
	
	if codeName ~= '' then
		doBroadcastMessage(codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED)
	else
		doPlayerBroadcastMessage(cid, param)
	end

	return true
end

Untested though, tell me if it works :P
 
Execute this query in your database:
Code:
ALTER TABLE `players` ADD `code_name` VARCHAR( 32 ) NOT NULL;

Change broadcast.lua to this:

LUA:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end

	codeNameTemp = db.getResult("SELECT `code_name` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";")
	local codeName = codeNameTemp:getDataInt("code_name")
	
	if codeName ~= '' then
		doBroadcastMessage(codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED)
	else
		doPlayerBroadcastMessage(cid, param)
	end

	return true
end

Untested though, tell me if it works :P
he wants it to give the time also, so;
Code:
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED)
also, why not query in the talkaction? ;d
Code:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end
	codeNameTemp = db.getResult("SELECT `code_name` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";")
	local codeName = codeNameTemp:getDataInt("code_name")
	if getGlobalStorageValue(45245) == -1 then db.executeQuery("ALTER TABLE `players` ADD `code_name` VARCHAR( 32 ) NOT NULL;") setGlobalStorageValue(45245, 1) end
	if codeName ~= '' then
		doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED
	else
		doPlayerBroadcastMessage(cid, param)
	end
	return true
end
 
he wants it to give the time also, so;
Code:
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED)
also, why not query in the talkaction? ;d
Code:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end
	codeNameTemp = db.getResult("SELECT `code_name` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";")
	local codeName = codeNameTemp:getDataInt("code_name")
	if getGlobalStorageValue(45245) == -1 then db.executeQuery("ALTER TABLE `players` ADD `code_name` VARCHAR( 32 ) NOT NULL;") setGlobalStorageValue(45245, 1) end
	if codeName ~= '' then
		doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED
	else
		doPlayerBroadcastMessage(cid, param)
	end
	return true
end

Execute this query in your database:
Code:
ALTER TABLE `players` ADD `code_name` VARCHAR( 32 ) NOT NULL;

Change broadcast.lua to this:

LUA:
function onSay(cid, words, param, channel)
	if(param == '') then
		return true
	end

	codeNameTemp = db.getResult("SELECT `code_name` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";")
	local codeName = codeNameTemp:getDataInt("code_name")
	
	if codeName ~= '' then
		doBroadcastMessage(codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED)
	else
		doPlayerBroadcastMessage(cid, param)
	end

	return true
end

Untested though, tell me if it works :P


I tested both, the one that queries doesn't work for me because it doesn't want to add the stuff to the database. They both also don't work because:
20:38 0: Hello
I set the codename to E14 and it comes up as 0.

Edit:
Also, it doesn't broadcast in the main window, only in the console.
 
Last edited:
try this;
instead of;
codeNameTemp:getDataInt("code_name")
replace with;
codeNameTemp:getDataString("code_name")
also he made it VARCHAR not int .. im not good at queries
 
try this;
instead of;
codeNameTemp:getDataInt("code_name")
replace with;
codeNameTemp:getDataString("code_name")
also he made it VARCHAR not int .. im not good at queries

Tried that:
20:51 /b Hello
20:51 E14: Hello

But still only shows up in the console. How can I make it appear in the game window as well?
 
What you mean "game window"?

Well there's the console which is where the default and game-chat and help channels and so on are... All the text. Then there's the game window which is where you can see monsters, your character, items, etc. The area above the console and to the left of your skills/equipment/map.
 
if u want it to do it with a white color;
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, 22)
else if you want it with green;
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, 24)
check constant.lua in the lib (library)
 
if u want it to do it with a white color;
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, 22)
else if you want it with green;
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param, 24)
check constant.lua in the lib (library)

Yeah but when I used broadcast before, just /b, it showed up in default and in the game window in red
 
doBroadcastMessage(os.date("%M:%S", os.time()) .. " " .. codeName .. ": " .. param)

Code:
function onSay(cid, words, param, channel)
        if(param == '') then
                return true
        end

        codeNameTemp = db.getResult("SELECT `code_name` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";")
        local codeName = codeNameTemp:getDataString("code_name")
        
        if codeName ~= '' then
                doBroadcastMessage(codeName .. ": " .. param, MESSAGE_STATUS_WARNING)
				doBroadcastMessage(codeName .. ": " .. param, MESSAGE_STATUS_CONSOLE_RED)
        else
                doPlayerBroadcastMessage(cid, param)
        end

        return true
end

This is what I'm using. Works perfectly now. Just added a second broadcast line cause I know the warning one is red in game window but nothing in console and console_red is console only. So I used both.

Rep++ For helping me out <3
 
Back
Top