Postado Junho 5, 2018 7 anos 2 minutos atrás, Daniel disse: Esse código vai dar 1 cc após 1 hora online e 2 cc após duas horas online. É só configurar ali no início: creaturescripts/scripts/onreward -- made by static -- local items = { [1] = { itemid = 2160, count = 1, }, [2] = { itemid = 2160, count = 2 } } local events = {} local function addReward(cid, rewardId) if not isPlayer(cid) then return end local item = items[rewardId or #items] doPlayerAddItem(cid, item.itemid, item.count) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1) end function onLogin(cid) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, 1) return true end function onLogout(cid) if events[cid] then stopEvent(events[cid]) events[cid] = nil end return true end creaturescripts/scripts/login.lua registerCreatureEvent(cid, "itemLogin") registerCreatureEvent(cid, "itemLogout") creaturescripts/creaturescripts.xml <event type="login" name="itemLogin" event="script" value="onreward.lua"/> <event type="logout" name="itemLogout" event="script" value="onreward.lua"/> obrigado mano vou testar 13 minutos atrás, Daniel disse: Esse código vai dar 1 cc após 1 hora online e 2 cc após duas horas online. É só configurar ali no início: creaturescripts/scripts/onreward -- made by static -- local items = { [1] = { itemid = 2160, count = 1, }, [2] = { itemid = 2160, count = 2 } } local events = {} local function addReward(cid, rewardId) if not isPlayer(cid) then return end local item = items[rewardId or #items] doPlayerAddItem(cid, item.itemid, item.count) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1) end function onLogin(cid) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, 1) return true end function onLogout(cid) if events[cid] then stopEvent(events[cid]) events[cid] = nil end return true end creaturescripts/scripts/login.lua registerCreatureEvent(cid, "itemLogin") registerCreatureEvent(cid, "itemLogout") creaturescripts/creaturescripts.xml <event type="login" name="itemLogin" event="script" value="onreward.lua"/> <event type="logout" name="itemLogout" event="script" value="onreward.lua"/> tem como colocar uma menssagem para oo player que recebeu o item falando paraben vc ficou 1 hora online e ganhou x item e depois parabens vc ficou 2 horas online e ganhao x item
Postado Junho 5, 2018 7 anos 16 horas atrás, mullino disse: obrigado mano vou testar tem como colocar uma menssagem para oo player que recebeu o item falando paraben vc ficou 1 hora online e ganhou x item e depois parabens vc ficou 2 horas online e ganhao x item o meu deu esse erro [Error - CreatureScript Interface] In a timer event called from: data/creaturescripts/scripts/onreward.lua:onLogin Description: data/creaturescripts/scripts/onreward.lua:21: attempt to index local 'item' (a nil value) stack traceback: data/creaturescripts/scripts/onreward.lua:21: in function <data/creaturescripts/scripts/onreward.lua:16> -- made by static -- local items = { [1] = { itemid = 11192, count = 10, }, [2] = { itemid = 11192, count = 20 } } local events = {} local function addReward(cid, rewardId) if not isPlayer(cid) then return end local item = items[rewardId or #items] doPlayerAddItem(cid, item.itemid, item.count) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1) end function onLogin(cid) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, 1) return true end function onLogout(cid) if events[cid] then stopEvent(events[cid]) events[cid] = nil end return true end
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.