Exedion
Active Member
- Joined
- Jun 11, 2007
- Messages
- 628
- Reaction score
- 30
A few days ago I made an order on the thread of Cyko, an advanced checkpoint system, because i had problems with the tables, but slowly went back to recalled learning a little about lua thanks to the work and to take some Cyko bases there, I could make a more optimized, achieving everything I wanted for this system, without further ado, there are the ADVACED CHECKPOINT SYSTEM:
*add to movements,xml
*create the file checkpointtiles.lua in moveevent's script folder and add inside:
How to use: when you create the checkpoint tile in map editor, add action id: 10001 to ALL of you checkpoint tile and add an unique id to recognize the number of the checkpoint, example: 10001 = checkpoint 1
*create the file checkpoint.lua in moveevent's script folder and add inside:
How to use: with map editor, create a special tile in a temple or wherever you want, and set action id to 10000, when the player step the tile, their checkpoints window will pop-up with all unlocked checkpoints. (recommend that this tile is created in a protection zone as the player does not move while the window is open)
in the file: insert more values in the CHECKPOINT_STORAGE table, to add you tile to the checkpoint data base, in "[10001]" <- here you add the unique id of your new checkpoint tile, in "{1, " <- here is the id number of you checkpoint, is used in another script to set the price of checkpoint and the position, and in " "Temple (150 gps)"}," <- you set the name of the checkpoint and you can put the price to inform players in the same channel window.
*and for last, add to creatureevents.xml:
*create the file checkpointteleport.lua in creatureevent's script folder and add inside:
How to use: insert more values in the CHECKPOINT_TELEPORT table, to add the price and position parameter to a checkpoint, in "[1]" <- here is the same id number of your checkpoint in the file "checkpoint.lua" ([1] is the id number of the checkpoont "Temple"), in "{price = 150, " <- is the price it will cost a player go to the checkpoint place (0 is free), in pos = "{x = 1000, y = 1000, z = 7 , stackpos = 1}}," <- is the known position table used comonly in OTS, here you add the position of checkpoints.
Well here are the system of checkpoints, if have a bug, report it here, I hope you enjoy
*add to movements,xml
Code:
<movevent type="StepIn" actionid="10000" event="script" value="checkpoint.lua"/>
<movevent type="StepOut" actionid="10000" event="script" value="checkpoint.lua"/>
<movevent type="StepIn" actionid="10001" event="script" value="checkpointtitles.lua"/>
*create the file checkpointtiles.lua in moveevent's script folder and add inside:
Code:
function onStepIn(cid, item, position, fromPosition)
local pos = getCreaturePosition(cid)
if(isPlayer(cid) and getCreatureStorage(cid, item.uid) < 1) then
setCreatureStorage(cid, item.uid, 1)
doCreatureSay(cid, "CHECKPOINT ADD!", TALKTYPE_MONSTER)
doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
else
doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
end
return true
end
How to use: when you create the checkpoint tile in map editor, add action id: 10001 to ALL of you checkpoint tile and add an unique id to recognize the number of the checkpoint, example: 10001 = checkpoint 1
*create the file checkpoint.lua in moveevent's script folder and add inside:
Code:
local CHECKPOINT_STORAGE = {
[10001] = {1, "Temple (150 gps)"},
[10002] = {2, "Cave (150 gps)"},
[10003] = {3, "Mountain (150 gps)"}
}
function onStepIn(cid, item, position, fromPosition)
if not isPlayer(cid) then
return true
end
unregisterCreatureEventType(cid, "channelrequest")
local CHECKPOINT_LIST = {}
for k, v in pairs(CHECKPOINT_STORAGE) do
if(isPlayer(cid)getCreatureStorage(cid, k) > 0) then
table.insert(CHECKPOINT_LIST, v[1], v[2])
end
end
doPlayerSendChannels(cid, CHECKPOINT_LIST)
registerCreatureEvent(cid, "checkpoint")
return true
end
function onStepOut(cid, item, position, lastPosition)
unregisterCreatureEventType(cid, "channelrequest")
return true
end
How to use: with map editor, create a special tile in a temple or wherever you want, and set action id to 10000, when the player step the tile, their checkpoints window will pop-up with all unlocked checkpoints. (recommend that this tile is created in a protection zone as the player does not move while the window is open)
in the file: insert more values in the CHECKPOINT_STORAGE table, to add you tile to the checkpoint data base, in "[10001]" <- here you add the unique id of your new checkpoint tile, in "{1, " <- here is the id number of you checkpoint, is used in another script to set the price of checkpoint and the position, and in " "Temple (150 gps)"}," <- you set the name of the checkpoint and you can put the price to inform players in the same channel window.
*and for last, add to creatureevents.xml:
Code:
<event type="channelrequest" name="checkpoint" event="script" value="checkpointteleport.lua"/>
*create the file checkpointteleport.lua in creatureevent's script folder and add inside:
Code:
local CHECKPOINT_TELEPORT = {
[1] = {price = 150, pos = {x = 1000, y = 1000, z = 7 , stackpos = 1}},
[2] = {price = 150, pos = {x = 1000, y = 1000, z = 7 , stackpos = 1}},
[3] = {price = 150, pos = {x = 1000, y = 1000, z = 7 , stackpos = 1}}
}
function onChannelRequest(cid, channel, custom)
local checkpoint = CHECKPOINT_TELEPORT[channel]
unregisterCreatureEvent(cid, "checkpoint")
if(not custom or type(channel) ~= 'number') then
doPlayerSendCancel(cid, "Invalid action.")
return false
end
if(not doPlayerRemoveMoney(cid, checkpoint.price)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. checkpoint.price .." gold coins to use checkpoint.")
return false
else
doTeleportThing(cid, checkpoint.pos, false, true)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doSendMagicEffect(checkpoint.pos, CONST_ME_TELEPORT)
end
return false
end
How to use: insert more values in the CHECKPOINT_TELEPORT table, to add the price and position parameter to a checkpoint, in "[1]" <- here is the same id number of your checkpoint in the file "checkpoint.lua" ([1] is the id number of the checkpoont "Temple"), in "{price = 150, " <- is the price it will cost a player go to the checkpoint place (0 is free), in pos = "{x = 1000, y = 1000, z = 7 , stackpos = 1}}," <- is the known position table used comonly in OTS, here you add the position of checkpoints.
Well here are the system of checkpoints, if have a bug, report it here, I hope you enjoy
Last edited: