• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Event System ;D

StreamSide

Joseluis Gonzalez
Staff member
Support Team
Joined
Aug 31, 2007
Messages
3,609
Solutions
51
Reaction score
1,224
Location
Arica - Chile
Well, this script was created by Haxy in OtServ Networks and i fix and post it ;D

Go to talkactions/scripts and create a file.lua called event and add this:

Code:
function onSay(cid, words, param)

local posx = getGlobalStorageValue(75311)
local posy = getGlobalStorageValue(75312)
local posz = getGlobalStorageValue(75313)
 
local evtpos = {x=posx, y=posy, z=posz}
 
	if words == '!participate' then
		if getGlobalStorageValue(75310) ~= 9 then
			doPlayerSendCancel(cid,'No events.')
		else	
			doTeleportThing(cid,evtpos)
		end
	elseif words == '/eventx' then
		if getPlayerAccess(cid) >= 3 then
			setGlobalStorageValue(75311, param)
		else
			doPlayerSendCancel(cid,'You not have access for use this command.')
		end
	elseif words == '/eventy' then
		if getPlayerAccess(cid) >= 3 then
			setGlobalStorageValue(75312, param)
		else
		doPlayerSendCancel(cid,'You not have access for use this command.')
		end
	elseif words == '/eventz' then
		if getPlayerAccess(cid) >= 3 then
			setGlobalStorageValue(75313, param)
		else
			doPlayerSendCancel(cid,'You not have access for use this command.')
		end
	elseif words == '/event' then
		if param == 'on' then
			if getPlayerAccess(cid) >= 3 then
				setGlobalStorageValue(75310, 9)
                                     doBroadcastMessage("An event, say !participate and be transported automatically", MESSAGE_EVENT_ADVANCE)
                else
                        doPlayerSendCancel(cid,'You not have access for use this command.')
                end
                elseif param == 'off' then
                        if getPlayerAccess(cid) >= 3 then
                                setGlobalStorageValue(75310, 0)
                                     doBroadcastMessage("The event finish", MESSAGE_EVENT_ADVANCE)
                else
                        doPlayerSendCancel(cid,'You not have access for use this command.')
                        end
end
 
end
end

and in talkactions.xml add
Code:
	<talkaction words="/eventx" log="no" access="3" script="event.lua" />
	<talkaction words="/eventy" log="no" access="3" script="event.lua" />
	<talkaction words="/eventz" log="no" access="3" script="event.lua" />
	<talkaction words="/event" log="yes" access="3" script="event.lua" />

	<talkaction words="!participate" script="event.lua" />

Usage:
If you like create a event say:
/eventx "the coordinates x
/eventy "the coordinates y
/eventz "the coordinates z
/event "on - for start the event
/event "off - for finish the event
The players need say !participate and will be teleporting (only if you have a event)

Ok, iam noob in english xd and Iam noob in scripts but i like learn :D

Rate it ;D
 
Last edited:
Great work, you're learning. :) Hope you understand how to tab correctly now. ;)
 
Dude, thanks for posting it, gave me an idea :)
 
i am not sure but is it like u make event area and set them and ppl who want to join use !participate?
if ye great script!!
 
i am not sure but is it like u make event area and set them and ppl who want to join use !participate?
if ye great script!!
Yeah, look this images ;D
event1wg9.png

eventossp7.png

eventonfo5.png

eventoyeszz2.png

lolty9.png

eventoparticipateat4.png

participateii7.png


I use: /eventox- /eventoy - /eventoz - /evento "on - !participar so iam from chile, i speak spanish ;D but here is /eventx - /eventy - /eventz - /event "on - !participate (without the "o" ;D)
 
ty alot for showing me how to use it and what it does ^^
 
Its basically the same, but you can see how does separators work etc :p

PHP:
local group = 3 -- min access
local eventTime = 60 * 1000 -- how long the event will stay on
local posx = getGlobalStorageValue(10001)
local posy = getGlobalStorageValue(10002)
local posz = getGlobalStorageValue(10003)
local eventPos = { x = posx, y = posy, z = posz }

