Advertisement
Guest User

login.lua

a guest
Oct 15th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. -- ordered as in creaturescripts.xml
  2. local events = {
  3.     'TutorialCockroach',
  4.     'ElementalSpheresOverlords',
  5.     'BigfootBurdenVersperoth',
  6.     'BigfootBurdenWarzone',
  7.     'BigfootBurdenWeeper',
  8.     'BigfootBurdenWiggler',
  9.     'SvargrondArenaKill',
  10.     'NewFrontierShardOfCorruption',
  11.     'NewFrontierTirecz',
  12.     'ServiceOfYalaharDiseasedTrio',
  13.     'ServiceOfYalaharAzerus',
  14.     'ServiceOfYalaharQuaraLeaders',
  15.     'InquisitionBosses',
  16.     'InquisitionUngreez',
  17.     'KillingInTheNameOfKills',
  18.     'MastersVoiceServants',
  19.     'SecretServiceBlackKnight',
  20.     'ThievesGuildNomad',
  21.     'WotELizardMagistratus',
  22.     'WotELizardNoble',
  23.     'WotEKeeper',
  24.     'WotEBosses',
  25.     'WotEZalamon',
  26.     'PlayerDeath',
  27.     'AdvanceSave',
  28.     'AdvanceRookgaard',
  29.     'ModalMD',
  30.     'PythiusTheRotten',
  31.     'DropLoot'
  32. }
  33.  
  34.  
  35. local function onMovementRemoveProtection(cid, oldPosition, time)
  36.     local player = Player(cid)
  37.     if not player then
  38.         return true
  39.     end
  40.  
  41.     local playerPosition = player:getPosition()
  42.     if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
  43.         player:setStorageValue(Storage.combatProtectionStorage, 0)
  44.         return true
  45.     end
  46.  
  47.     addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
  48. end
  49.  
  50. function onLogin(player)
  51.     local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
  52.     if player:getLastLoginSaved() <= 0 then
  53.         loginStr = loginStr .. ' Please choose your outfit.'
  54.         player:sendTutorial(1)
  55.     else
  56.         if loginStr ~= '' then
  57.             player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
  58.         end
  59.  
  60.         loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
  61.     end
  62.     player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
  63.  
  64.     --Quests
  65.     player:addStorageValue(12241, 6)
  66.    
  67.     local playerId = player:getId()
  68.  
  69.     -- Stamina
  70.     nextUseStaminaTime[playerId] = 0
  71.        
  72.     -- Promotion
  73.     local vocation = player:getVocation()
  74.     local promotion = vocation:getPromotion()
  75.     if player:isPremium() then
  76.         local value = player:getStorageValue(Storage.Promotion)
  77.         if not promotion and value ~= 1 then
  78.             player:setStorageValue(Storage.Promotion, 1)
  79.         elseif value == 1 then
  80.             player:setVocation(promotion)
  81.         end
  82.     elseif not promotion then
  83.         player:setVocation(vocation:getDemotion())
  84.     end
  85.  
  86.     -- Events
  87.     for i = 1, #events do
  88.         player:registerEvent(events[i])
  89.     end
  90.  
  91.     if player:getStorageValue(Storage.combatProtectionStorage) <= os.time() then
  92.         player:setStorageValue(Storage.combatProtectionStorage, os.time() + 10)
  93.         onMovementRemoveProtection(playerId, player:getPosition(), 10)
  94.     end
  95.     return true
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement