• 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!

[request] /promote "name

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
I'm requesting a talkaction!

This is what the talkactions will do:

13:00 /promote "name
13:00 You have promoted "name" from Player to Tutor!
and if i do it again on the same person:
13:01 /promote "name
13:01 You have promoted "name" from Tutor to Senior Tutor!
then GM then CM then God :p

Hope you understand what i mean!
 
Yea the section is fine, but actually it's not easy to make a script which changes values in database. Faster way is manually changing group ids of players in 'players' table.
 
Yes you can :[

talkactions/scripts/promote.lua
Code:
--Promote/Demote player by slawkens

local lastGroup = 9 -- How much groups you have?
local talks = {"/promote", "/demote"} -- talk words, if you wish to change it - remember also to edit talkactions.xml 

file

function onSay(cid, words, param)
	if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return TRUE
	end

	local i = 1
	if words == talks[2] then
		i = -1
	end

	local tmpPlayer = getPlayerByNameWildcard(param)
	if tmpPlayer == FALSE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is not online.")
		return TRUE
	end

	local tmpGroup = getPlayerGroupId(tmpPlayer)
	if (i > 0 and (tmpGroup + i) > lastGroup) or (tmpGroup == 1 and i < 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Max/Min group reached... [Min: 1, Max: " .. 

lastGroup .. "]")
		return TRUE
	end

	setPlayerGroupId(tmpPlayer, tmpGroup + i)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New player group: " .. tmpGroup + i)
	return TRUE
end

talkactions.xml
Code:
	<talkaction access="5" words="/promote" script="promote.lua"/>
	<talkaction access="5"  words="/demote" script="promote.lua"/>
 
Code:
local config = {
	maxGroup = 6,
	groupName = { 
	[1] = "player", [2] = "tutor", [3] = "senior tutor", 
	[4] = "gamemaster", [5] = "community manager", [6] = "god" }
}

function onSay(cid, words, param)
	if param ~= nil then
	local target = getPlayerByNameWildcard(param)
		if target ~= FALSE then
			if words == "/promote" then
				if getPlayerGroupId(target) < config.maxGroup then
					setPlayerGroupId(target, getPlayerGroupId(target) + 1)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have promoted "..target.." to "..config.groupName[getPlayerGroupId(target)]..".")
					doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "You have been promoted to "..config.groupName[getPlayerGroupId(target)]..".")
					local account = getPlayerAccountId(target)
					db.executeQuery("UPDATE accounts SET type = type + 1 WHERE id = "..account..";")
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is already a "..config.groupName[config.maxGroup]..".")
				end
			elseif words == "/demote" then
				setPlayerGroupId(target, getPlayerGroupId(target) - 1)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have demoted "..target.." to "..config.groupName[getPlayerGroupId(target)]..".")
				doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "You have been demoted to "..config.groupName[getPlayerGroupId(target)]..".")
				local account = getPlayerAccountId(target)
				db.executeQuery("UPDATE accounts SET type = type - 1 WHERE name = "..account..";")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "A player with that name does not exist.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to specify players name.")
	end
	return FALSE
end

Probably mine wont work =D
 
@Slawkens, I get an error:
PHP:
[13/12/2008 18:58:56] Warning: [Event::loadScript] Can not load script. data/talkactions/scripts/promote.lua
[13/12/2008 18:58:56] data/talkactions/scripts/promote.lua:8: '=' expected near 'function'
Thank you anyway :)

@Marcinek Paladinek, Your actually worked! It works real fine! Thank you
 
Ah mine works, just [
Code:
] has messed it ;\

[code]
[code]
--Promote/Demote player by slawkens

local lastGroup = 9 -- How much groups you have?
local talks = {"/promote", "/demote"}
-- talk words, if you wish to change it remember also to edit --talkactions.xml file

function onSay(cid, words, param)
	if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return TRUE
	end

	local i = 1
	if words == talks[2] then
		i = -1
	end

	local tmpPlayer = getPlayerByNameWildcard(param)
	if tmpPlayer == FALSE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player is not online.")
		return TRUE
	end

	local tmpGroup = getPlayerGroupId(tmpPlayer)
	if (i > 0 and (tmpGroup + i) > lastGroup) or (tmpGroup == 1 and i < 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Max/Min group reached... [Min: 1, Max: " .. 

lastGroup .. "]")
		return TRUE
	end

	setPlayerGroupId(tmpPlayer, tmpGroup + i)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New player group: " .. tmpGroup + i)
	return TRUE
end
 
Back
Top