Ir para conteúdo
  • 0

Mudar premio para items variaveis


surfnament

Pergunta

Olha eu aqui de novo :p

Alguem poderia me ajudar a implementar uma variavel no premio deste escript?

 

local centeroffight = {x = 15233, y = 15008, z = 7}
local waitingplace = {x = 15210, y = 15023, z = 7}
local depotcenter = {x = 15000, y = 15000, z = 7}
local MinimumPlayers = 2
local rewardpoints = 1





local function lmsclosed1()
broadcastMessage("Last Man Standing event will start in 1 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
end


local function lmsclosed()

count = 0
local spectators = getSpectators(waitingplace, 10, 10, false)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
count = count + 1

end
end
end



if (count >= MinimumPlayers) then

broadcastMessage("Last Man Standing event portal closed and event started!", MESSAGE_STATUS_WARNING)

for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
doTeleportThing(playerids,centeroffight)
doSendMagicEffect(center, CONST_ME_TELEPORT)
end

end

else

broadcastMessage("Not enough players to start Last man Standing event! Minimum: "..MinimumPlayers.." players. We have "..count.."!", MESSAGE_STATUS_WARNING)
setGlobalStorageValue(25002, 0)

for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
doTeleportThing(playerids,depotcenter)
doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
setPlayerStorageValue(pid, 25001, 0)

end
end

end


return true
end





local function lmscheck()


count = 0
local spectators = getSpectators(centeroffight, 10, 10, false)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
count = count + 1

end
end
end

if count == 1 then


for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
setPlayerStorageValue(playerids, 25001, 0)
end
end

local spectators = getSpectators(centeroffight, 10, 10, false)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then



doTeleportThing(spectator,depotcenter)
doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
broadcastMessage("LMS ended winner is: "..getPlayerName(spectator)..", reward is 1 premium points.", MESSAGE_STATUS_WARNING)

local accid = Player(spectator):getAccountId()
local points = rewardpoints
db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. accid)

end
end
end



for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
setPlayerStorageValue(pid, 25001, 0)
end
end

stopEvent(lmscheck)

else
addEvent(lmscheck, 10*1000)
end
end



