MoveEvent Soccer system

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
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:
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
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:
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
change there also position of the middle field.

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
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
 
Last edited:

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
Nice work, Fare-Fray. Nice of you to release it. :)
 

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Best answers
0
Reaction score
0
I got question for what is teleport on middle ? I will be lil brokin game ;>
 
OP
Fare

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
when team got teleported to football field, teleport dissapear, and when match is ended, teleported appear ;> it's kinda a checkpoint, if field free or not ;>
@Empty, thanks
 

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Best answers
0
Reaction score
0
I did everything and when I want move switch it says:

02:10 Need wait until previous command will end the match!
 
OP
Fare

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
Did you changed position in actions\scripts\football.lua, so teleport(id1387)(which is middle of the soccers field), is in this position?
local teleportpos = {x=72, y=384, z=7, stackpos=1} --middle of your soccer field, ball will spawn here
 

Massen

Masserv RPG
Joined
Jul 23, 2007
Messages
325
Best answers
0
Reaction score
1
Location
Sweden
I get this error when a match is complete and the last person leaves the field through the teleporter

Code:
[10/11/2008  08:57:53] Lua Script Error: [MoveEvents Interface] 
[10/11/2008  08:57:53] data/movements/scripts/footballteleport.lua:onStepIn

[10/11/2008  08:57:53] luaGetThingfromPos(). Tile not found
Do you know why?

//Massen
 
OP
Fare

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
I get this error when a match is complete and the last person leaves the field through the teleporter

Code:
[10/11/2008  08:57:53] Lua Script Error: [MoveEvents Interface] 
[10/11/2008  08:57:53] data/movements/scripts/footballteleport.lua:onStepIn

[10/11/2008  08:57:53] luaGetThingfromPos(). Tile not found
Do you know why?

//Massen
open footballteleport.lua
There is also
local teleportPosition = {x=72, y=384, z=7, stackpos=1}
on line 20, change coordinates to your teleport coords(middle of the field)
 

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Best answers
0
Reaction score
0
ok its working now but I got problem with teleport when game ends. When one player enter tp, the teleport just dissapear and not teleporting other players 0.o
 
Last edited:
OP
Fare

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
ok its working now but I got problem with teleport when game ends. When one player enter tp, the teleport just dissapear and not teleporting other players 0.o
Try this one data\actions\scripts\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
 

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Best answers
0
Reaction score
0
ok :) I have question, is there any time of game? because when someone will put the ball out of game place, they cant finish, and cant exit 0.o
 
OP
Fare

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
hmm...simpliest way to make it clean, it's to make 2x lines of walls around field. Or maybe I will add something for this... but not today ;d
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,667
Best answers
202
Reaction score
1,375
Location
Norway, Oslo
Nice! Perhaps i'll add it to my server again. I remember I had a soccer field on my OT back at 7.92 HAHGA
 

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Best answers
0
Reaction score
0
My proposition is to make 3-4 minutes rounds :p first and second ^^

what do u think?
 
OP
Fare

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
My proposition is to make 3-4 minutes rounds :p first and second ^^

what do u think?
yeah, it will be nice, but for this, I must rewrite 50% of script ;d badly I didn't have time for this, working on another scripts... maybe on weekend ;\
 
Top