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

getSocket(cid) function [To audio module]

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
Only posting an function to Tibiando.

http://otland.net/f19/tibiando-audio-api-tibia-86952/

Code:
function getSocket(cid)
        if not dj then
             error('You have to install tibiando. The tibiando work ONLY in creaturescripts. This function too.')
        end
	for i,b in pairs(dj.online) do
		if b.cid == cid then
			return b[1]
		end
	end
end

You can do it:
Code:
function onKill(cid) --Function on kill
     if isPlayer(cid) then -- Check if the killer is a player
          local sock = getSocket(cid) --- Get player socket
          if sock then  --- If player has audio
               sock:send('EF=kill.wav\n') --Send the music name to play
          end
     end
     return true -- return true :p
end

or:
Code:
function onLogin(cid)
     if getPlayerGroupid(cid) > 5 then
          for i,cid in pairs(getOnlinePlayers()) do
              local sock = getSocket(cid)
              if sock then
                  sock:send('EF=adm_online.mp3\n')
              end
          end
     end
end
 
this function works in actions, movements, etc... ?

------------
oh, sorry
The tibiando work ONLY in creaturescripts. This function too.

kkkkkk'
 
Last edited:
Just active TFS shared states, or use your creativity.
is not exactly simple...
#SHARED_STATES true
is not this... you have to remake like 30% of lua envoriment in server.
 
Isn't so hard to make this changes, after you thought about the logic, a lot of it is just copy and paste...
Anywhay, thanks. :)
 
Back
Top