Advertisement
Guest User

Untitled

a guest
Jul 19th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1. function onJoinChannel(cid, channelId, users, isTv)
  2.  
  3.  
  4.     if channelId == 10 then
  5.         doShowPokemonStatistics(cid)
  6.     return false
  7.     end
  8.  
  9.     if channelId == 11 then
  10.         if reloadHighscoresWhenUsingPc then
  11.             doReloadHighscores()
  12.         end
  13.         doPlayerPopupFYI(cid, getHighscoreString(8))
  14.     return false
  15.     end
  16.  
  17.     if channelId == 12 then
  18.         if reloadHighscoresWhenUsingPc then
  19.             doReloadHighscores()
  20.         end
  21.         doPlayerPopupFYI(cid, getHighscoreString(6))
  22.     return false
  23.     end
  24.  
  25.     if channelId >= 100 and channelId <= 10000 then
  26.  
  27.     local owner =  getPlayerByGUID(getChannelOwner(channelId))
  28.  
  29.         if isChannelTv(channelId) then
  30.             if isCreature(owner) then
  31.                 if owner ~= cid then
  32.                     doPlayerWatchOther(cid, owner)
  33.                     local plural = #users == 1 and "" or "s"
  34.                     doPlayerSendChannelMessage(owner, "TV Channel", getCreatureName(cid)..' is now watching your channel (currently '..#users..' player'..plural..' watching this channel).', 15, channelId)
  35.                 else
  36.                     setPlayerStorageValue(cid, 99284, 1)
  37.                 end
  38.             end
  39.         elseif owner == cid then
  40.             setPlayerStorageValue(cid, 99284, 2)
  41.         end
  42.  
  43.     return true
  44.     end
  45.  
  46. return true
  47. end
  48.  
  49. function onLeaveChannel(cid, channelId, users)
  50.  
  51.     if channelId >= 100 and channelId <= 10000 then
  52.  
  53.     local owner =  getPlayerByGUID(getChannelOwner(channelId))
  54.  
  55.         if isChannelTv(channelId) then
  56.             if owner ~= cid and getCreatureOutfit(cid).lookType == 814 then
  57.                 doPlayerStopWatching(cid)
  58.                 local plural = #users == 2 and "" or "s"
  59.                 doPlayerSendChannelMessage(owner, "TV Channel", getCreatureName(cid)..' is not watching your channel anymore (currently '..#users - (1)..' player'..plural..' watching this channel).', 15, channelId)
  60.             elseif owner == cid then
  61.                 setPlayerStorageValue(cid, 99284, -1)
  62.                 doSendAnimatedText(getThingPos(cid), "CAM OFF", 180)
  63.                 for stops = 1, #users do
  64.                     if users[stops] ~= owner then
  65.                         doPlayerStopWatching(users[stops])
  66.                     end
  67.                 end
  68.             end
  69.         elseif owner == cid then
  70.             setPlayerStorageValue(cid, 99284, -1)
  71.         end
  72.  
  73.     return true
  74.     end
  75.  
  76. return true
  77. end
  78.  
  79. function onWalk(cid, fromPosition, toPosition)
  80.  
  81.  
  82.  
  83.     -- Código não é mais necessário, feito em c++
  84.     -- Code deprecated, made in c++
  85.     --if not canWalkOnPos(toPosition, false, false, false, true, false) and getPlayerStorageValue(cid, 17000) >= 1 then
  86.     --  doTeleportThing(cid, fromPosition, false)
  87.     --  doPlayerSendCancel(cid, "Sorry, not possible.")
  88.     --end
  89.  
  90.     if getPlayerStorageValue(cid, 99284) <= 0 then return true end
  91.  
  92.     local speed = getCreatureSpeed(cid)
  93.     local a = getWatchingPlayersFromPos(cid, fromPosition)
  94.  
  95.     for b = 1, #a do
  96.         if getCreatureSpeed(a[b]) ~= speed then
  97.             doChangeSpeed(a[b], - getCreatureSpeed(a[b]))
  98.             doChangeSpeed(a[b], speed)
  99.         end
  100.         doTeleportThing(a[b], toPosition, true)
  101.     end
  102.  
  103. return true
  104. end
  105.  
  106. local permited = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
  107. "t", "u", "v", "x", "w", ",", "'", '"',
  108. "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ".", "!", "@", "#", "$", "%", "&", "*", "(", ")",
  109. "-", "_", "+", "/", ";", ":", "?", "^", "~", "{", "[", "}", "]", ">", "<", "£", "¢", "¬"}
  110.  
  111. function onTextEdit(cid, item, newText)
  112.  
  113.     if item.itemid == 12330 then
  114.  
  115.         if getPlayerStorageValue(cid, 99284) >= 1 then
  116.             doPlayerSendCancel(cid, "You are already on air!")
  117.         return false
  118.         end
  119.  
  120.         local channelName = getCreatureName(cid).."'s TV Channel"
  121.  
  122.         if string.len(newText) <= 0 then
  123.             doPlayerSendCancel(cid, "Your channel is going to be shown as \""..getCreatureName(cid).."'s TV Channel\".")
  124.         elseif string.len(newText) > 25 then
  125.             doPlayerSendCancel(cid, "Your channel name can't have more than 25 characters.")
  126.         return false
  127.         else
  128.             channelName = newText
  129.         end
  130.  
  131.  
  132.         setPlayerStorageValue(cid, 99284, 1)
  133.         setPlayerStorageValue(cid, 99285, "")
  134.         setPlayerStorageValue(cid, 99285, channelName)
  135.         doPlayerCreatePrivateChannel(cid, channelName)
  136.         doSendAnimatedText(getThingPos(cid), "ON AIR!", COLOR_GRASS)
  137.  
  138.     return false
  139.     end
  140.  
  141. return true
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement