• 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 Whats wrong with this LUA?

Ghazer

Member
Joined
Mar 13, 2009
Messages
350
Reaction score
6
I have this MOD but one part doesn't work good... Is a part of combat... "players can not attack if have same condition" but that dont work and all players can attack all players.... Anyone know why doesn't work?

LUA:
   <event type="combat" name="tcom" event="script"><![CDATA[
domodlib('t')

function onCombat(cid, target)
	if isPlayer(cid) and isPlayer(target) then
	    if getPlayerStorageValue(cid, t.a[-1].b) == 1 and getPlayerStorageValue(target, t.a[-1].b) == 1 then
			return false
		end
		if getPlayerStorageValue(cid, t.a[1].b) == 1 and getPlayerStorageValue(target, t.a[1].b) == 1 then
			return false
		end
	end
	return true
end
]]>></event>


All script

LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Team War" version="1.0" author="Bogart" contact="otland.net" enabled="yes">
   <description>
        This should teleport all players to a new random town in intervals and add them into a team.
   </description>
	<config name="t"><![CDATA[
		t = {
			a = {
				[-1] = {
					a = "fagarians",
					b = 1002,
					c = "conditionRed"
				},
				[1] = {
					a = "homosexualsins",
					b = 1001,
					c = "conditionBlue"	
				},
			},
			b = 1000,
			c = 3,
			d = {1,3}
		}
		fromPosition = {x = 1444, y = 375, z = 0} -- north west corner (remember using z= 0 coz players might be on a higher floor)
		toPosition = {x = 1720, y = 620, z = 15} -- south east corner (remember using z= 15 coz players might be on a lower floor)
 ]]></config>
   <movevent type="StepIn" actionid ="8271" event="script"><![CDATA[
domodlib('t')
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 onStepIn(cid, item, pos)
    if getPlayerGroupId(cid) < 3 then
       if getGlobalStorageValue(t.b) == 1 then
			doPlayerSetTown(cid, getGlobalStorageValue(3454))
			doTeleportThing(cid, getPlayerMasterPos(cid))
			setPlayerStorageValue(cid, t.a[-1], 1)
			doAddCondition(cid, conditionRed)
			doPlayerSendTextMessage(cid, 21, "You're going to fight for the Red Sky so pew the shit out of the Saints of Valhalla")
			setGlobalStorageValue(t.b, -1)
          			else
					doPlayerSetTown(cid, getGlobalStorageValue(3454)+2)
					doTeleportThing(cid, getPlayerMasterPos(cid))
					setPlayerStorageValue(cid, t.a[1], 1)
					doAddCondition(cid, conditionBlue)
					doPlayerSendTextMessage(cid, 21, "You're going to fight for the Saints of Valhalla so pew the shit out of the Red Sky")
					setGlobalStorageValue(t.b, 1)
				end
			end
	return TRUE
end
]]></movevent>
<event type="logout" name="tout" event="script"><![CDATA[
domodlib('t')
function onLogout(cid)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
		setPlayerStorageValue(cid, t.a[-1].b, -1)
    	setGlobalStorageValue(t.b, 1)
             elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
		setPlayerStorageValue(cid, t.a[1].b, -1)
    	setGlobalStorageValue(t.b, -1)
    end
return true
end
]]></event>
   <event type="login" name="register" event="script"><![CDATA[
domodlib('t')
function onLogin(cid)
	registerCreatureEvent(cid, "tded")
	registerCreatureEvent(cid, "tout")	
	registerCreatureEvent(cid, "tcom")
return true
end
]]></event>
<movevent type="StepIn" actionid ="8272" event="script"><![CDATA[
domodlib('t')
function onStepIn(cid, item, pos)
    if getPlayerStorageValue(cid, t.a[-1]) == 1 then
	setPlayerStorageValue(cid, t.a[-1], 0)
    	setGlobalStorageValue(t.b, 1)
             elseif getPlayerStorageValue(cid, t.a[1]) == 1 then
			setPlayerStorageValue(cid, t.a[-1], 0)
			setGlobalStorageValue(t.b, -1)
		end
	return true
end
]]></movevent>
   <event type="prepareDeath" name="tded" event="script"><![CDATA[
domodlib('t')
function onPrepareDeath(cid)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
		setPlayerStorageValue(cid, t.a[-1].b, -1)
    	setGlobalStorageValue(t.b, 1)
             elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
		setPlayerStorageValue(cid, t.a[1].b, -1)
    	setGlobalStorageValue(t.b, -1)
    end
return true
end
 
]]></event>
   <event type="combat" name="tcom" event="script"><![CDATA[
domodlib('t')

function onCombat(cid, target)
	if isPlayer(cid) and isPlayer(target) then
	    if getPlayerStorageValue(cid, t.a[-1].b) == 1 and getPlayerStorageValue(target, t.a[-1].b) == 1 then
			return false
		end
		if getPlayerStorageValue(cid, t.a[1].b) == 1 and getPlayerStorageValue(target, t.a[1].b) == 1 then
			return false
		end
	end
	return true
end
]]>></event>
<globalevent name="Map Change" interval="1200000" event="script"><![CDATA[
domodlib('t')
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 and isInRange(getThingPosition(pid), fromPosition, toPosition) then
			doPlayerSetTown(pid, config.temples[RDM])
			doTeleportThing(pid, (getTownTemplePosition(config.temples[RDM])), false)				doRemoveCondition(pid, CONDITION_INFIGHT)
			doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
			doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
    			doBroadcastMessage("Map has been changed to "..getTownName(config.temples[RDM]).."! next map change will be in 20 minutes! have a nice fight!", MESSAGE_STATUS_WARNING)
			setGlobalStorageValue(3454, config.temples[RDM])
		end
	end
	return true	
end
]]></globalevent>	
</mod>
 
