• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Reward onAdvance by vocation.

Optus

GeorgeB.
Joined
Aug 30, 2011
Messages
390
Reaction score
12
Location
Australia
Hello guys i am new to scripting and am still learning. I wrote this script with onAdvance level 50 the player receives a reward based on his vocation. For people that are looking for that instead of giving 1 reward. Also can be increase the level etc in config. It should work although i haven't tested it <_<

Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local setup = {
			level = 50, -- level to receive items.
			message = "Congratulations on advancing to level 50 here is your reward.", -- The message they will receive.
			effectID = 61 -- ID of the effect that will appear on the character.
			storage = 1337 -- storage value to store information.
		}
			
	if skill == SKILL__LEVEL and newLevel < setup.level then
	doPlayerSendTextMessage("Congratulations on leveling your brand new character! You are now level ".. getPlayerLevel(cid) .."!"
		return true
			end
	if getPlayerStorageValue(cid, storage) ~= 1 then
	return true
	end
	
	local p = getPlayerPosition(cid)
	local positions = {
                { position= {x=p.x+1,y=p.y,z=p.z}, delay = 100},
                { position= {x=p.x+1,y=p.y+1,z=p.z}, delay = 200},
                { position= {x=p.x,y=p.y+1,z=p.z}, delay = 300},
                { position= {x=p.x-1,y=p.y+1,z=p.z}, delay = 400},
                { position= {x=p.x-1,y=p.y,z=p.z}, delay = 500},
                { position= {x=p.x-1,y=p.y-1,z=p.z}, delay = 600},
                { position= {x=p.x,y=p.y-1,z=p.z}, delay = 700},
                { position= {x=p.x+1,y=p.y-1,z=p.z}, delay = 800}
	for i = 1, 8 do
        addEvent(doSendDistanceShoot, positions[i].delay, positions[i].position, p, setup.effectID)
		end
	local vocations = {
			sorcerer = 1,
			druid = 2,
			paladin = 3,
			knight = 4, 
			msorcerer = 5,
			edruid = 6,
			rpaladin = 7,
			eknight = 8
		
			
	}
	local backpack = doPlayerAddItem(cid, 1988, 1)
	if getPlayerVocation(cid) == vocations.sorcerer or getPlayerVocation(cid) == vocations.druid or getPlayerVocation(cid) == vocations.msorcerer or getPlayerVocation(cid) == vocations.edruid then
		doAddContainerItem(backpack, 2160, 5)
		doAddContainerItem(backpack, 7589, 50)
		 doPlayerSendTextMessage(cid, setup.message)
		 doSetPlayerStorageValue(cid, storage, 1)
	end
	
	elseif getPlayerVocation(cid) == vocations.paladin or getPlayerVocation(cid) == vocations.rpaladin then
	doAddContainerItem(backpack, 2160, 5)
	doAddContainerItem(backpack, 7588, 50)
	 doPlayerSendTextMessage(cid, setup.message)
	 doSetPlayerStorageValue(cid, storage, 1)
	end
	elseif getPlayerVocation(cid) == vocations.knight or getPlayerVocation(cid) == vocations.eknight then
	doAddContainerItem(backpack, 2160, 5)
	doAddContainerItem(backpack, 7588, 50)
	doPlayerSendTextMessage(cid, setup.message)
	doSetPlayerStorageValue(cid, storage, 1)
	end
	return true
	end
 
Could be made shorter, alot shorter infact.
Anyways, it's good for being first so i'll give you creds on that ^^.
 
Lua:
	local positions = {
                { position= {x=p.x+1,y=p.y,z=p.z}, delay = 100},
                { position= {x=p.x+1,y=p.y+1,z=p.z}, delay = 200},
                { position= {x=p.x,y=p.y+1,z=p.z}, delay = 300},
                { position= {x=p.x-1,y=p.y+1,z=p.z}, delay = 400},
                { position= {x=p.x-1,y=p.y,z=p.z}, delay = 500},
                { position= {x=p.x-1,y=p.y-1,z=p.z}, delay = 600},
                { position= {x=p.x,y=p.y-1,z=p.z}, delay = 700},
                { position= {x=p.x+1,y=p.y-1,z=p.z}, delay = 800}
	for i = 1, 8 do
        addEvent(doSendDistanceShoot, positions[i].delay, positions[i].position, p, setup.effectID)
		end

==

Lua:
local time = 0
for x = -1, 1 do
	for y = -1, 1 do
		pos = {x = getPlayerPosition(cid).x + x, y = getPlayerPosition(cid).y + y, z = getPlayerPosition(cid).z}
		if(pos.x == getPlayerPosition(cid).x and pos.y == getPlayerPosition(cid).y) then
			addEvent(doSendDistanceShoot, time, pos, getPlayerPosition(cid), setup.effectID)
			time = time + 100
		end
	end
end
 
Lua:
	local positions = {
                { position= {x=p.x+1,y=p.y,z=p.z}, delay = 100},
                { position= {x=p.x+1,y=p.y+1,z=p.z}, delay = 200},
                { position= {x=p.x,y=p.y+1,z=p.z}, delay = 300},
                { position= {x=p.x-1,y=p.y+1,z=p.z}, delay = 400},
                { position= {x=p.x-1,y=p.y,z=p.z}, delay = 500},
                { position= {x=p.x-1,y=p.y-1,z=p.z}, delay = 600},
                { position= {x=p.x,y=p.y-1,z=p.z}, delay = 700},
                { position= {x=p.x+1,y=p.y-1,z=p.z}, delay = 800}
	for i = 1, 8 do
        addEvent(doSendDistanceShoot, positions[i].delay, positions[i].position, p, setup.effectID)
		end

==

Lua:
local time = 0
for x = -1, 1 do
	for y = -1, 1 do
		pos = {x = getPlayerPosition(cid).x + x, y = getPlayerPosition(cid).y + y, z = getPlayerPosition(cid).z}
		if(pos.x == getPlayerPosition(cid).x and pos.y == getPlayerPosition(cid).y) then
			addEvent(doSendDistanceShoot, time, pos, getPlayerPosition(cid), setup.effectID)
			time = time + 100
		end
	end
end

Thanks i will study this.
 
doesnt work.
[14/12/2011 10:25:39] [Error - LuaInterface::loadFile] data/creaturescripts/scripts/reward.lua:6: '}' expected (to close '{' at line 2) near 'storage'
[14/12/2011 10:25:39] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/reward.lua)
[14/12/2011 10:25:39] data/creaturescripts/scripts/reward.lua:6: '}' expected (to close '{' at line 2) near 'storage
 
Back
Top