• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua globalevents

Skoczi

New Member
Joined
Jun 6, 2012
Messages
115
Reaction score
0
Hello.

Can someone convert this script. If vocation x add the effect x every 2 seconds

Code:
function onThink(interval, lastExecution)

if getPlayerVocation(cid) == 143 then	             
		doSendMagicEffect(getPlayerPosition(cid), 6)
      

      end
   end
 
Hello.

Can someone convert this script. If vocation x add the effect x every 2 seconds

Code:
function onThink(interval, lastExecution)

if getPlayerVocation(cid) == 143 then	             
		doSendMagicEffect(getPlayerPosition(cid), 6)
      

      end
   end

Like this?
LUA:
function onThink(interval, lastExecution)

if getPlayerVocation(cid) == 143 then	             
		doSendMagicEffect(getPlayerPosition(cid), 6)
	elseif getPlayerVocation(cid) == xx then	             
		doSendMagicEffect(getPlayerPosition(cid), x)
	elseif getPlayerVocation(cid) == xx then	             
		doSendMagicEffect(getPlayerPosition(cid), x)
	elseif getPlayerVocation(cid) == xx then	             
		doSendMagicEffect(getPlayerPosition(cid), x)
   		return true	
      end
   end

LUA:
	<globalevent name="xxxx" interval="2000" event="script" value="xxxx.lua"/>
 
Should work now, this time i tested it myself and realized what was missing.
LUA:
function onThink(interval, lastExecution)
         for _, name in ipairs(getOnlinePlayers()) do
         local cid = getPlayerByName(name)
if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 then	             
		doSendMagicEffect(getPlayerPosition(cid), 40)
	elseif getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 then	             
		doSendMagicEffect(getPlayerPosition(cid), 40)
	elseif getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7 then	             
		doSendMagicEffect(getPlayerPosition(cid), 40)
	elseif getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then	             
		doSendMagicEffect(getPlayerPosition(cid), 40)
               end
         end
         return true
end

doSendMagicEffect(getPlayerPosition(cid), 40) -- replace 40 with your own effect.
Also should work for both characters - promoted and not promoted.
 
LUA:
function onThink()
	for _, cid in ipairs(getPlayersOnline()) do
		if isInArray({1, 5}, getPlayerVocation(cid)) then
			doSendMagicEffect(getThingPosition(cid), CONST_ME_BIGCLOUDS)
		end
	end
	return true
end
 
LUA:
function onThink()
	for _, cid in ipairs(getPlayersOnline()) do
		if isInArray({1, 5}, getPlayerVocation(cid)) then
			doSendMagicEffect(getThingPosition(cid), CONST_ME_BIGCLOUDS)
		end
	end
	return true
end

what about different effects for different vocations? ;)
 
what about different effects for different vocations? ;)
he never specified if there's several vocations, so it's up to him to copypaste

@OP try adding a print call in the function such as print("test") to see if the globalevent runs at all :p
post your globalevents.xml line and make sure you're not using milliseconds and your server treats them as seconds
 
Back
Top