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

[Competition] Scripting

Jesper_Kladden

Donator
Joined
May 16, 2008
Messages
458
Reaction score
1
Location
Sweden

...::: Scripting Competition :::...
Brought to you by Jesper_kladden


How to get in?
~Write here on this thread:

*How long have you been scripting LUA?
*Rate yourself with a 1 to 100 ratio.
*Have you made any Kick-Ass scripts(?), Then link 'em here.

F.A.Q

*You will win Fame and Reputation and maybe a little extra thingy from me :)
*The script should be an Action, or a TalkAction.
*The script should be sent to me VIA PM And you should write what it does. Then I'll post it here and people will Vote for the best.
*The script should be shown by hosting it on your OT or someone else's ot. Just as long as you can show it to me.


Competitors (5/5):

Zoriath
Macroman
Lef
Colandus
NOOBLAND

Red -> Disqualified
Green -> Script sent



The competition ends @ 20th of February 2009


-Zoriath's 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]
 
Last edited:
Spaceholder for scripts~~

Zoriath'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

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

------------------

PHP:
Space~~~~

------------------

PHP:
Space~~~~

------------------

PHP:
Space~~~~

------------------
 
Last edited:
Here I go...

I'm a noob scripter, just bored and want to see how good I do compared with 'tha pro' scripters xD..

Well, I don't really know how long I've been scripting (I think a week or two).
The points:
Well, depends on who I get compared with. If it's with Colandus 1/100 and if it's with a beginner I think it's like 65/100 or something.. It's hard to rate yourself..

Didn't make any kickass scripts ;)
 
Bumping it for you, btw my script is done 100% tested and working!


Will send it now ^^
 
I guess I could sign up if you'd like to. ; )
 
Actions and talkactions aren't advanced scripts.

Well yours maybe not. But some of mine are, its always better then a stolen gui with a pot system;). Also you can combine it with sql to get advanced scripts. I've got some simple games for my psp written in lua, you could do much more with it then you think..
 
Lol, I dont think so xD, never seen sharp scripting.. I doubt if he can xDdDdD l0l
 
Actions and talkactions are movements :O? xDD, I think they should be allowed, would be unfair to me, wanted to do that too, but couldn't... xD, but I dont care... i wont win anyway l0l
 
Heh, well I know for sure they ain't - but I don't see why they shouldn't be allowed.
 
If I wasn't out of ideas I would join:p. But at this moment I don't know anything special or I don't want to release it:p
 
Back
Top