Try this and post the reports, so i can see if the script works, also it will print on the console when you try target the player.
LUA:
<event type="combat" name="tcom" event="script"><![CDATA[
domodlib('t')
 
function onCombat(cid, target)
	if isPlayer(cid) and isPlayer(target) then
	    if getPlayerStorageValue(cid, t.a[-1].b) == 1 and getPlayerStorageValue(target, t.a[-1].b) == 1 then
		print("Cyko Report Stage 1")
			return false
		end
		if getPlayerStorageValue(cid, t.a[1].b) == 1 and getPlayerStorageValue(target, t.a[1].b) == 1 then
		print("Cyko Report Stage 2")
			return false
		end
	end
	return true
end
]]>></event>
 
I test and I dont have errors in console, but I can attack all players... dont considerer if are of same team (same team = same storage)
 
Im not looking for errors, im just wanna know did you recive any prints, when you atking someone?
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Team War" version="1.0" author="Bogart" contact="otland.net" enabled="yes">
   <description>
        This should teleport all players to a new random town in intervals and add them into a team.
   </description>
	<config name="t"><![CDATA[
		t = {
			a = {
				[-1] = {
					a = "fagarians",
					b = 1002,
					c = "conditionRed"
				},
				[1] = {
					a = "homosexualsins",
					b = 1001,
					c = "conditionBlue"	
				},
			},
			b = 1000,
			c = 3,
			d = {1,3}
		}
		fromPosition = {x = 1444, y = 375, z = 0} -- north west corner (remember using z= 0 coz players might be on a higher floor)
		toPosition = {x = 1720, y = 620, z = 15} -- south east corner (remember using z= 15 coz players might be on a lower floor)
 ]]></config>
   <movevent type="StepIn" actionid ="8271" event="script"><![CDATA[
domodlib('t')
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 onStepIn(cid, item, pos)
    if getPlayerGroupId(cid) < 3 then
       if getGlobalStorageValue(t.b) == 1 then
			doPlayerSetTown(cid, getGlobalStorageValue(3454))
			doTeleportThing(cid, getPlayerMasterPos(cid))
			setPlayerStorageValue(cid, t.a[-1].b, 1)
			doAddCondition(cid, conditionRed)
			doPlayerSendTextMessage(cid, 21, "You're going to fight for the Red Sky so pew the shit out of the Saints of Valhalla")
			setGlobalStorageValue(t.b, -1)
        else
            doPlayerSetTown(cid, getGlobalStorageValue(3454)+2)
            doTeleportThing(cid, getPlayerMasterPos(cid))
            setPlayerStorageValue(cid, t.a[1].b, 1)
            doAddCondition(cid, conditionBlue)
            doPlayerSendTextMessage(cid, 21, "You're going to fight for the Saints of Valhalla so pew the shit out of the Red Sky")
            setGlobalStorageValue(t.b, 1)
		end
	end
	return true
end
]]></movevent>
<event type="logout" name="tout" event="script"><![CDATA[
domodlib('t')
function onLogout(cid)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
		setPlayerStorageValue(cid, t.a[-1].b, -1)
    	setGlobalStorageValue(t.b, 1)
    elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
		setPlayerStorageValue(cid, t.a[1].b, -1)
    	setGlobalStorageValue(t.b, -1)
    end
return true
end
]]></event>
   <event type="login" name="register" event="script"><![CDATA[
domodlib('t')
function onLogin(cid)
	registerCreatureEvent(cid, "tded")
	registerCreatureEvent(cid, "tout")	
	registerCreatureEvent(cid, "tcom")
return true
end
]]></event>
<movevent type="StepIn" actionid ="8272" event="script"><![CDATA[
domodlib('t')
function onStepIn(cid, item, pos)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
        setPlayerStorageValue(cid, t.a[-1].b, 0)
    	setGlobalStorageValue(t.b, 1)
    elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
        setPlayerStorageValue(cid, t.a[-1].b, 0)
        setGlobalStorageValue(t.b, -1)
	end
	return true
end
]]></movevent>
   <event type="prepareDeath" name="tded" event="script"><![CDATA[
domodlib('t')
function onPrepareDeath(cid)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
		setPlayerStorageValue(cid, t.a[-1].b, -1)
    	setGlobalStorageValue(t.b, 1)
    elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
		setPlayerStorageValue(cid, t.a[1].b, -1)
    	setGlobalStorageValue(t.b, -1)
    end
return true
end
 
]]></event>
   <event type="combat" name="tcom" event="script"><![CDATA[
domodlib('t')
 
function onCombat(cid, target)
	if isPlayer(cid) and isPlayer(target) then
	    if getPlayerStorageValue(cid, t.a[-1].b) == 1 and getPlayerStorageValue(target, t.a[-1].b) == 1 then
			return false
		end
		if getPlayerStorageValue(cid, t.a[1].b) == 1 and getPlayerStorageValue(target, t.a[1].b) == 1 then
			return false
		end
	end
	return true
end
]]>></event>
<globalevent name="Map Change" interval="1200000" event="script"><![CDATA[
domodlib('t')
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 and isInRange(getThingPosition(pid), fromPosition, toPosition) then
			doPlayerSetTown(pid, config.temples[RDM])
			doTeleportThing(pid, (getTownTemplePosition(config.temples[RDM])), false)				doRemoveCondition(pid, CONDITION_INFIGHT)
			doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
			doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
    			doBroadcastMessage("Map has been changed to "..getTownName(config.temples[RDM]).."! next map change will be in 20 minutes! have a nice fight!", MESSAGE_STATUS_WARNING)
			setGlobalStorageValue(3454, config.temples[RDM])
		end
	end
	return true	
end
]]></globalevent>	
</mod>
 