function onSay(cid, words, param)

	if getGlobalStorageValue(10000) == 0 then
		if getPlayerGroupId(cid) >= group then
			if param ~= "" then
				if string.find(param, '-') ~= nil then		
				local sep1 = string.find(param, '-')
				local param1 = string.sub(param, 1, sep1-1)
				local subparam1 = string.sub(param,sep1+1,string.len(param))
					if string.find(subparam1, '-') ~= nil then
					local sep2 = string.find(subparam1, '-')
					local param2 = string.sub(subparam1,1,sep2-1)
					local subparam2 = string.sub(subparam1,sep2+1,string.len(param))
						if string.find(subparam2, '-') ~= nil then
						local sep3 = string.find(subparam2, '-')
						local param3 = string.sub(subparam2,1,sep3-1)
						local param4 = string.sub(subparam2,sep3+1,string.len(param))
							if param1 == "" then
								doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have to type an Event Name.")
							elseif param2 == "" or isNumber(param2) == FALSE then
								doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have to type position X.")
							elseif param3 == "" or isNumber(param3) == FALSE then
								doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have to type position Y.")
							elseif param4 == "" or isNumber(param4) == FALSE then
								doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have to type position Z.")
							elseif words == "!event" then
								broadcastMessage("An event ("..param1..") has been started! Say \"!join\" to participate in.", MESSAGE_EVENT_ADVANCE)
								setGlobalStorageValue(10000, 1)
								setGlobalStorageValue(10001, param2)
								setGlobalStorageValue(10002, param3)
								setGlobalStorageValue(10003, param4)
								addEvent(endEvent, eventTime, a)
							end
						else
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format, type in: !event \"event name-x-y-z.")					
						end
					else
						doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format, type in: !event \"event name-x-y-z.")
					end
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format, type in: !event \"event name-x-y-z.")
				end
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format, type in: !event \"event name-x-y-z.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Sorry, only authorized players may execute events.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "An event is already running, it has to be stopped to start another one.")
	end
	if words == "!join" or words =="!participate" then
		if getGlobalStorageValue(10000) == 1 then
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			doTeleportThing(cid, eventPos, 0)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_ENERGYAREA)
			broadcastMessage(getCreatureName(cid).." has joined the event!", MESSAGE_STATUS_DEFAULT)
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "No event is on now.")
		end
	end
end

function endEvent(cid)
setGlobalStorageValue(10000, 0)
broadcastMessage("An event has been finished.", MESSAGE_EVENT_ADVANCE)
--tping to town
end

also for the global storage value use you have to have server compiled with __GLOBAL_STORAGE__ (if using new revisions).

also run this in your phpmyadmin:
PHP:
INSERT INTO `global_storage` (
`key` ,
`value`
)
VALUES (
'10000', ''
), (
'10001', ''
), (
'10002', ''
), (
'10003', ''
)

Literally, it may have some bugs, since i didnt test it much.
Ill be adding TPing to residence or old pos when the event ends later.
 
I changed it around so you no longer have to set the position manually. It will automatically set the event position to your current position.

Code:
function onSay(cid, words, param)

local posx = getGlobalStorageValue(75001)
local posy = getGlobalStorageValue(75002)
local posz = getGlobalStorageValue(75003)
 
local evtpos = {x=posx, y=posy, z=posz}

local playerPos = getPlayerPosition(cid)

	if words == '!participate' then
		if getGlobalStorageValue(75000) ~= 9 then
			doPlayerSendCancel(cid,'There are currently no events open.')
		else	
			doTeleportThing(cid,evtpos)
		end
	elseif words == '/event' then
		if param == 'open' then
			if getPlayerGroupId(cid) >= 3 then
				setGlobalStorageValue(75000, 9)
				
				setGlobalStorageValue(75001, playerPos.x)
				setGlobalStorageValue(75002, playerPos.y)
				setGlobalStorageValue(75003, playerPos.z)
				
        broadcastMessage("A server wide event has been opened. Please say !participate if you would like to join", MESSAGE_EVENT_ADVANCE)
      else
        doPlayerSendCancel(cid,'You do not have the proper access to use this command.')
      end
    elseif param == 'close' then
     if getPlayerGroupId(cid) >= 3 then
       setGlobalStorageValue(75000, 0)
       broadcastMessage("The event is now closed", MESSAGE_EVENT_ADVANCE)
      else
        doPlayerSendCancel(cid,'You do not have the proper access to use this command.')
      end
end
 
end
end
 
Code:
-- Credits to Ispiro, Colandus, Huxy, and StreamSide

function string.trim(str)
	-- Function by Colandus
	return (string.gsub(str, "^%s*(.-)%s*$", "%1"))
end

function string.explode(str, sep)
    -- Function by Colandus
    local pos, t = 1, {}
    if #sep == 0 or #str == 0 then return end
    for s, e in function() return string.find(str, sep, pos) end do
        table.insert(t, string.trim(string.sub(str, pos, s-1)))
        pos = e+1
    end
    table.insert(t, string.trim(string.sub(str, pos)))
    return t
end

TELEPORT_POSITION = false
JOINED_PLAYERS = {}

-- /event 75, 117, 7
-- /event off <- teleports players that participated in event to their home temples
-- !joinevent <- participate in event
function onSay(cid, text, param)
    if(text == "/event") then
        if(getPlayerAccess == 0) then return TRUE end
        if(param == "off") then
            TELEPORT_POSITION = false
            for i, v in ipairs(JOINED_PLAYERS) do
                if(isPlayer(v) == TRUE) then
                    doTeleportThing(v, getPlayerMasterPos(v))
                end
            end
            JOINED_PLAYERS = {}
            doPlayerSendCancel(cid, "Event has been disabled, and all participating players have been sent to their temples.")
        else
            local t = string.explode(param, ",")
            TELEPORT_POSITION = {x = tonumber(t[1]), y = tonumber(t[2]), z = tonumber(t[3] or 7)}
            doPlayerSendCancel(cid, "Event has been enabled.")
        end
    elseif(text == "!joinevent") then
        if(TELEPORT_POSITION) then
            doTeleportThing(cid, TELEPORT_POSITION)
            table.insert(JOINED_PLAYERS, cid)
        end
    end
    return FALSE
end

Thought this way should be better, and that way events are automatically turned off when server shuts down. Also, participating players are teleported to their home temples after event.

Regards,
Ispiro.
 
Last edited:
Is it possible that players with skull, not to be able to be teleported, since they can land on a pz area?

Thank you!
 
#Juninroxy
Code:
-- Credits to Ispiro, Colandus, Huxy, and StreamSide

function string.trim(str)
	-- Function by Colandus
	return (string.gsub(str, "^%s*(.-)%s*$", "%1"))
end

function string.explode(str, sep)
    -- Function by Colandus
    local pos, t = 1, {}
    if #sep == 0 or #str == 0 then return end
    for s, e in function() return string.find(str, sep, pos) end do
        table.insert(t, string.trim(string.sub(str, pos, s-1)))
        pos = e+1
    end
    table.insert(t, string.trim(string.sub(str, pos)))
    return t
end

TELEPORT_POSITION = false
JOINED_PLAYERS = {}

-- /event 75, 117, 7
-- /event off <- teleports players that participated in event to their home temples
-- !joinevent <- participate in event
function onSay(cid, text, param)
    if(text == "/event") then
        if(getPlayerAccess == 0) then return TRUE end
        if(param == "off") then
            TELEPORT_POSITION = false
            for i, v in ipairs(JOINED_PLAYERS) do
                if(isPlayer(v) == TRUE) then
                    doTeleportThing(v, getPlayerMasterPos(v))
                end
            end
            JOINED_PLAYERS = {}
            doPlayerSendCancel(cid, "Event has been disabled, and all participating players have been sent to their temples.")
        else
            local t = string.explode(param, ",")
            TELEPORT_POSITION = {x = tonumber(t[1]), y = tonumber(t[2]), z = tonumber(t[3] or 7)}
            doPlayerSendCancel(cid, "Event has been enabled.")
        end
    elseif(text == "!joinevent") then
	local pos = getCreaturePosition(cid)
	if getTilePzInfo(pos) == FALSE then
		if getCreatureSkullType == 0 then
        if(TELEPORT_POSITION) then
            doTeleportThing(cid, TELEPORT_POSITION)
            table.insert(JOINED_PLAYERS, cid)
        end
		else
			doPlayerSendCancel(cid, "If you have skull you cant enter.")
		end
	else
	doPlayerSendCancel(cid, "If you have pz locked you cant enter.")
    end
	end
    return FALSE
end
 
Its without broadcasting, so when i say /event bla,bla,bla It just says Event is enabled. and for me only! So i need this but, when i say /event bla,bla,bla, It broadcasts :Event has been started. Please say !joinevent to join the event. 5 minutes and it will be closed! So and else let it say it for 5minutes, So after this 5minutes player says !joinevent it says :Event is already started and joining time is ended.
Thankful for all.
Heres the script that guys give:

