• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Avesta] Help with script

Veterana

Oldschool Player
Joined
May 4, 2010
Messages
194
Reaction score
7
Can someone help me with this promotion script?

I want it to check if the player is allready promoted and if he is, it should not promote him.
Also, if the player has "No Vocation" it should not promote him.

It should also check if the player is level 20 or higher.

Someone got the skills to add this into the script? Thank you!


--- Written by X_anero
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2279 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,2279)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
end
end
 
k
in actions.xml
LUA:
<action itemid="5545" event="script" value="promotion.lua"/>

in actions/scrips/
add promotion.lua

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
end
return true
end

It now promotes the player.
But if you use another promotion item, it will promote him again and again endlessly!
This means that you can promote yourself further on after you are allready promoted, very bugged.
 
K but you said that dont check if already promoted !!

ok this will work

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 and getPlayerStorageValue(cid, 2222) == 1 then
doPlayerSendTextMessage(cid,22,"You already Promoted!.")
return true
end
if item.itemid == 5545 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSetPlayerStorageValue(cid, 2222, 1)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
end
return true
end
 
xD the promotion for him is: Vocation id = more than 0
not a vocation promotion Promoted(cid) == 0


LUA:
local promoItem = 5545

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == promoItem and getPlayerVocation(cid) > 0 and isPromoted(cid) == 0 and getPlayerLevel(cid) >= 20 then
		local playerpos = getCreaturePosition(cid)
		doRemoveItem(item.uid, promoItem)
		doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
		doPlayerSetPromotionLevel(cid, 1)
		doSendMagicEffect(playerpos, 12)
		doPlayerSendTextMessage(cid, 22, "You just got Promoted!.")
	else
		doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
	end
	return TRUE
end

If that shit doesn't work I'm gonna kill myself -.-
 
K but you said that dont check if already promoted !!

ok this will work

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 and getPlayerStorageValue(cid, 2222) == 1 then
doPlayerSendTextMessage(cid,22,"You already Promoted!.")
return true
end
if item.itemid == 5545 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSetPlayerStorageValue(cid, 2222, 1)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
end
return true
end

Still promotes player if it is allready promoted.

- - - Updated - - -

LUA:
local promoItem = 5545

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == promoItem and getPlayerVocation(cid) > 0 and isPromoted(cid) == 0 and getPlayerLevel(cid) >= 20 then
		local playerpos = getCreaturePosition(cid)
		doRemoveItem(item.uid, promoItem)
		doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
		doPlayerSetPromotionLevel(cid, 1)
		doSendMagicEffect(playerpos, 12)
		doPlayerSendTextMessage(cid, 22, "You just got Promoted!.")
	else
		doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
	end
	return TRUE
end

If that shit doesn't work I'm gonna kill myself -.-

Not working at all, i think you are coding for TFS and not Avesta, it is abit different.
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerStorageValue(cid, 2222) == -1 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSetPlayerStorageValue(cid, 2222, 1)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end

return true
end
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerStorageValue(cid, 2222) == -1 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSetPlayerStorageValue(cid, 2222, 1)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end

return true
end

Still promoting the player after he is promted.
 
lol, stop trying stupid codes... he say that he is using avesta, also your codes just remove the item and add +4 to the voc, and +4, +4, +4...
sec.


LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 and isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) == true and getPlayerLevel(cid) => 20 then
		local playerpos = getPlayerPosition(cid)
		doRemoveItem(item.uid, 1)
		doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
		doSendMagicEffect(playerpos, 12)
		doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
	end
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
 
Last edited:
lol, stop trying stupid codes... he say that he is using avesta, also your codes just remove the item and add +4 to the voc, and +4, +4, +4...
sec.

You think you know how to fix it?

- - - Updated - - -

Close your ot and open it again !

I have a reload function, works the same as closing the server and opening it again
 
try the last code i posted, and if it doesnt work, post the console error

It is giving me this error in console:

Warning: [Event::loadScript] Can not load script. data/actions/scripts/promotion.lua
data/actions/scripts/promotion.lua:2: 'then' expected near '='

- - - Updated - - -

LUA:
local promoItem = 5545