@Summ I can not attack any player... No damage
All examples if are team, if no are team, without team, etc...
________________
KbmuA.png

________________
LG5iX.png

________________
5ASd8.png

________________
348ceb2f026642b9b941cae.png
 
Check:
/storage Miami, 1001
/storage Miami, 1002

/storage Testing, 1001
/storage Testing, 1002
 
@Cyko... I edit script of Summ and put your part and I have this in console
SKJPG.png

But I cant not attack any player.

- - - Updated - - -

@Summ
A0hTi.png

Colors team when checking
522C4.png


Whats wrong? )=
 
Last edited:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Team War" version="1.0" author="Bogart" contact="otland.net" enabled="yes">
   <description>
        This should teleport all players to a new random town in intervals and add them into a team.
   </description>
	<config name="t"><![CDATA[
		t = {
			a = {
				[-1] = {
					a = "fagarians",
					b = 1002,
					c = "conditionRed"
				},
				[1] = {
					a = "homosexualsins",
					b = 1001,
					c = "conditionBlue"	
				},
			},
			b = 1000,
			c = 3,
			d = {1,3}
		}
		fromPosition = {x = 1444, y = 375, z = 0} -- north west corner (remember using z= 0 coz players might be on a higher floor)
		toPosition = {x = 1720, y = 620, z = 15} -- south east corner (remember using z= 15 coz players might be on a lower floor)
 ]]></config>
   <movevent type="StepIn" actionid ="8271" event="script"><![CDATA[
domodlib('t')
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 onStepIn(cid, item, pos)
    if getPlayerGroupId(cid) < 3 then
       if getGlobalStorageValue(t.b) == 1 then
			doPlayerSetTown(cid, getGlobalStorageValue(3454))
			doTeleportThing(cid, getPlayerMasterPos(cid))
			setPlayerStorageValue(cid, t.a[-1].b, 1)
			setPlayerStorageValue(cid, t.a[1].b, -1)
			doAddCondition(cid, conditionRed)
			doPlayerSendTextMessage(cid, 21, "You're going to fight for the Red Sky so pew the shit out of the Saints of Valhalla")
			setGlobalStorageValue(t.b, -1)
        else
            doPlayerSetTown(cid, getGlobalStorageValue(3454)+2)
            doTeleportThing(cid, getPlayerMasterPos(cid))
            setPlayerStorageValue(cid, t.a[1].b, 1)
            setPlayerStorageValue(cid, t.a[-1].b, -1)
            doAddCondition(cid, conditionBlue)
            doPlayerSendTextMessage(cid, 21, "You're going to fight for the Saints of Valhalla so pew the shit out of the Red Sky")
            setGlobalStorageValue(t.b, 1)
		end
	end
	return true
end
]]></movevent>
<event type="logout" name="tout" event="script"><![CDATA[
domodlib('t')
function onLogout(cid)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
		setPlayerStorageValue(cid, t.a[-1].b, -1)
    	setGlobalStorageValue(t.b, 1)
    elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
		setPlayerStorageValue(cid, t.a[1].b, -1)
    	setGlobalStorageValue(t.b, -1)
    end
return true
end
]]></event>
   <event type="login" name="register" event="script"><![CDATA[
domodlib('t')
function onLogin(cid)
	registerCreatureEvent(cid, "tded")
	registerCreatureEvent(cid, "tout")	
	registerCreatureEvent(cid, "tcom")
return true
end
]]></event>
<movevent type="StepIn" actionid ="8272" event="script"><![CDATA[
domodlib('t')
function onStepIn(cid, item, pos)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
        setPlayerStorageValue(cid, t.a[-1].b, 0)
    	setGlobalStorageValue(t.b, 1)
    elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
        setPlayerStorageValue(cid, t.a[-1].b, 0)
        setGlobalStorageValue(t.b, -1)
	end
	return true
end
]]></movevent>
   <event type="prepareDeath" name="tded" event="script"><![CDATA[
domodlib('t')
function onPrepareDeath(cid)
    if getPlayerStorageValue(cid, t.a[-1].b) == 1 then
		setPlayerStorageValue(cid, t.a[-1].b, -1)
    	setGlobalStorageValue(t.b, 1)
    elseif getPlayerStorageValue(cid, t.a[1].b) == 1 then
		setPlayerStorageValue(cid, t.a[1].b, -1)
    	setGlobalStorageValue(t.b, -1)
    end
return true
end
 
]]></event>
   <event type="combat" name="tcom" event="script"><![CDATA[
domodlib('t')
 
function onCombat(cid, target)
	if isPlayer(cid) and isPlayer(target) then
	    if getPlayerStorageValue(cid, t.a[-1].b) == 1 and getPlayerStorageValue(target, t.a[-1].b) == 1 then
			return false
		end
		if getPlayerStorageValue(cid, t.a[1].b) == 1 and getPlayerStorageValue(target, t.a[1].b) == 1 then
			return false
		end
	end
	return true
end
]]>></event>
<globalevent name="Map Change" interval="1200000" event="script"><![CDATA[
domodlib('t')
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 and isInRange(getThingPosition(pid), fromPosition, toPosition) then
			doPlayerSetTown(pid, config.temples[RDM])
			doTeleportThing(pid, (getTownTemplePosition(config.temples[RDM])), false)				doRemoveCondition(pid, CONDITION_INFIGHT)
			doCreatureAddHealth(pid, getCreatureMaxHealth(pid))
			doCreatureAddMana(pid, (getCreatureMaxMana(pid) - getCreatureMana(pid)))
    			doBroadcastMessage("Map has been changed to "..getTownName(config.temples[RDM]).."! next map change will be in 20 minutes! have a nice fight!", MESSAGE_STATUS_WARNING)
			setGlobalStorageValue(3454, config.temples[RDM])
		end
	end
	return true	
end
]]></globalevent>	
</mod>
 
@Summ, It works perfectly, really thank you very much:)

- - - Updated - - -

I have other problem... This part doesn't work without errors in console.

LUA:
<movevent type="StepIn" actionid ="8272" event="script"><![CDATA[
domodlib('t')
function onStepIn(cid, item, pos)
    if getPlayerStorageValue(cid, t.a[-1]) == 1 then
	setPlayerStorageValue(cid, t.a[-1], 0)
    	setGlobalStorageValue(t.b, 1)
             elseif getPlayerStorageValue(cid, t.a[1]) == 1 then
			setPlayerStorageValue(cid, t.a[-1], 0)
			setGlobalStorageValue(t.b, -1)
		end
	return true
end
]]></movevent>

Summ help please... this actionid is for out of team battle I need this please, because I dont use event on all maps only in two maps of 6
 
Last edited:
Back
Top