local function lms()
broadcastMessage("Last Man Standing event will start in 2 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)

portalwhere = {x= 14996, y=14999, z=7} local portal = doCreateItem(11796,1,portalwhere)
doSetItemActionId(portal, 25001)
doSendMagicEffect(portalwhere, CONST_ME_TELEPORT)


iteminfo = {x= 14995, y=14999, z=7}
local item = doCreateItem(1431,1,iteminfo)
doSetItemActionId(item, 25002)
doSendMagicEffect(iteminfo, CONST_ME_TELEPORT)

addEvent(function() doRemoveItem(getTileItemById(portalwhere, 11796).uid) end, 120 * 1000)
addEvent(function() doSendMagicEffect(portalwhere, CONST_ME_TELEPORT) end, 120 * 1000)

addEvent(function() doRemoveItem(getTileItemById(iteminfo, 1431).uid) end, 120 * 1000)
addEvent(function() doSendMagicEffect(iteminfo, CONST_ME_TELEPORT) end, 120 * 1000)

addEvent(lmsclosed, 2*60*1000)
addEvent(lmsclosed1, 1*60*1000)
addEvent(lmscheck, 130*1000)

return true
end



function onThink(interval)

broadcastMessage("Last Man Standing event will start in 3 minutes.", MESSAGE_STATUS_WARNING)
addEvent(lms, 60*1000)

return true
end

 

 

Eu queria que ao inves de dar premium points , de um item randomico...

Esta pode ser uma boa base:

local config = {
interval = "3 hours",
rewards = {[13295] = 1, [13536] = 1, [13537] = 1, [13294] = 1, [13535] = 1, [13539] = 1, [18448] = 1, [13293] = 1, [12398] = 1, [13247] = 1, [13498] = 1, [13538] = 1, [13508] = 1, [13292] = 1, [13291] = 1, [13938] = 1, [23550] = 1, [13939] = 2, [20138] = 1, [13307] = 1},
-- [itemid] = count; [2160] = 50 - it gives 50 crystal coins
website = true
}


function onThink(interval)
if Game.getPlayerCount() == 0 then
return true
end

local players = Game.getPlayers()
local winner = players[math.random(1, #players)]

local items = {}
for itemid, count in pairs(config.rewards) do
items[#items + 1] = itemid
end

local itemid = items[math.random(1, #items)]
local amount = config.rewards[itemid]
winner:addItem(itemid, amount)

local it = ItemType(itemid)
local name = ""
if amount == 1 then
name = it:getArticle() .. " " .. it:getName()
else
name = amount .. " " .. it:getPluralName()
end

broadcastMessage("[LOTERIA] " .. winner:getName() .. " ganhou " .. name .. "! Parabéns! (Próxima loteria em " .. config.interval .. ")")

if config.website then
db.query("INSERT INTO `lottery` (`name`, `item`) VALUES (\"".. db.escapeString(winner:getName()) .."\", \"".. db.escapeString(it:getName()) .."\");")
end
return true
end


Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0

Tenta ae:

 

 

local centeroffight = {x = 15233, y = 15008, z = 7}
local waitingplace = {x = 15210, y = 15023, z = 7}
local depotcenter = {x = 15000, y = 15000, z = 7}
local MinimumPlayers = 2
local gifts = {
[1] = {id = 2148, count = 100},
[2] = {id = 2160, count = 100}
}





local function lmsclosed1()
    broadcastMessage("Last Man Standing event will start in 1 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
end


local function lmsclosed()

count = 0
        local spectators = getSpectators(waitingplace, 10, 10, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then    
                         count = count + 1
                       
                        end
                end
        end
        
        
        
if (count >= MinimumPlayers) then

broadcastMessage("Last Man Standing event portal closed and event started!", MESSAGE_STATUS_WARNING)

for _, pid in ipairs(getOnlinePlayers()) do
    if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
doTeleportThing(playerids,centeroffight)
doSendMagicEffect(center, CONST_ME_TELEPORT)
    end
       
end

else

broadcastMessage("Not enough players to start Last man Standing event! Minimum: "..MinimumPlayers.." players. We have "..count.."!", MESSAGE_STATUS_WARNING)
setGlobalStorageValue(25002, 0)

for _, pid in ipairs(getOnlinePlayers()) do
    if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
doTeleportThing(playerids,depotcenter)
doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
setPlayerStorageValue(pid, 25001, 0)

    end
end

end


return true
end





local function lmscheck()


count = 0
        local spectators = getSpectators(centeroffight, 10, 10, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then    
                         count = count + 1
                       
                        end
                end
        end

if count == 1 then


for _, pid in ipairs(getOnlinePlayers()) do
    if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
setPlayerStorageValue(playerids, 25001, 0)
    end
end

        local spectators = getSpectators(centeroffight, 10, 10, false)
        if spectators ~= nil then
                for _, spectator in ipairs(spectators) do
                        if isPlayer(spectator) then  
a = math.random(1, #gifts)
doTeleportThing(spectator,depotcenter)
doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
doPlayerAddItem(spectator, gifts[a].id, gifts[a].count)
broadcastMessage('LMS ended winner is: '..getPlayerName(spectator)..', reward is '..gifts[a].count..' '..getItemName(gifts[a].id)..'.', MESSAGE_STATUS_WARNING)               
   end
                end
        end
        


for _, pid in ipairs(getOnlinePlayers()) do
    if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
setPlayerStorageValue(pid, 25001, 0)
end
end

stopEvent(lmscheck)

else
addEvent(lmscheck, 10*1000)
end
end



local function lms()
    broadcastMessage("Last Man Standing event will start in 2 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)

    portalwhere = {x= 14996, y=14999, z=7}    local portal = doCreateItem(11796,1,portalwhere)
  doSetItemActionId(portal, 25001)
  doSendMagicEffect(portalwhere, CONST_ME_TELEPORT)


    iteminfo = {x= 14995, y=14999, z=7}
    local item = doCreateItem(1431,1,iteminfo)
  doSetItemActionId(item, 25002)
  doSendMagicEffect(iteminfo, CONST_ME_TELEPORT)
 
addEvent(function() doRemoveItem(getTileItemById(portalwhere, 11796).uid) end, 120 * 1000)
addEvent(function() doSendMagicEffect(portalwhere, CONST_ME_TELEPORT) end, 120 * 1000)

addEvent(function() doRemoveItem(getTileItemById(iteminfo, 1431).uid) end, 120 * 1000)
addEvent(function() doSendMagicEffect(iteminfo, CONST_ME_TELEPORT) end, 120 * 1000)

addEvent(lmsclosed, 2*60*1000)
addEvent(lmsclosed1, 1*60*1000)
addEvent(lmscheck, 130*1000)

return true
end



function onThink(interval)

    broadcastMessage("Last Man Standing event will start in 3 minutes.", MESSAGE_STATUS_WARNING)
    addEvent(lms, 60*1000)

return true
end

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

Me salvou denovo *----* mt obrigadoo!

 

Sera que voce poderia me ajudar a adicionar level minimo no script movements join?

 

local t = {
waitingroom = {x = 15210, y = 15023, z = 7},
}

function onStepIn(cid, item, position, lastPosition)

doTeleportThing(cid, t.waitingroom)
doSendMagicEffect(t.waitingroom, CONST_ME_TELEPORT)



if (getGlobalStorageValue(25002) < 0) then
setGlobalStorageValue(25002,1)
setPlayerStorageValue(cid, 25001, 1)
broadcastMessage("O player "..getCreatureName(cid).." entrou no Last Standing Event!", MESSAGE_STATUS_WARNING)

else

setGlobalStorageValue(25002,getGlobalStorageValue(25002)+1)
setPlayerStorageValue(cid, 25001, 1)

broadcastMessage("O player "..getCreatureName(cid).." entrou no Last Standing Event!", MESSAGE_STATUS_WARNING)
end
end

 



Queria que só player level 400+ possa entrar , se tentar pisar no tile(teleport) seja kikado da posição (vai e volta)

Sei que é algo como isto , mas esse TFS 1.0 eu nao entendo muito bem , eu mexia em 0.4

 

 

if getPlayerLevel >= 400 then

else

player:teleportTo(fromPosition)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Requere no minimo level 400 para participar")
end

 

 

 

Editado por Prototype
Link para o comentário
Compartilhar em outros sites

  • 0

Blz, eu peguei o script que vc mandou e botou funções de tfs 0.4... Pq ele está todo escrito em 0.4...
Vê se funfa:

local t = {
waitingroom = {x = 15210, y = 15023, z = 7},
}
local levelMin = 400


function onStepIn(cid, item, position, fromPosition)
if getPlayerLevel >= levelMin then
doTeleportThing(cid, t.waitingroom)
doSendMagicEffect(t.waitingroom, CONST_ME_TELEPORT)

	if (getGlobalStorageValue(25002) < 0) then
	setGlobalStorageValue(25002,1)
	setPlayerStorageValue(cid, 25001, 1)
	broadcastMessage("O player "..getCreatureName(cid).." entrou no Last Standing Event!", MESSAGE_STATUS_WARNING)

	else

	setGlobalStorageValue(25002,getGlobalStorageValue(25002)+1)
	setPlayerStorageValue(cid, 25001, 1)

	broadcastMessage("O player "..getCreatureName(cid).." entrou no Last Standing Event!", MESSAGE_STATUS_WARNING)
	end
else
doTeleportThing(cid, fromPosition)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, 'É necessário ter level '..levelMin..' para entrar aqui.')
end
return true
end
Link para o comentário
Compartilhar em outros sites

  • 0

Oh god... Passou batido.... sahushauas

local t = {
waitingroom = {x = 15210, y = 15023, z = 7},
}
local levelMin = 400


function onStepIn(cid, item, position, fromPosition)
if getPlayerLevel(cid) >= levelMin then
doTeleportThing(cid, t.waitingroom)
doSendMagicEffect(t.waitingroom, CONST_ME_TELEPORT)

	if (getGlobalStorageValue(25002) < 0) then
	setGlobalStorageValue(25002,1)
	setPlayerStorageValue(cid, 25001, 1)
	broadcastMessage("O player "..getCreatureName(cid).." entrou no Last Standing Event!", MESSAGE_STATUS_WARNING)

	else

	setGlobalStorageValue(25002,getGlobalStorageValue(25002)+1)
	setPlayerStorageValue(cid, 25001, 1)

	broadcastMessage("O player "..getCreatureName(cid).." entrou no Last Standing Event!", MESSAGE_STATUS_WARNING)
	end
else
doTeleportThing(cid, fromPosition)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, 'É necessário ter level '..levelMin..' para entrar aqui.')
end
return true
end
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...