Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- checkpoint={}
- function eventNewGame()
- checkpoint={}
- end
- function eventNewPlayer(name)
- tfm.exec.bindKeyboard(name,69,true,true)
- tfm.exec.bindKeyboard(name,70,true,true)
- tfm.exec.bindKeyboard(name,65,true,true)
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventPlayerWon(name)
- checkpoint[name]=nil
- tfm.exec.respawnPlayer(name)
- end
- function eventPlayerDied(name)
- tfm.exec.respawnPlayer(name)
- if checkpoint[name] then
- tfm.exec.movePlayer(name,checkpoint[name].x,checkpoint[name].y,false,1,1,false)
- if checkpoint[name].cheese then
- tfm.exec.giveCheese(name)
- end
- end
- end
- function eventKeyboard(name,key,down,x,y)
- if key==69 then
- tfm.exec.chatMessage("<VP>Checkpoint set (<N>"..x.." "..y.."<VP>)",name)
- checkpoint[name]={
- cheese=tfm.get.room.playerList[name].hasCheese,
- x=x,
- y=y
- }
- elseif key==70 then
- if checkpoint[name] and tfm.get.room.playerList[name].hasCheese and not checkpoint[name].cheese then
- tfm.exec.killPlayer(name)
- else
- eventPlayerDied(name)
- end
- elseif key==65 then
- tfm.exec.chatMessage("<VP>Checkpoint cleared",name)
- checkpoint[name]=nil
- end
- end
- function eventChatCommand(name,message)
- local args={}
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg)
- end
- if args[1]=="goto" then
- local player=tfm.get.room.playerList[args[2]]
- local offset=false
- if player then
- args[4]=args[3]
- args[2]=player.x
- args[3]=player.y
- end
- if args[4]=="offset" then
- offset=true
- elseif args[4]=="checkpoint" then
- eventKeyboard(name,69,true,args[2],args[3])
- end
- tfm.exec.movePlayer(name,args[2],args[3],offset,1,1,false)
- elseif args[1]=="time" then
- tfm.exec.setGameTime(60*6)
- elseif args[1]=="cheese" then
- tfm.exec.giveCheese(name)
- end
- end
- tfm.exec.chatMessage("<VP>Running checkpoint.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement