Jesper_Kladden
Donator
You should vote for
*Most functional
*The Best
*The one you liked the most
*The one that looks most clean
-VOTING ENDS @ THE 22nd FEBRUARY-
Master-Z's Script
Script explanation:
NOOBLAND's Script
Script Explanation:
*Most functional
*The Best
*The one you liked the most
*The one that looks most clean
-VOTING ENDS @ THE 22nd FEBRUARY-
Master-Z's Script
PHP:
-- Script made by Zoriath --
-- Variables --
-- What level does the player need to have to go on the annihilator? --
local playerLevelNeed = 100
-- Enter the positions of the demon which is most on the right (in front of the door). --
local firstMonster = {"Demon", {x = 33224, y = 31659, z = 13}}
-- Preferably, do not edit this (only if you don't have a standard annihilator). --
local monsterSummons = {
{"Demon", {x = firstMonster.x - 1, y = firstMonster.y, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 2, y = firstMonster.y - 1, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 3, y = firstMonster.y - 1, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 2, y = firstMonster.y + 1, z = firstMonster.z}},
{"Demon", {x = firstMonster.x - 3, y = firstMonster.y + 1, z = firstMonster.z}}
}
-- Enter the position of the first player (the one most on the right). --
local firstPlayer = {x = 33225, y = 31671, z = 13, stackpos = STACKPOS_TOP_CREATURE}
-- Preferably, do not edit this (only if you don't have a standard annihilator). --
local playersPositions = {
{x = firstPlayer.x - 1, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 2, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 3, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos}
}
-- Enter the position of the first player (the one most on the right) for the position after they've been teleported into the annihilator. --
local firstNewPlayer = {x = 33222, y = 31659, z = 13, stackpos = STACKPOS_TOP_CREATURE}
-- Preferably, do not edit this (only if you don't have a standard annihilator). --
local playersPositionsNew = {
{x = firstPlayer.x - 1, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 2, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos},
{x = firstPlayer.x - 3, y = firstPlayer.y, z = firstPlayer.z, stackpos = firstPlayer.stackpos}
}
-- Enter the position of the beginning of the annihilator (the top left sqm). --
startAnnihilator = {x = 33219, y = 31657, z = 13, stackpos = STACKPOS_TOP_CREATURE}
-- Enter the position of the ending of the annihilator (the lowest right sqm). --
endAnnihilator = {x = 33237, y = 31662, z = 13, stackpos = STACKPOS_TOP_CREATURE}
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- Checks if the ItemID of the lever is correct. --
if(item.itemid == 1945) then
-- Checks if the player has enough level. --
for _, v in ipairs(firstPlayer + playerPositions) do
if(getPlayerLevel(cid) >= playerLevelNeed) then
-- Checks if the player hasn't done annihilator already. --
for _, v in ipairs(firstPlayer + playerPositions) do
if(getPlayerStorageValue ~= TRUE) then
-- Checks if all the players are there. --
for _, d in ipairs(firstPlayer + playerPositions) do
if(getThingFromPos(unpack(d)).itemid > 0) then
-- Checks how many monsters there are in the annihilator. --
for _, v in ipairs(firstMonster + monsterSummons) do
-- Makes everything happen (the summoning/teleporting). --
doSummonCreature(unpack(v))
doTeleportThing(unpack(d), firstNewPlayer + playersPositionsNew)
end
else
doPlayerSendCancel(unpack(d), 22, "You need " .. #firstPlayer + #playerPositions .. " players to go on annihilator!")
end
end
else
doPlayerSendCancel(unpack(v), 22, "Someone has already done the annihilator.")
end
end
else
doPlayerSendCancel(unpack(v), 22, "Someone in your team hasn't got the required level to do the annihilator.")
end
end
-- Checks if the annihilator hasn't been done before. --
elseif(item.itemid == 1946) then
if(cleanArea()) then
doTransformItem(item.uid, 1945)
else
return FALSE
end
-- Checks if the amounts are correct (from the players). --
elseif(#firstPlayer + #playersPositions ~= #firstNewPlayer + #playersPositionsNew) then
for _, v in ipairs(firstPlayer + playersPositions) do
doPlayerSendCancel(unpack(v), 22, "The annihilator is not (yet) useable in this server.")
end
elseif(#firstPlayer > 2 or #firstNewPlayer > 2) then
for _, v in ipairs(firstPlayer + playersPositions) do
doPlayerSendCancel(unpack(v), 22, "The annihilator is not (yet) useable in this server.")
end
end
return TRUE
end
-- This is not made by myself but by Tworn (was too lazy to make it myself :P). --
function cleanArea()
local checkAnnihilator = {x = startAnnihilator.x, y = startAnnihilator.y, z = startAnnihilator.z, stackpos = STACKPOS_TOP_CREATURE}
local monster = {}
while(checkAnnihilator.y <= endAnnihilator.y) do
local creature = getTopCreature(checkAnnihilator)
if(isCreature(creature) == TRUE) then
if(isPlayer(creature) == TRUE) then
return FALSE
else
table.insert(monster, creature)
end
end
if(checkAnnihilator.x == endAnnihilator.x) then
checkAnnihilator.x = startAnnihilator.x
checkAnnihilator.y = checkAnnihilator.y + 1
end
checkAnnihilator.x = checkAnnihilator.x + 1
end
end
Script explanation:
Code:
Well, you enter the position of the player position in the beginning most to the right (at firstMonster). Example:
P = Player.
O = Player you should edit the variable to.
L = Lever.
W = Walkable object.
WWWWWWW
WPPPOLW
WWWWWWW
Then, you enter the position of the player where he/she should be teleported to most to the right (in the room) at firstPlayer. Example:
P = Player.
O = Player you should edit the variable to.
D = Demon.
X = Non-walkable object.
XDXD
XXXX
PPPODD
XXXX
DXDX
After that you enter the position of the first monster (the one most on the right in the room) at firstPlayerNew. Example:
P = Player.
D = Demon.
M = Demon you should edit the variable to.
X = Non-walkable object.
DXDX
XXXX
PPPPDM
XXXX
XDXD
Then you enter the position of the starting sqm of the annihilator room (the top left one) at startAnnihilator and the position of the ending sqm of the annihilator room (the lower right one) at endAnnihilator. Example:
The red one is the startAnnihilator and the blue one is the endAnnihilator.
[COLOR="Red"]O[/COLOR]-----
| |
| |
| |
-----[COLOR="Blue"]O[/COLOR]
NOOBLAND's Script
PHP:
function doPlayerAddLevel(cid, amount)
local addExp = getPlayerExperience(cid) - getExperienceForLevel(getPlayerLevel(cid) + amount)
doPlayerAddExp(cid, addExp)
return addExp
end
sleep = coroutine.yield
function doSleep(co)
if coroutine.status(co) ~= 'dead' then
local _, delay = coroutine.resume(co)
addEvent(doSleep, delay or 100, co)
end
end
function enableSleep(f)
if type(f) == 'function' then
local co = coroutine.create(f)
doSleep(co)
end
end
local interval = 3 * 60 -- 3 minutes interval between each level :-)
local gainLevels = 20 -- How many levels will you gain? They will increase each "interval" seconds and when reaching "gainLevels" level they will go back again.
function onUse(cid)
-- Store the player name to be able to execute database query (you cannot check the name after he has logged out!)
local playerName = getCreatureName(cid)
-- Store gained experience to later be able to remove them.
local gainExp = 0
-- This function is necessary to be able to use the sleep function.
enableSleep(function()
for i = 1, gainLevels do
gainExp = gainExp + doPlayerAddLevel(cid, 1)
-- Pause the code for "interval" seconds.
sleep(interval * 1000)
-- If the player has logged out the experience must be removed from him!
if isPlayer(cid) == FALSE then
-- Player could possibly have relogged and a new "cid" would have been made for him, which means the SQL query would be overwritten by the server anyhow.
cid = getPlayerByName(playerName)
if isPlayer(cid) == FALSE then
db.executeQuery("UPDATE players SET experience -= " .. gainExp .. " WHERE name = " .. db.escapeString(playerName))
return
end
-- This will occur only if the player relogged/died, which would pass it to the doPlayerAddExp function to remove the experience in-game.
break
end
end
-- Remove the experience from the player after "gainLevels" levels with "interval" interval.
doPlayerAddExp(cid, -gainedExp)
end)
end
Script Explanation:
Code:
Well it simply gives a player level each x seconds/minutes or w/e u want.... And if you logout it will remove the added experience with some stuff to makes the script unable to fail ;> The comments should explain that too
Last edited: