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

CreatureEvent Advanced - CheckPoint System!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,284
Location
Sweden?
Requested By Exedion



First go to movements/movements.xml and add this line:
Code:
<movevent type="StepIn" actionid="100" event="script" value="checkpoint.lua"/>

Now goto movements/scripts and create new lua and name it "checkpoint" and paste this code below:
Lua:
local otswe = {
	storage_on_enter_tile = 1000,
	first_time_enter_tile = "CHECKPOINT!", 
	already_enter_the_tile = "Sorry, but you already entered this checkpoint tile." 
}

function onStepIn(cid, item, position, fromPosition)
	if not(isPlayer(cid)) then return true end
	if getPlayerStorageValue(cid, otswe.storage_on_enter_tile) == -1 then
		setPlayerStorageValue(cid, otswe.storage_on_enter_tile, 1)
		doCreatureSay(cid, otswe.first_time_enter_tile, TALKTYPE_MONSTER)
	else
		doPlayerSendTextMessage(cid,20, otswe.already_enter_the_tile)
	end
end

Now goto movements/movements.xml and paste this line below:
Code:
<movevent type="StepIn" actionid="1001" event="script" value="opencheckpointsdialog.lua"/>
<movevent type="StepOut" actionid="1001" event="script" value="opencheckpointsdialog.lua"/>

Now goto movements/scripts and create new lua and name it "opencheckpointdialog" and paste this code below:
Lua:
local message = "Here can you chose your latest check points"
local open_storage = 5555 -- make sure use a empty storage

function dialog(cid)
	if isPlayer(cid) then
		openChannelDialog(cid)
	end
end

function onStepIn(cid, item, position, fromPosition)
	if isPlayer(cid) then
		doPlayerPopupFYI(cid, message)
		addEvent(dialog, 1*1, cid)
		setPlayerGroupId(cid, 7)
		setPlayerStorageValue(cid, open_storage, 1)
	end
end

function onStepOut(cid, item, position, fromPosition)
	if isPlayer(cid) then
		setPlayerGroupId(cid, 1)
		setPlayerStorageValue(cid, open_storage, -1)
	end
end

Now goto xml/channels.xml and post this lines below:
Code:
--////////////////////Dungeons Channels/////////////--
	<channel id="20" name="Dark Dungeon" access="0"/>
	<channel id="21" name="Spooky House" access="0"/>
--////////////////////Dungeons Channels/////////////--

Also on all other channels paste access 1, so we dont need to see them when we view the checkpoint dialog, Ex:
Code:
<channel id="6" name="Trade" level="8" muted="120" access="1" conditionId="2" conditionMessage="You may only place one offer in two minutes."/>

Now go to xml/groups.xml. We have to add access so Example trade wont appear or other channels. But we cant prevent when its back group 1, those channels comming up. But they cant use them, since they need the storage.
Code:
<group id="7" access="0" name="Player"/>

Now change your player at xml/groups.xml and make sure it has access 1
Code:
<group id="1" access="1" name="Player"/>

Now go to creaturescripts/creaturescripts.xml
Code:
<event type="joinchannel" name="CheckJoin" event="script" value="checkpointsystem.lua"/>
<event type="leavechannel" name="CheckLeave" event="script" value="checkpointsystem.lua"/>

Now goto creaturescripts/scripts and create new lua and name it "checkpointsystem" and paste the script below:
Lua:
local otswe = {
    cave1 = {
    [1000] = {pos1 = { x = 1000, y = 1000, z = 7 , stackpos = 1 }}, --The first box is the storage to get teleported to the first check point.
    [1001] = {pos2 = { x = 1000, y = 1000, z = 6 , stackpos = 1 }}, --Higher the storage is, then you will get teleported to that checkpoint.
    },
    cave2 = {
    [1002] = {pos1 = { x = 1005, y = 1005, z = 7 , stackpos = 1 }},
    [1003] = {pos2 = { x = 1000, y = 1000, z = 6 , stackpos = 1 }}
	}
}

function onJoinChannel(cid, channelId, users)
    if getPlayerStorageValue(cid, 5555) == -1 then
	doPlayerSendTextMessage(cid,20, "Sorry, but you are at the wrong place to use any of these check points.")
    return false
end
    if channelId == 20 then
		if getPlayerStorageValue(cid, otswe.cave1[1000]) == 1 then
			doTeleportThing(cid, otswe.cave1[1000].pos1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
		 end
			if getPlayerStorageValue(cid, otswe.cave1[1001]) == 1 then
			doTeleportThing(cid, otswe.cave1[1001].pos2)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
		 else
			doPlayerSendTextMessage(cid,20, "You dont have any check points in this place.")	
                        openChannelDialog(cid) 
		end
	return false
end
    if channelId == 21 then
		if getPlayerStorageValue(cid, otswe.cave2[1002]) == 1 then
			doTeleportThing(cid, otswe.cave2[1002].pos1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	     end
			if getPlayerStorageValue(cid, otswe.cave2[1003]) == 1 then
			doTeleportThing(cid, otswe.cave2[1003].pos2)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
       	 else
			doPlayerSendTextMessage(cid,20, "You dont have any check points in this place.")
                        openChannelDialog(cid)
         end	 
		return false
	end
end
 
 
function onLeaveChannel(cid, channelId, users)
    if channelId >= 20 and channelId <= 21 then
           doPlayerSetGroupId(cid, 1)
		end
	return true
end

Now goto creaturescripts/scripts/login.lua and paste this code below
function onLogin(cid):
Lua:
	if getPlayerGroupId(cid) == 7 then
		setPlayerGroupId(cid, 1)	
	end
	if getPlayerStorageValue(cid, 5555) == 1 then
	        setPlayerStorageValue(cid, 5555) == -1  
	end

Enjoy, ive already tested the channels and they work. Im not sure about the tiles, but try them out and report any bugs.
Maybe its not easy to configure the channels, thats why i made two caves so you get the idea how everything works to add more.

The problem is those channels will come, so make sure every channels has higher id than the normal channels to atleast prevent other channels when we enter the checkpoint dialog.
 
Last edited:
It's nice but I can be shortened. Specially the creaturescript.
 
I know bro, but im trying doing everything easily configured ^^ I can also merged things togehter :p
 
Thank you man! really thank you! I do not want to be rude but maybe you could do a little better using the functions that I mentioned in the topic of requests so as not to have the need to create new channels and access and neither shown unnecessary channels like locked checkpoints or the chat system (private channels option and NPC's option)

functions are:
Lua:
doPlayerSendChannels(cid[, list])

you can see how this function using the command "/ban"

and trigger functions such as teleportation can use the creature event:
Lua:
onChannelRequest(cid, channel, custom)

which is also used in the banishment system, in the files in creature events
 
Idk i tried but didnt work.

Ive changed the creaturescript code and made that if you dont get have checkpoints on that place, the channeldialog opens again.
 
for me work perfectly, i try to do by myself but i have problems with tables
 
What do you mean?
 
This is pretty good. Keep up the work! You'll get a lot better at Lua by coding more and more, that's how I learned...trial and error. ;)
 
Perhaps your two threads should be merged if you both are working on one system.
 
Back
Top