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

vip system 1.2

ss1182772

New Member
Joined
Jan 22, 2015
Messages
51
Reaction score
2
function onLogin(player) isso
player:loadVipData()
player:updateVipTime()
how add this code
 
PunBB

    1. ALTER TABLE `accounts`
    2. ADD COLUMN `viplastday` int(10) NOT NULL DEFAULT 0 AFTER `lastday`,
    3. ADD COLUMN `vipdays` int(11) NOT NULL DEFAULT 0 AFTER `lastday`;


ahora en data/creaturescripts/scripts/login.lua
PunBB

    1. player:loadVipData()
    2. player:updateVipTime()

ahora en la carpeta Data haces un archivo llamado vipsystem.lua
PunBB

    1. local config = {
    2. -- true = player will be teleported to this position if Vip runs out
    3. -- false = player will not be teleported
    4. useTeleport = true,
    5. expirationPosition = Position(95, 114, 7),

    6. -- true = player will received the message you set
    7. -- false = player will not receive a message
    8. useMessage = true,
    9. expirationMessage = 'Your vip days ran out.',
    10. expirationMessageType = MESSAGE_STATUS_WARNING
    11. }

    12. if not VipData then
    13. VipData = { }
    14. end

    15. function Player.onRemoveVip(self)
    16. if config.useTeleport then
    17. self:teleportTo(config.expirationPosition)
    18. config.expirationPosition:sendMagicEffect(CONST_ME_TELEPORT)
    19. end

    20. if config.useMessage then
    21. self:sendTextMessage(config.expirationMessageType, config.expirationMessage)
    22. end
    23. end

    24. function Player.getVipDays(self)
    25. return VipData[self:getId()].days
    26. end

    27. function Player.getLastVipDay(self)
    28. return VipData[self:getId()].lastDay
    29. end

    30. function Player.isVip(self)
    31. return self:getVipDays() > 0
    32. end

    33. function Player.addInfiniteVip(self)
    34. local data = VipData[self:getId()]
    35. data.days = 0xFFFF
    36. data.lastDay = 0

    37. db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', 0xFFFF, 0, self:getAccountId()))
    38. end

    39. function Player.addVipDays(self, amount)
    40. local data = VipData[self:getId()]
    41. local amount = math.min(0xFFFE - data.days, amount)
    42. if amount > 0 then
    43. if data.days == 0 then
    44. local time = os.time()
    45. db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i, `viplastday` = %i WHERE `id` = %i;', amount, time, self:getAccountId()))
    46. data.lastDay = time
    47. else
    48. db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i WHERE `id` = %i;', amount, self:getAccountId()))
    49. end
    50. data.days = data.days + amount
    51. end

    52. return true
    53. end

    54. function Player.removeVipDays(self, amount)
    55. local data = VipData[self:getId()]
    56. if data.days == 0xFFFF then
    57. return false
    58. end

    59. local amount = math.min(data.days, amount)
    60. if amount > 0 then
    61. db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` - %i WHERE `id` = %i;', amount, self:getAccountId()))
    62. data.days = data.days - amount

    63. if data.days == 0 then
    64. self:eek:nRemoveVip()
    65. end
    66. end

    67. return true
    68. end

    69. function Player.removeVip(self)
    70. local data = VipData[self:getId()]
    71. if data.days == 0 then
    72. return
    73. end

    74. data.days = 0
    75. data.lastDay = 0

    76. self:eek:nRemoveVip()

    77. db.query(string.format('UPDATE `accounts` SET `vipdays` = 0, `viplastday` = 0 WHERE `id` = %i;', self:getAccountId()))
    78. end

    79. function Player.loadVipData(self)
    80. local resultId = db.storeQuery(string.format('SELECT `vipdays`, `viplastday` FROM `accounts` WHERE `id` = %i;', self:getAccountId()))
    81. if resultId then
    82. VipData[self:getId()] = {
    83. days = result.getDataInt(resultId, 'vipdays'),
    84. lastDay = result.getDataInt(resultId, 'viplastday')
    85. }

    86. result.free(resultId)
    87. return true
    88. end

    89. VipData[self:getId()] = { days = 0, lastDay = 0 }
    90. return false
    91. end

    92. function Player.updateVipTime(self)
    93. local save = false

    94. local data = VipData[self:getId()]
    95. local days, lastDay = data.days, data.lastDay
    96. local daysBefore = days
    97. if days == 0 or days == 0xFFFF then
    98. if lastDay ~= 0 then
    99. lastDay = 0
    100. save = true
    101. end
    102. elseif lastDay == 0 then
    103. lastDay = os.time()
    104. save = true
    105. else
    106. local time = os.time()
    107. local elapsedDays = math.floor((time - lastDay) / 86400)
    108. if elapsedDays > 0 then
    109. if elapsedDays >= days then
    110. days = 0
    111. lastDay = 0
    112. else
    113. days = days - elapsedDays
    114. lastDay = time - ((time - lastDay) % 86400)
    115. end
    116. save = true
    117. end
    118. end

    119. if save then
    120. if daysBefore > 0 and days == 0 then
    121. self:eek:nRemoveVip()
    122. end

    123. db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', days, lastDay, self:getAccountId()))
    124. data.days = days
    125. data.lastDay = lastDay
    126. end
    127. end

Ahora en Global.lua agregas la siguiente linea:
PunBB

    1. dofile('data/vipsystem.lua')


Ahora en data/talkactions/scripts haces un archivo llamado checkvip.lua
PunBB

    1. function onSay(cid, words, param)
    2. local player = Player(cid)

    3. local days = player:getVipDays()
    4. if days == 0 then
    5. player:sendCancelMessage('You do not have any vip days.')
    6. else
    7. player:sendCancelMessage(string.format('You have %s vip day%s left.', (days == 0xFFFF and 'infinite amount of' or days), (days == 1 and '' or 's')))
    8. end
    9. return false
    10. end


data/talkactions/talkactions.xml
PunBB

    1. <talkaction words="!checkvip" script="checkvip.lua"/>


data/talkactions/scripts/vipcommand.lua
PunBB

    1. function onSay(cid, words, param)
    2. local player = Player(cid)
    3. if not player:getGroup():getAccess() then
    4. return true
    5. end

    6. local params = param:split(',')
    7. if not params[2] then
    8. player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('Player is required.\nUsage:\n%s <action>, <name>, [, <value>]\n\nAvailable actions:\ncheck, adddays, addinfinite, removedays, remove', words))
    9. return false
    10. end

    11. local targetName = params[2]:trim()
    12. local target = Player(targetName)
    13. if not target then
    14. player:sendCancelMessage(string.format('Player (%s) is not online. Usage: %s <action>, <player> [, <value>]', targetName, words))
    15. return false
    16. end

    17. local action = params[1]:trim():lower()
    18. if action == 'adddays' then
    19. local amount = tonumber(params[3])
    20. if not amount then
    21. player:sendCancelMessage('<value> has to be a numeric value.')
    22. return false
    23. end

    24. target:addVipDays(amount)
    25. player:sendCancelMessage(string.format('%s received %s vip day(s) and now has %s vip day(s).', target:getName(), amount, target:getVipDays()))

    26. elseif action == 'removedays' then
    27. local amount = tonumber(params[3])
    28. if not amount then
    29. player:sendCancelMessage('<value> has to be a numeric value.')
    30. return false
    31. end

    32. target:removeVipDays(amount)
    33. player:sendCancelMessage(string.format('%s lost %s vip day(s) and now has %s vip day(s).', target:getName(), amount, target:getVipDays()))

    34. elseif action == 'addinfinite' then
    35. target:addInfiniteVip()
    36. player:sendCancelMessage(string.format('%s now has infinite vip time.', target:getName()))

    37. elseif action == 'remove' then
    38. target:removeVip()
    39. player:sendCancelMessage(string.format('You removed all vip days from %s.', target:getName()))

    40. elseif action == 'check' then
    41. local days = target:getVipDays()
    42. player:sendCancelMessage(string.format('%s has %s vip day(s).', target:getName(), (days == 0xFFFF and 'infinite' or days)))

    43. else
    44. player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('Action is required.\nUsage:\n%s <action>, <name>, [, <value>]\n\nAvailable actions:\ncheck, adddays, addinfinite, removedays, remove', words))
    45. end
    46. return false
    47. end

data/talkactions/talkactions.xml
PunBB

    1. <talkaction words="/vip" separator=" " script="vipcommand.lua" />

Tiles VIP

data/movements/movements.xml

PunBB

    1. <movevent event="StepIn" actionid="1500" script="viptiles.lua"/>
    2. <movevent event="StepIn" actionid="1501" script="viptiles.lua"/>

data/movements/script/viptiles.lua
PunBB

    1. local vipPosition = Position(101, 116, 7)

    2. function onStepIn(cid, item, position, fromPosition)
    3. local player = Player(cid)
    4. if not player then
    5. return true
    6. end

    7. if item.actionid == 1500 then
    8. if not player:isVip() then
    9. player:teleportTo(fromPosition)
    10. fromPosition:sendMagicEffect(CONST_ME_POFF)
    11. player:sendCancelMessage('You do not have any vip days.')
    12. end
    13. elseif item.actionid == 1501 then
    14. if player:isVip() then
    15. player:teleportTo(vipPosition)
    16. player:say('!* VIP *!', TALKTYPE_MONSTER_SAY)
    17. vipPosition:sendMagicEffect(CONST_ME_STUN)
    18. else
    19. player:teleportTo(fromPosition)
    20. player:sendCancelMessage('You do not have any vip days.')
    21. fromPosition:sendMagicEffect(CONST_ME_POFF)
    22. end
    23. end
    24. return true
    25. end

Puertas Vip
data/actions/actions.xml
PunBB

    1. <action actionid="1502" script="vipdoors.lua"/>
    2. <action actionid="1503" script="vipdoors.lua"/>
    3. <action actionid="1504" script="vipdoors.lua"/>

data/actions/scripts/vipdoors.lua
PunBB

    1. local vipPosition = Position(101, 116, 7)

    2. function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    3. local player = Player(cid)
    4. if item.actionid == 1502 then
    5. local position = player:getPosition()
    6. if position.y < fromPosition.y then
    7. fromPosition.y = fromPosition.y + 1
    8. else
    9. fromPosition.y = fromPosition.y - 1
    10. end
    11. player:teleportTo(fromPosition)
    12. player:say('!* VIP *!', TALKTYPE_MONSTER_SAY)
    13. fromPosition:sendMagicEffect(CONST_ME_STUN)

    14. elseif item.actionid == 1503 then
    15. local position = player:getPosition()
    16. if position.x < fromPosition.x then
    17. fromPosition.x = fromPosition.x + 1
    18. else
    19. fromPosition.x = fromPosition.x - 1
    20. end
    21. player:teleportTo(fromPosition)
    22. player:say('!* VIP *!', TALKTYPE_MONSTER_SAY)
    23. fromPosition:sendMagicEffect(CONST_ME_STUN)

    24. elseif item.actionid == 1504 then
    25. if player:isVip() then
    26. player:teleportTo(vipPosition)
    27. player:say('!* VIP *!', TALKTYPE_MONSTER_SAY)
    28. vipPosition:sendMagicEffect(CONST_ME_STUN)
    29. else
    30. player:sendCancelMessage('You do not have any vip days.')
    31. end
    32. end
    33. return true
    34. end

Items que dan vip
PunBB

    1. ItemId 10135 10 dias vip.
    2. ItemId 10134 30 dias vip.
    3. ItemId 10133 90 dias vip.

data/actions/actions.xml
PunBB

    1. <action fromid="10133" toid="10135" script="vipitems.lua"/>

data/actions/scripts/vipitems.lua

PunBB

    1. local vipItems = {
    2. -- [itemid] = amount of vip days
    3. [10135] = 10,
    4. [10134] = 30,
    5. [10133] = 90
    6. }

    7. function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    8. local player = Player(cid)
    9. local days = vipItems[item.itemid]
    10. player:addVipDays(days)
    11. player:say('!* VIP! *!', TALKTYPE_MONSTER_SAY)
    12. player:getPosition():sendMagicEffect(CONST_ME_STUN)
    13. player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You received %s vip days.', days))
    14. Item(item.uid):remove(1)
    15. return true
    16. end
 
function onLogin(player) isso
player:loadVipData()
player:updateVipTime()
how i add this in login lua


im very bad learn tell me what i need doing

function onLogin(player) isso
player:loadVipData()
player:updateVipTime()
how i add this in login lua

how i add this in login lua

no but how
 
Last edited by a moderator:
Back
Top