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

TalkAction + Movement - Create Portal with players go limit!

Azi

Banned User
Joined
Aug 12, 2007
Messages
1,167
Reaction score
53
Location
Włocławek
in talkactions/scripts/portal.lua
PHP:
function onSay(cid, words, param)
    local param = param.explode(param, ',')
    if param then
    teleport = doCreateTeleport(1387, {x=param[1], y=param[2], z=param[3]}, getPlayerPosition(cid))
	doSetItemSpecialDescription(teleport, 'The portal may enter '..param[4]..' people left.')
    doSetItemActionId(teleport, 100+param[4])
    else
    doPlayerSendCancel(cid, "You must set param.")
    end
    return TRUE
end

talkactions.xml
PHP:
<talkaction access="5" log="yes" words="!portal" script="portal.lua"/>
now in movements/scripts/portal.lua
PHP:
function onStepIn(cid, item, position, fromPosition)
    if item.actionid > 100 then
	doSetItemSpecialDescription(item.uid, 'The portal may enter '..(item.actionid-101)..' people left.')
    doSetItemActionId(item.uid, item.actionid-1)
    end
    return TRUE
end


function onStepOut(cid, item, position, fromPosition)
    if item.actionid == 100 then
	doSendMagicEffect(position, 2)
    doRemoveItem(item.uid, 1)
    end
    return TRUE
end

and movements.xml
PHP:
<movevent type="StepIn" itemid="1387" event="script" value="portal.lua"/>
<movevent type="StepOut" itemid="1387" event="script" value="portal.lua"/>

how do use?
login gm and say !portal x,y,z,players_ammount like:
!portal 127,54,7,20

and 20 players who goto portal are teleported to position 127,54,7 and portal auto remove. : ))
I'm used it's to events ( 5 first players win! :p )

Yours,
azi.
 
Last edited:
very nice bro
id give u rep but shit doesnt work for me
 
i mean the rep thing it wont let me give
and about the script

it says theres already an event with 1387 *teleport id*

<!-- Citizen teleport -->
<movevent event="StepIn" itemid="1387" script="temples.lua" />

what to do
 
[05/02/2009 21:03:19] Lua Script Error: [TalkAction Interface]
[05/02/2009 21:03:19] data/talkactions/scripts/portal.lua: onSay

[05/02/2009 21:03:19] data/talkactions/scripts/portal.lua:6: attempt to compare nil with number
[05/02/2009 21:03:19] stack traceback:
[05/02/2009 21:03:19] data/talkactions/scripts/portal.lua:6: in function <data/talkactions/scripts/portal.lua:4>

Used on Tfs 0.3 beta 3
 
#up
try now - group id requipment removed from script - added in talkactions.xml : )


#dół
no ok. :p
a masz access na 5 ustawiony? xd
 
Last edited:
Kurde nie chce mi sie po angielsku pisac.. :p

Nic sie tera nie dzieje jak pisze !portal xxx yyy z ..
W silniku nic nie ma :huh:

@up

<!-- Gods -->

<talkaction access="5" log="yes" words="!portal" script="portal.lua"/>

Jesli to o to chodzi :p
A jesli o God'a to tak

@down
I'm too sorry for talking in Polish
Tak mam :D
You are god.

To tak jakby skrpy nie byl skryptem.. tzn.
Sam nie wiem ;/
 
Last edited:
#sorry for pl. :p

ee, na postaci czy masz access na 5 :p

#up
to nie wiem czemu, jak błędu nie ma to trudno się dowiedzieć. ;s
 
im using tfs 0.22
Code:
Lua Script Error: [TalkAction Interface] 
data/talkactions/scripts/portal.lua:onSay

data/talkactions/scripts/portal.lua:2: attempt to call field 'explode' (a nil value)
stack traceback:
	data/talkactions/scripts/portal.lua:2: in function <data/talkactions/scripts/portal.lua:1>
 
@up
You dont have the function string.explode!

How to add it?
Open global.lua and add this:

PHP:
function string.explode(str, sep, limit)
    -- Function by Colandus
    if limit and type(limit) ~= 'number' then
        error("string.explode: limit must be a number", 2)
    end

    if #sep == 0 or #str == 0 then return end
    local pos, i, t = 1, 1, {}
    for s, e in function() return str:find(sep, pos) end do
        table.insert(t, str:sub(pos, s-1):trim())
        pos = e + 1
        i = i + 1
        if limit and i == limit then break end
    end
    table.insert(t, str:sub(pos):trim())
    return t
end

Function thanks to Colandus :D
 
ok, thanks i added it.

but it doesn't work. I have this same error like Your Master:

on console everything looks fine, 0 errors but it doesnt work.
 
and 20 players who goto portal are teleported to position 127,54,7 and portal auto remove. : ))
I'm used it's to events ( 5 first players win! :p )
Seems it creates the portal @ the said position and teleports to where you were standing when you made the portal. Not the other way around like you said, where it would create a portal where you are standing that goes to a said position.

Works none-the-less.
I'm going to use it!
 
#updated.
added "cloud" effect when teleport was removing and descriptions (with auto change) how many players may go to tp. :)
 
It's get in shock with another movement that already exists (citizen) how i may proceed?
 
Last edited:
can you do:


'Broadcast' [param5]


idk how to write it so, can you fix that for me? and maybe show me what the script would look like with a broadcast message too?

thanks
 
PHP:
function onSay(cid, words, param)
    local param = param.explode(param, ',')
    if param then
    teleport = doCreateTeleport(1387, {x=param[1], y=param[2], z=param[3]}, getPlayerPosition(cid))
	doSetItemSpecialDescription(teleport, 'The portal may enter '..param[4]..' people left.')
    doSetItemActionId(teleport, 100+param[4])
   doBroadcastMessage(param[5], MESSAGE_EVENT_ADVANCE)     
    else
    doPlayerSendCancel(cid, "You must set param.")
    end
    return TRUE
end



edit: this works for broadcasting a message with your event portal
 
Last edited:
Back
Top