-- Credits to Ispiro, Colandus, Huxy, and StreamSide

function string.trim(str)
-- Function by Colandus
return (string.gsub(str, "^%s*(.-)%s*$", "%1"))
end

function string.explode(str, sep)
-- Function by Colandus
local pos, t = 1, {}
if #sep == 0 or #str == 0 then return end
for s, e in function() return string.find(str, sep, pos) end do
table.insert(t, string.trim(string.sub(str, pos, s-1)))
pos = e+1
end
table.insert(t, string.trim(string.sub(str, pos)))
return t
end

TELEPORT_POSITION = false
JOINED_PLAYERS = {}

-- /event 75, 117, 7
-- /event off <- teleports players that participated in event to their home temples
-- !joinevent <- participate in event
function onSay(cid, text, param)
if(text == "/event") then
if(getPlayerAccess == 0) then return TRUE end
if(param == "off") then
TELEPORT_POSITION = false
for i, v in ipairs(JOINED_PLAYERS) do
if(isPlayer(v) == TRUE) then
doTeleportThing(v, getPlayerMasterPos(v))
end
end
JOINED_PLAYERS = {}
doPlayerSendCancel(cid, "Event has been disabled, and all participating players have been sent to their temples.")
else
local t = string.explode(param, ",")
TELEPORT_POSITION = {x = tonumber(t[1]), y = tonumber(t[2]), z = tonumber(t[3] or 7)}
doPlayerSendCancel(cid, "Event has been enabled.")
end
elseif(text == "!joinevent") then
local pos = getCreaturePosition(cid)
if getTilePzInfo(pos) == FALSE then
if getCreatureSkullType == 0 then
if(TELEPORT_POSITION) then
doTeleportThing(cid, TELEPORT_POSITION)
table.insert(JOINED_PLAYERS, cid)
end
else
doPlayerSendCancel(cid, "If you have skull you cant enter.")
end
else
doPlayerSendCancel(cid, "If you have pz locked you cant enter.")
end
end
return FALSE
 
Code:
-- Credits to Ispiro, Colandus, Huxy, and StreamSide

function string.trim(str)
	-- Function by Colandus
	return (string.gsub(str, "^%s*(.-)%s*$", "%1"))
end

function string.explode(str, sep)
    -- Function by Colandus
    local pos, t = 1, {}
    if #sep == 0 or #str == 0 then return end
    for s, e in function() return string.find(str, sep, pos) end do
        table.insert(t, string.trim(string.sub(str, pos, s-1)))
        pos = e+1
    end
    table.insert(t, string.trim(string.sub(str, pos)))
    return t
end

TELEPORT_POSITION = false
JOINED_PLAYERS = {}

-- /event 75, 117, 7
-- /event off <- teleports players that participated in event to their home temples
-- !joinevent <- participate in event
function onSay(cid, text, param)
    if(text == "/event") then
        if(getPlayerAccess == 0) then return TRUE end
        if(param == "off") then
            TELEPORT_POSITION = false
            for i, v in ipairs(JOINED_PLAYERS) do
                if(isPlayer(v) == TRUE) then
                    doTeleportThing(v, getPlayerMasterPos(v))
                end
            end
            JOINED_PLAYERS = {}
            doPlayerSendCancel(cid, "Event has been disabled, and all participating players have been sent to their temples.")
        else
            local t = string.explode(param, ",")
            TELEPORT_POSITION = {x = tonumber(t[1]), y = tonumber(t[2]), z = tonumber(t[3] or 7)}
            doPlayerSendCancel(cid, "Event has been enabled.")
        end
    elseif(text == "!joinevent") then
        if(TELEPORT_POSITION) then
            doTeleportThing(cid, TELEPORT_POSITION)
            table.insert(JOINED_PLAYERS, cid)
        end
    end
    return FALSE
end

Thought this way should be better, and that way events are automatically turned off when server shuts down. Also, participating players are teleported to their home temples after event.

Regards,
Ispiro.
With a nice thanks, and with the best for you!.. Thanks master ispiro.. You scripted a best script! Thankfully.
 
can anyone add 2 teams when player say !joinevent he randomy set to red or blue team and get the outfit can anyone ? :)
 
Back
Top