Hello, I want to release one of my last works, it is soccer system.
Credits for idea goes for Ecration and Tokubasher, also to me for scripts.
Features:
*Just 2 team on soccer field(3 players in each team).
*Broadcast of every goal maked
*Game over if one of the team make 3 goals, also broadcasting, which team won.
*After match ended, teleport appears, and next match can be started just if all teams(6 players) will leave soccers field(all field, is a non logout zone, so they can't logout and login when new match will be started)
Here is image, how it must be. Switch must be with uniqueid 15026, soccers gates must bewith actionid 15027,15028.Also it uses global storages 15024, 15025, 15026, 15027, so if you want use others, change it in scripts.
Now, script:
in action.xml add:
in actions\scripts add football.lua:
change there, your players positions(stone tiles), and position where ball must be spawned after goal(middle of the soccers field)
Next, add to movements.xml:
now, data\movements\scripts,create football.lua:
change there also position of the middle field.
and last movement, data\movements\scripts, create footballteleport.lua:
change there position of balls spawn(middle of the field), and also position where players must be teleported after match(in 2x places).
NOTE. This was done on TFS0.3 alpha3, I am not sure what it will work in mystic spirit.
I hope thats, all. Enjoy;]
p.s. Fixed footballteleport.lua missconfig, thanks for Massen
Credits for idea goes for Ecration and Tokubasher, also to me for scripts.
Features:
*Just 2 team on soccer field(3 players in each team).
*Broadcast of every goal maked
*Game over if one of the team make 3 goals, also broadcasting, which team won.
*After match ended, teleport appears, and next match can be started just if all teams(6 players) will leave soccers field(all field, is a non logout zone, so they can't logout and login when new match will be started)
Here is image, how it must be. Switch must be with uniqueid 15026, soccers gates must bewith actionid 15027,15028.Also it uses global storages 15024, 15025, 15026, 15027, so if you want use others, change it in scripts.
Now, script:
in action.xml add:
PHP:
<action uniqueid="15026" script="football.lua" />
in actions\scripts add football.lua:
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
--script maked by Fare, for otland community.
--position of players when pressing switch, change to yourselfs coordinates
local pos1 = {x=57, y=384, z=7, stackpos=1}
local pos2 = {x=56, y=383, z=7, stackpos=1}
local pos3 = {x=56, y=385, z=7, stackpos=1}
local pos4 = {x=87, y=384, z=7, stackpos=1}
local pos5 = {x=88, y=383, z=7, stackpos=1}
local pos6 = {x=88, y=385, z=7, stackpos=1}
-- end of positions
local player1 = getThingfromPos(pos1)
local player2 = getThingfromPos(pos2)
local player3 = getThingfromPos(pos3)
local player4 = getThingfromPos(pos4)
local player5 = getThingfromPos(pos5)
local player6 = getThingfromPos(pos6)
local teleportpos = {x=72, y=384, z=7, stackpos=1} --middle of your soccer field, ball will spawn here
local getteleport = getThingfromPos(teleportpos)
if getteleport.itemid == 1387 then
if isPlayer(player1.uid) == TRUE and isPlayer(player2.uid) == TRUE and isPlayer(player3.uid) == TRUE and isPlayer(player4.uid) == TRUE and isPlayer(player5.uid) == TRUE and isPlayer(player6.uid) == TRUE then
local pos11 = {x=63, y=384, z=7, stackpos=1}
local pos22 = {x=67, y=382, z=7, stackpos=1}
local pos33 = {x=67, y=386, z=7, stackpos=1}
local pos44 = {x=81, y=384, z=7, stackpos=1}
local pos55 = {x=77, y=382, z=7, stackpos=1}
local pos66 = {x=77, y=386, z=7, stackpos=1}
local team1 = getPlayerGUIDByName(getCreatureName(player1.uid))
local team2 = getPlayerGUIDByName(getCreatureName(player4.uid))
setGlobalStorageValue(15024, 0)
setGlobalStorageValue(15025, 0)
setGlobalStorageValue(15026, team1)
setGlobalStorageValue(15027, team2)
setGlobalStorageValue(15029, 0)
doBroadcastMessage("Football match with "..getPlayerName(player1.uid).."'s team and "..getPlayerName(player4.uid).."'s team started!", MESSAGE_EVENT_ADVANCE)
doTeleportThing(player1.uid,pos11,0)
doTeleportThing(player2.uid,pos22,0)
doTeleportThing(player3.uid,pos33,0)
doTeleportThing(player4.uid,pos44,0)
doTeleportThing(player5.uid,pos55,0)
doTeleportThing(player6.uid,pos66,0)
doRemoveItem(getteleport.uid,1)
doCreateItem(2109,1,teleportpos)
else
doPlayerSendTextMessage(cid, 22, "You need 2 teams, 3 players in each team, to start the match!")
end
else
doPlayerSendTextMessage(cid, 22, "Need wait until previous command will end the match!")
end
end
Next, add to movements.xml:
PHP:
<!--Football-->
<movevent event="AddItem" tileitem="1" actionid="15027" script="football.lua"/>
<movevent event="AddItem" tileitem="1" actionid="15028" script="football.lua"/>
<movevent event="StepIn" actionid="15029" script="footballteleport.lua"/>
now, data\movements\scripts,create football.lua:
PHP:
function onAddItem(moveitem, tileitem, position)
-- middle pos of soccers field, change it to position where ust be your ball spawned!
local ballpos = {x=72, y=384, z=7, stackpos=1}
local ball = getThingfromPos(ballpos)
local komanda1 = getPlayerNameByGUID(getGlobalStorageValue(15026))
local komanda2 = getPlayerNameByGUID(getGlobalStorageValue(15027))
if tileitem.actionid == 15027 and moveitem.itemid == 2109 then
local wet = getGlobalStorageValue(15025) + 1
local wet2 = getGlobalStorageValue(15024)
doRemoveItem(moveitem.uid, 1)
doSendMagicEffect(ballpos, 5)
setGlobalStorageValue(15025, wet)
if getGlobalStorageValue(15025) ~= 3 then
doCreateItem(2109, 1, ballpos)
end
doBroadcastMessage("GOOL!!! "..komanda2.."'s team score! "..wet2.." : " ..wet.. " !", MESSAGE_EVENT_ADVANCE)
if getGlobalStorageValue(15025) == 3 then
doBroadcastMessage("Game over! "..komanda2.."'s team win! "..wet2.." : " ..wet.. " !", MESSAGE_EVENT_ADVANCE)
doSetItemActionId(doCreateItem(8058, 1, ballpos), 15029)
end
elseif tileitem.actionid == 15028 and moveitem.itemid == 2109 then
local wet3 = getGlobalStorageValue(15024) + 1
local wet4 = getGlobalStorageValue(15025)
doRemoveItem(moveitem.uid, 1)
doSendMagicEffect(ballpos, 5)
setGlobalStorageValue(15024, wet3)
if getGlobalStorageValue(15024) ~= 3 then
doCreateItem(2109, 1, ballpos)
end
doBroadcastMessage("GOOL!!! "..komanda1.."'s team score! "..wet3.." : " ..wet4.. " !", MESSAGE_EVENT_ADVANCE)
if getGlobalStorageValue(15024) == 3 then
doBroadcastMessage("Game over! "..komanda1.."'s team win! "..wet3.." : " ..wet4.. " !", MESSAGE_EVENT_ADVANCE)
doSetItemActionId(doCreateItem(8058, 1, ballpos), 15029)
end
end
return TRUE
end
and last movement, data\movements\scripts, create footballteleport.lua:
PHP:
function onStepIn(cid, item, pos)
--soccer system by Fare, otland.net
if item.actionid == 15029 then
local position = {x=72, y=392, z=7, stackpos=255} -- where players must be teleported after match
local position2 = {x=72, y=384, z=7, stackpos=255} -- middle of the field(ball spawn)
local getplayer = getThingfromPos(position2)
doTeleportThing(getplayer.uid,position,0)
if getGlobalStorageValue(15029) == -1 or getGlobalStorageValue(15029) == 0 then
setGlobalStorageValue(15029, 2)
elseif getGlobalStorageValue(15029) == 2 then
setGlobalStorageValue(15029, 3)
elseif getGlobalStorageValue(15029) == 3 then
setGlobalStorageValue(15029, 4)
elseif getGlobalStorageValue(15029) == 4 then
setGlobalStorageValue(15029, 5)
elseif getGlobalStorageValue(15029) == 5 then
setGlobalStorageValue(15029, 6)
elseif getGlobalStorageValue(15029) == 6 then
setGlobalStorageValue(15029, 0)
local teleportPosition = {x=72, y=384, z=7, stackpos=1} -- middle of the field(ball spawn)
local getTeleport = getThingfromPos(teleportPosition)
if getTeleport.itemid == 8058 then
doRemoveItem(getTeleport.uid, 1)
doCreateItem(1387, 1, teleportPosition)
end
end
end
end
NOTE. This was done on TFS0.3 alpha3, I am not sure what it will work in mystic spirit.
I hope thats, all. Enjoy;]
p.s. Fixed footballteleport.lua missconfig, thanks for Massen
Last edited: