• 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!

Lua ChangeMap Bug | Please Fix it!

soulest

New Member
Joined
Nov 30, 2009
Messages
5
Reaction score
0
Good Evening:

This script used to change the map each time interval runs but has a bug: when players connect newly created, players not in the moment city because appear in the first city.

Also, if I bring these people to the moment city, and then I make a kick, they do not appear in the first moment city, but they remained in the city of the moment before; this means that the script does not work for players created new ones, because the system does not teleports the people where all players are playing. Finally, I use a TFS SVN_04 and msyql.

Please help men! (if you can fix this script please)

Code:
local config, new = {
	minTownId = 1,
	maxTownId = 6
}, 0
function onThink(interval, lastExecution)
	for _, pid in ipairs(getPlayersOnline()) do
		local town = getPlayerTown(pid)
		new = town < config.maxTownId and town + 1 or config.minTownId
		doPlayerSetTown(pid, new)
		doTeleportThing(pid, getTownTemplePosition(new))
		doRemoveConditions(pid)
		doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
		doCreatureAddMana(pid, getCreatureMaxMana(pid))
    		doBroadcastMessage("Map has been changed! Next map change will be in 30 minutes!", MESSAGE_STATUS_WARNING)
	end
	db.executeQuery("UPDATE players SET town_id = ".. new ..", posx = 0, posy = 0, posz = 0;")
	return true
end
 
a possible solution to this problem is to connect players ever in the town number that corresponds to the city that plays at that time I think ... please help!
 
store townid in storage in the globalevent with doSetStorage(123, new)
and use doTeleportThing(cid, getTownTemplePosition(getStorage(123))) in onLogin
 
Author Vodkart from other forum:

MODS

ChangeMap.xml
Lua:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="ChangeMap" version="1.0" author="Vodkart" contact="xtibia.com" enabled="yes">  
<config name="map_func"><![CDATA[  

                      info = {  
                        [0] = {x=160,y=54,z=7},  
                        [1] = {x=205,y=30,z=6},  
                        [2] = {x=304,y=205,z=7},  
                        [3] = {x=412,y=100,z=5},  
                        [4] = {x=884,y=151,z=6},  
                        [5] = {x=1102,y=1001,z=7}  
                        }
                        storage = 50555  

]]></config>
<event type="login" name="Check Map" event="script"><![CDATA[  
domodlib('map_func')  
        function onLogin(cid)
        if getGlobalStorageValue(storage) == -1 then
        setGlobalStorageValue(storage,getGlobalStorageValue(storage)+1)  
        end
        doTeleportThing(cid,info[getGlobalStorageValue(storage)])  
        return true  
end  
]]></event>
        <globalevent name="ChangeMap" interval="3600" event="script"><![CDATA[  
        domodlib('map_func')  
        function onThink(interval, lastExecution)  
                doBroadcastMessage('The map will be changed again in 1 hour.')
                if getGlobalStorageValue(storage) < #info then  
                setGlobalStorageValue(storage,getGlobalStorageValue(storage)+1)  
                else  
                setGlobalStorageValue(storage,getGlobalStorageValue(storage)-#info)
                end  
                for _, pid in ipairs(getPlayersOnline()) do
                doRemoveConditions(pid, true)
                doTeleportThing(pid,info[getGlobalStorageValue(storage)])    
                end  
         return TRUE  
end]]></globalevent>
</mod>
 
Back
Top