function onUse(cid, item, frompos, item2, topos)
	if (item.itemid == promoItem) then
		if (getPlayerVocation(cid) > 0) then 
			if (isPromoted(cid) == 0) then
				if (getPlayerLevel(cid) >= 20) then
					local playerpos = getCreaturePosition(cid)
					doRemoveItem(item.uid, promoItem)
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					doPlayerSetPromotionLevel(cid, 1)
					doSendMagicEffect(playerpos, 12)
					doPlayerSendTextMessage(cid, 22, "You just got Promoted!.")
				else
					doPlayerSendTextMessage(cid, 22, "Sorry, not possible.")
				end
			end
		end
	end
	return TRUE
end

Not working at all.
 
LUA:
function onUse(cid, item)
	if item.itemid == 2279 then
		if isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) == TRUE then
			if getPlayerLevel(cid) > 19 then
				doRemoveItem(item.uid)
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				doSendMagicEffect(getThingPos(cid), 12)
				doPlayerSendTextMessage(cid, 22, "You have been promoted.")
			else
				doPlayerSendTextMessage(cid, "You need level 20.")
			end
		else
			doPlayerSendTextMessage(cid, "You have already been promoted.")
		end
	end
	
	return 1
end
 
It is giving me this error in console:

Warning: [Event::loadScript] Can not load script. data/actions/scripts/promotion.lua
data/actions/scripts/promotion.lua:2: 'then' expected near '='

Lol I'm done. To fix StreamSide code just change => 20 to >= 20.
 
LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 then
		if isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) == true then
			if getPlayerLevel(cid) => 20 then
				local playerpos = getPlayerPosition(cid)
				doRemoveItem(item.uid, 2279)
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				doSendMagicEffect(playerpos, 12)
				doPlayerSendTextMessage(cid,22,"You just got Promoted!")
			else
				doPlayerSendTextMessage(cid,22,"Sorry, you need level 20 or more.")
			end
		else
			doPlayerSendTextMessage(cid,22,"You are already promoted.")
		end
	end
	return true
end
 
LUA:
function onUse(cid, item)
	if item.itemid == 2279 then
		if isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) == TRUE then
			if getPlayerLevel(cid) > 19 then
				doRemoveItem(item.uid)
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				doSendMagicEffect(getThingPos(cid), 12)
				doPlayerSendTextMessage(cid, 22, "You have been promoted.")
			else
				doPlayerSendTextMessage(cid, "You need level 20.")
			end
		else
			doPlayerSendTextMessage(cid, "You have already been promoted.")
		end
	end
	
	return 1
end

Not working.

- - - Updated - - -

LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 then
		if isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) == true then
			if getPlayerLevel(cid) => 20 then
				local playerpos = getPlayerPosition(cid)
				doRemoveItem(item.uid, 2279)
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				doSendMagicEffect(playerpos, 12)
				doPlayerSendTextMessage(cid,22,"You just got Promoted!")
			else
				doPlayerSendTextMessage(cid,22,"Sorry, you need level 20 or more.")
			end
		else
			doPlayerSendTextMessage(cid,22,"You are already promoted.")
		end
	end
	return true
end

Not working.
 
ok try this one...

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerVocation(cid) >= 1 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end
 
return true
end
 
ok try this one...

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerVocation(cid) >= 1 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end
 
return true
end


It is still promoting the player after it has promotion.
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if not getPlayerVocation(cid) >= 1 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end
 
return true
end
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerVocation(cid) >= 1 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end
 
return true
end

it will promote the player anyways, thats why i use is in array

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerVocation(cid) > 0 and getPlayerVocation(cid) < 5 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end

return true
end
 
Thanks StreamSide.
Please look private message!

- - - Updated - - -

it will promote the player anyways, thats why i use is in array

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 5545 then
if getPlayerVocation(cid) > 0 and getPlayerVocation(cid) < 5 then
local playerpos = getCreaturePosition(cid)
doRemoveItem(item.uid,1)
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
doSendMagicEffect(playerpos, 12)
doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
doPlayerSendTextMessage(cid,22,"You already promoted!.")
return true
end
end

return true
end


Please look your private message!
 
Back
Top