Lua givePoints

Discussion in 'Support' started by leandroluck, Feb 13, 2018.

  1. leandroluck

    leandroluck Member

    Joined:
    Dec 24, 2010
    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    global events
    Code (Text):
    1.  
    2. l
    3. local config = {
    4. p_time = 1, -- Tempo em segundos para receber os pontos( 3600 = 1hora )
    5. p_points = 1 -- Quantidade de pontos recebida a cada "p_time"
    6. }
    7.  
    8. local function givePoints(cid, quant)
    9. if os.time() - player:getStorageValue(974859) >= config.p_time then
    10. doPlayerSendTextMessage(cid, 19, "Congratulations, you recieved ".. config.p_points .." p points. Now you have ".. config.p_points .." p points in your account. Your timer was reseted.")
    11. --db.query("UPDATE `accounts` SET `coins` = `coins` + '" .. p_points .. "' WHERE `id` = '" .. player:getAccountId() .. "';")
    12. player:setStorageValue(974859, 0)
    13. player:setStorageValue(974859, os.time())
    14. end
    15. return true
    16. end
    17.  
    18. function onThink(interval)
    19. for i, v in pairs(Game.getPlayers()) do
    20. givePoints(v, config.p_points)
    21. end
    22. return true
    23. end
    24.  
    25.  
    26.  
    27.  
    28.  
    29.  
    30.  
    31.  
    creaturescripts
    Code (Text):
    1.  
    2. function onLogin(cid)
    3. doCreatureSetStorage(cid, 974859, os.time())
    4. return true
    5. end
    6.  
    7. function onLogout(cid)
    8. doCreatureSetStorage(cid, 974859, 0)
    9. return true
    10. end
    11.  
    Lua Script Error: [GlobalEvent Interface]
    data/globalevents/scripts/points.lua:eek:nThink
    data/globalevents/scripts/points.lua:7: attempt to index global 'player' (a nil value)
    stack traceback:
    [C]: in function '__index'
    data/globalevents/scripts/points.lua:7: in function 'givePoints'
    data/globalevents/scripts/points.lua:18: in function <data/globalevents/scripts/points.lua:16>
    [Error - GlobalEvents::think] Failed to execute event: pointss
     
    Last edited: Feb 13, 2018
  2. Static_

    Static_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,437
    Likes Received:
    1,494
    Best Answers:
    228
    local function givePoints(cid, quant)
    to
    local function givePoints(player, quant)
     

Share This Page

Loading...