• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Auto-balance teams

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
I've used search, there are PLENTY of requests with no scripts in them.
There is one certain thread that caught my eye but the fact that Bogart kept bumping his thread gave me ill feelings as in something is not working there. (here is the thread: http://otland.net/f132/auto-team-balance-116572/)

What I am hoping to get is an auto-balance team script onLogin (two different teams red/blue; cannot attack teammate), also it would detect what globalStorage(if that's how you do it) it currently is so it can determine which map it is on because I also want a map "rotater" where every 20 minutes, the map will switch to the next one, something like that.

So if someone could make me those two scripts, that would be freakin' awesome, I might even put in a little bit of fee for it too.

Thanks,
e.MC (Lostboy)
 
team login:
Code:
local config = {
    team1Name = "Blue Assassins",
    team2Name = "Red Barbarians",
    team1 = 1002, -- Storage
    team2 = 1003, -- Storage
    }

local conditionBlue = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionBlue, {lookType = 152, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionRed, {lookType = 143, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})

function onLogin(cid)
	setPlayerStorageValue(cid, 1002, 0)
	setPlayerStorageValue(cid, 1003, 0)
        	if getGlobalStorageValue(1000) > getGlobalStorageValue(1001) then
           	 setPlayerStorageValue(cid, 1003, 1)
            	doAddCondition(cid, conditionBlue)
            	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1001, getGlobalStorageValue(1001)+1)
       	 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team1Name .. "!")          
        else
            setPlayerStorageValue(cid, 1002, 1)
            doAddCondition(cid, conditionRed)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1000, getGlobalStorageValue(1000)+1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team2Name .. "!")
        end
return true
end

team logout
Code:
function onLogout(cid)
    if getPlayerStorageValue(cid, 1002) == 1 then
        setGlobalStorageValue(1000, getGlobalStorageValue(1000)-1)
    elseif getPlayerStorageValue(cid, 1003) == 1 then
        setGlobalStorageValue(1001, getGlobalStorageValue(1001)-1)
        setPlayerStorageValue(cid, 1003, -1)
    end
return true
end
i use a MOD to change map, if you login in any character, it will teleport you to the current map, here is the mod
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Map Change" version="2.0" author="Syntax" contact="[email protected]" enabled="yes">
   <description>
        This should teleport all players to a new random town in intervals.
   </description>
	<config name="mapchange_config"><![CDATA[
		config = {
                access = 3, -- minimum access to bypass teleportation.
		temples = {1,2,3} --townids to teleport to.
		}
 ]]></config>
   <event type="login" name="Map Login" event="script"><![CDATA[
	function onLogin(cid)
		doPlayerSetTown(cid, getGlobalStorageValue(3454))
		doTeleportThing(cid, getPlayerMasterPos(cid))
	return true
	end
]]></event>
	<globalevent name="Map Change" interval="1000" event="script"><![CDATA[
	domodlib('mapchange_config')
		function onThink(interval, lastExecution, thinkInterval)
			repeat
				RDM = math.random(1,#config.temples)
			until RDM ~= getGlobalStorageValue(3454) and isInArray(config.temples, RDM)
			for _, pid in ipairs(getPlayersOnline()) do
				if getPlayerAccess(pid) < config.access then
					doPlayerSetTown(pid, config.temples[RDM])
					doTeleportThing(pid, getTownTemplePosition(config.temples[RDM]), false)
					doSendMagicEffect(getCreaturePosition(pid), 37)
					doRemoveCondition(pid, CONDITION_INFIGHT)
					doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
					doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
					setGlobalStorageValue(3454, config.temples[RDM])
				end
			end
		return true
		end
]]></globalevent>
</mod>
i use it, and it works perfect.

tho, i can't make work the 'cannot attack team mates'.
 
Last edited:
Back
Top