Hi there, im having issues with CTF mod, my script mostly works but when someone takes the flag and captures it, it says Blue team flag: -1/3 captures. Im not sure how to fix this. Please help me out, would be much appreciated.
Im gonna send 3 replies of the rest of the code as it is too long.
First part of ctf.xml
Im gonna send 3 replies of the rest of the code as it is too long.
First part of ctf.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="CTF" version="1.0" author="Doggynub" contact="otland.net" enabled="yes">
<config name="toto"><![CDATA[
--[[ Storage Settings]]--
Owner = 1900 -- put empty storage
FLAG2_INn = 44000 -- put empty storage
FLAG_IN = 44001 -- put empty storage
TEAM1_FLAGS = 33056 -- put empty storage
TEAM2_FLAGS = 33057 -- put empty storage
Event_Start = 3032 -- put empty storage
Event_timeend = 3033 -- put empty storage
Event_Tile_Close = 3039 -- put empty storage
joined = 2023 --put empty storage
Timer = 1010 --put empty storage
--------------------------------------
--[[ Places setting ]]--
BLUE_FLAG = {x=16799,y=16280,z=6} -- Blue flag Place
RED_FLAG = {x=16851,y=16280,z=6} --red flag Place
Tp_Place = {x=32310,y=32204,z=7} -- Place where the event teleport will be created.
Wait_Place = {x=16791, y=16345, z=7} -- Positions Players will be sent when the enter event's teleport
frompos = {x=16787,y=16340,z=7} --start sqm in the waiting room(1 floor)
topos = {x=16795,y=16348,z=7} -- end sqm in the waiting room(1 floor)
Red_Position = {x=16849,y=16280,z=7} -- Red team temple pos
Blue_Position = {x=16801,y=16280,z=7} -- Blue team temple pos
---------------------------------------
--[[Event setting ]]--
Event_WaitTime = 5 -- time for the collection of player then event will start (in minutes)
Event_MaxTime = 15 --- in minutes ( this is the max time for an event to bb running )
Players_Speed = 175 -- put the level of base speed in event ( like if you want the speed of lvl 300 then wright 300)
TEAM2_NAME = "Red" -- team 2 name
TEAM1_NAME = "Blue" -- team 1 name
FLAG_SCORE = 3 -- score when team gets he wins
Teleport_On_Score = true -- this teleport all players to their team main position when some one score a flag , make false to disable.
Players_Least_Number = 4 -- this means if there is less than 2 players joined the event will be cancelled
Min_Join_Level = 100 -- min lvl for a player to join event
rewards_random = {
[60] = { -- Rewards of 60% , if it is then it will randomly give one of the items in the items verible if there you put more than one item there
items = {6542,2284,2433}
},
[30] = { -- Rewards of 30%
items = {3982,9928,2496}
},
[10] = { -- Rewards of 10%
items = {2309,6512,8890}
}
}
]]></config>
<lib name="CTF-lib"><![CDATA[
function isTeamTwo(cid)
return (isPlayer(cid) and getPlayerStorageValue(cid,5054) > -1)
end
function isTeamOne(cid)
return (isPlayer(cid) and getPlayerStorageValue(cid,5055) > -1)
end
function resetTheTeams(cid)
return (isPlayer(cid) and setPlayerStorageValue(cid,5054,-1) and setPlayerStorageValue(cid,5055,-1))
end
function setflagOwner(cid)
return setPlayerStorageValue(cid,Owner,1)
end
function flagOwner(cid)
return (isPlayer(cid) and getPlayerStorageValue(cid,Owner) > 0)
end
function releaseBF(cid)
setGlobalStorageValue(FLAG_IN,-1)
setPlayerStorageValue(cid,103, 0)
setPlayerStorageValue(cid,Owner,-1)
return true
end
function releaseRF(cid)
setGlobalStorageValue(FLAG2_INn,-1)
setPlayerStorageValue(cid,103, 0)
setPlayerStorageValue(cid,Owner,-1)
return true
end
function setFirstTeam(cid)
return setPlayerStorageValue(cid,5055,1)
end
function setSecondTeam(cid)
return setPlayerStorageValue(cid,5054,2)
end
function addToRed()
return setGlobalStorageValue(TEAM2_FLAGS,getGlobalStorageValue(TEAM2_FLAGS)+1)
end
function addToBlue()
return setGlobalStorageValue(TEAM1_FLAGS,getGlobalStorageValue(TEAM1_FLAGS)+1)
end
function getBlueScore()
return getGlobalStorageValue(TEAM1_FLAGS)
end
function getRedScore()
return getGlobalStorageValue(TEAM2_FLAGS)
end
function getTheSpeed(level)
value = (220 +(2 *(level -1)))
return value
end
function resetTheStorage()
setGlobalStorageValue(Event_Start,-1)
setGlobalStorageValue(Event_timeend,-1)
setGlobalStorageValue(TEAM1_FLAGS,0)
setGlobalStorageValue(FLAG2_INn,-1)
setGlobalStorageValue(FLAG_IN,-1)
setGlobalStorageValue(TEAM2_FLAGS,0)
return true
end
function blueStolen()
return getGlobalStorageValue(FLAG_IN)
end
function redStolen()
return getGlobalStorageValue(FLAG2_INn)
end
function giveReward(cid)
local t = math.random(1,100)
if t <= 10 then
local rare = rewards_random[10].items[math.random(1,#rewards_random[10].items)]
doPlayerAddItem(cid,rare,1)
doPlayerSendTextMessage(cid,25,"Rare rate Reward : you won "..getItemNameById(rare)..".")
elseif t > 10 and t <= 40 then
local semi = rewards_random[30].items[math.random(1,#rewards_random[30].items)]
doPlayerAddItem(cid,semi,1)
doPlayerSendTextMessage(cid,25,"Semi rate Reward : you won "..getItemNameById(semi)..".")
elseif t > 40 then
local aver = rewards_random[60].items[math.random(1,#rewards_random[60].items)]
doPlayerAddItem(cid,aver,1)
doPlayerSendTextMessage(cid,25,"Averege rate Reward : you won "..getItemNameById(aver)..".")
end
return true
end
]]></lib>
<event type="login" name="Tutorial Login" event="script"><![CDATA[
domodlib('toto')
domodlib('CTF-lib')
function onLogin(cid)
if getGlobalStorageValue(Event_Start) < 1 then
if isTeamOne(cid) or isTeamTwo(cid) then
resetTheTeams(cid)
end
end
registerCreatureEvent(cid, "Attk")
registerCreatureEvent(cid, "ctff")
registerCreatureEvent(cid, "prepare")
return true
end
]]></event>
<event type="combat" name="Attk" event="script"><![CDATA[
domodlib('toto')
domodlib('CTF-lib')
function onCombat(cid, target)
if isTeamOne(cid) and isTeamOne(target) then
return false
end
if isTeamTwo(cid) and isTeamTwo(target) then
return false
end
return true
end
]]></event>
<event type="statschange" name="prepare" event="script"><![CDATA[
domodlib('toto')
domodlib('CTF-lib')