• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

How to use this function?

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
How do I use this function?
LUA:
doPlayerSendChannelMessage(cid, author, message, SpeakClasses, channel)
I mean what should I write in author, SpeakClasses?
and if I choose channel - Deaths - Will it say it in the Deaths chanel than?
 
change
Slaktaren
to
"Slaktaren"

it's a string goddamn it... Only thing that shouldn't have "" (a string) around them are CONSTANTS (like TRUE and MESSAGE_STATUS_CONSOLE_RED), VARIABLES (local rizz = 1337, then rizz is a variable), numbers (like 1337) and functions ( example: doPlayerSendCancel(cid, "some message") ).


channels you can find in channels.xml (data/xml)
 
Ah, thank you :)
but why do I need a name at Author? :S

EDIT; I did make a new channel with the ID 10, and I made the script like this:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
		
	if getPlayerLevel(cid) >= 1 then
		doPlayerSendChannelMessage(cid, "God Gatupojk", "TEST!!!!", MESSAGE_EVENT_ORANGE, 10)
		else
					doCreatureSay(cid, "Error", TALKTYPE_ORANGE_1)
		end
end
But it give me debugs :S
 
Test this

doPlayerSendChannelMessage(cid, "Rizz", "Rizz Roxs!!!!", TALKTYPE_CHANNEL_R1, 4)


SpeakClasses are these:
Code:
TALKTYPE_SAY = 1
TALKTYPE_WHISPER = 2
TALKTYPE_YELL = 3
TALKTYPE_PRIVATE_PN = 4
TALKTYPE_PRIVATE_NP = 5
TALKTYPE_PRIVATE = 6
TALKTYPE_CHANNEL_Y = 7
TALKTYPE_CHANNEL_W = 8
TALKTYPE_RVR_CHANNEL = 9
TALKTYPE_RVR_ANSWER = 10
TALKTYPE_RVR_CONTINUE = 11
TALKTYPE_BROADCAST = 12
TALKTYPE_CHANNEL_R1 = 13
TALKTYPE_PRIVATE_RED = 14
TALKTYPE_CHANNEL_O = 15
TALKTYPE_CHANNEL_R2 = 17
TALKTYPE_ORANGE_1 = 19
TALKTYPE_ORANGE_2 = 20
 
Last edited:
Thank you! It's working!
Rizz roxs! :D
rep++


EDIT;
I use a custom channel and I need to know how to edit so you can't talk in it

EDIT2;
This script doesn't work, could you fix it?
LUA:
function onPrepareDeath(cid, killer)
if(isPlayer(killer) == TRUE) then
doPlayerSendChannelMessage(cid, "Starfall", " - ".. getPlayerName(killer) .." ["..getPlayerLevel(killer).."] just killed "..getPlayerName(cid).." ["..getPlayerLevel(cid).."].", TALKTYPE_CHANNEL_O, 10)
end 
return TRUE
end

This script worked:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
		
		
	if getPlayerLevel(cid) >= 1 then
		doPlayerSendChannelMessage(cid, "Starfall", "Rizz Roxs!!!!", TALKTYPE_CHANNEL_O, 10)
		end
end
 
Last edited:
At the end of playerdeath.lua (creaturescripts), right before the last "end"

place

Code:
if(isPlayer(lastHitKiller) == TRUE) then
doPlayerSendChannelMessage(cid, "Starfall", " - ".. getPlayerName(lastHitKiller) .." ["..getPlayerLevel(lastHitKiller).."] just killed "..getPlayerName(cid).." ["..getPlayerLevel(cid).."].", TALKTYPE_CHANNEL_O, 10)
end
 
Here it is :p
LUA:
local config = {
	deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
	sqlType = getConfigInfo('sqlType'),
	maxDeathRecords = getConfigInfo('maxDeathRecords')
}

config.sqlType = config.sqlType == "mysql" and DATABASE_ENGINE_MYSQL

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
	if(config.deathListEnabled ~= TRUE) then
		return
	end

	local hitKillerName = "field item"
	local damageKillerName = ""
	if(lastHitKiller ~= FALSE) then
		if(isPlayer(lastHitKiller) == TRUE) then
			hitKillerName = getPlayerGUID(lastHitKiller)
		else
			hitKillerName = getCreatureName(lastHitKiller)
		end

		if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
			if(isPlayer(mostDamageKiller) == TRUE) then
				damageKillerName = getPlayerGUID(mostDamageKiller)
			else
				damageKillerName = getCreatureName(mostDamageKiller)
			end
		end
	end

	db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
	local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
	if(rows:getID() ~= -1) then
		local amount = rows:getRows(true) - config.maxDeathRecords
		if(amount > 0) then
			if(config.sqlType == DATABASE_ENGINE_SQLITE) then
				for i = 1, amount do
					db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
				end
			else
				db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
			end
		end
	end
	if(isPlayer(lastHitKiller) == TRUE) then
		doPlayerSendChannelMessage(cid, "Starfall", " - ".. getPlayerName(lastHitKiller) .." ["..getPlayerLevel(lastHitKiller).."] just killed "..getPlayerName(cid).." ["..getPlayerLevel(cid).."].", TALKTYPE_CHANNEL_O, 10)
	end
end
 
I made like this, your idea ofc...

LUA:
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)

if isPlayer(lastHitKiller) == TRUE then
	doPlayerSendChannelMessage(cid, "Auto Message -", " "..getCreatureName(cid).."["..getPlayerLevel(cid).."] just got killed by "..getCreatureName(lastHitKiller).."["..getPlayerLevel(lastHitKiller).."](Player)", TALKTYPE_CHANNEL_O, 10)
elseif isMonster(lastHitKiller) == TRUE then
	doPlayerSendChannelMessage(cid, "Auto Message -", " "..getCreatureName(cid).."["..getPlayerLevel(cid).."] just got killed by "..getCreatureName(lastHitKiller).."(Monster)", TALKTYPE_CHANNEL_O, 10)
else
	doPlayerSendChannelMessage(cid, "Auto Message -", " "..getCreatureName(cid).."["..getPlayerLevel(cid).."] just got killed by "..getCreatureName(lastHitKiller).."(?)", TALKTYPE_CHANNEL_O, 10)
		end
	return TRUE
end

But this says if the player got killed by a monster or something, a channel like Deaths :p

But, anyone know how to make it non-writeable?
 
Back
Top