• 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
 
LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 and isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) and getPlayerLevel(cid) => 20 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
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
 
LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 and isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) and getPlayerLevel(cid) => 20 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
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end


Not working.

Now the item is not working at all.
 
I never tried Avesta, but why don't use doPlayerSetPromotionLevel(cid, 1) instead of doPlayerSetVocation(cid, getPlayerVocation(cid)+4)?
 
LUA:
function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 and isInArray({1, 2, 3, 4}, getPlayerVocation(cid)) and getPlayerLevel(cid) => 20 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
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end

Change getCreaturePosition(cid) to getPlayerPosition(cid) and it will work
 
LUA:
local noVoc = {0}

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 and not isInArray(noVoc, getPlayerVocation(cid)) and getPlayerLevel(cid) >= 20 then
		local playerpos = getCreaturePosition(cid)
		doRemoveItem(item.uid, 2279)
		--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
That should work :)
 
Change getCreaturePosition(cid) to getPlayerPosition(cid) and it will work

Still doesnt work.

- - - Updated - - -

LUA:
local noVoc = {0}

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 2279 and not isInArray(noVoc, getPlayerVocation(cid)) and getPlayerLevel(cid) >= 20 then
		local playerpos = getCreaturePosition(cid)
		doRemoveItem(item.uid, 2279)
		--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
That should work :)

Now it is just saying "Sorry, not possible." in green text.
 
make sure that you got in action.xml
LUA:
<action itemid="2279" event="script" value="xxxx.lua"/>

LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
	if  getPlayerLevel(cid) => 20 and getPlayerVocation(cid) == 0 then 
		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
 
make sure that you got in action.xml
LUA:
<action itemid="2279" event="script" value="xxxx.lua"/>

LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
	if  getPlayerLevel(cid) => 20 and getPlayerVocation(cid) == 0 then 
		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


Not working!
 
Are you sure that your vocation is 0 ?

try this
LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
	if  getPlayerLevel(cid) >= 20 and getPlayerVocation(cid) == 0 then 
		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
 
Are you sure that you have the right vocation(s) and the level?



You are doing right the thing that he DON'T want to o.O


oh aright sorry.. then mmm

LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
        if  getPlayerVocation(cid) == 0 or getPlayerStorageValue (cid, 3333) == 1 then
             doPlayerSendTextMessage(cid,22,"You have no vocation or already promoted!")
return true
end
	if  getPlayerLevel(cid) >= 20 then
		doRemoveItem(item.uid, 1)
		doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
                setPlayerStorageValue(cid, 3333, 1)
		doSendMagicEffect(playerpos, 12)
		doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
else
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
return true
end
 
Last edited:
oh aright sorry.. then mmm

LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
        if  getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == 1 or  getPlayerVocation(cid) == 2 or  getPlayerVocation(cid) == 3 or  getPlayerVocation(cid) == 4 then
return true
end
	if  getPlayerLevel(cid) >= 20 then
		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.")
return true
end


Nothing is happening when i click the item.
Not working at all.
 
Well lets try a global value

LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
        if  getPlayerVocation(cid) == 0 or getPlayerStorageValue(cid, 3333) == 1 then
             doPlayerSendTextMessage(cid,22,"You have no vocation or already promoted!")
return true
end
	if  getPlayerLevel(cid) >= 20 then
		doRemoveItem(item.uid, 1)
		doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
                setPlayerStorageValue(cid, 3333, 1)
		doSendMagicEffect(playerpos, 12)
		doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
 else
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
	end
return true
end
 
Well lets try a global value

LUA:
function onUse(cid, item, frompos, item2, topos)
                               local playerpos = getCreatureByName(cid)
        if  getPlayerVocation(cid) == 0 or getPlayerStorageValue (cid, 3333) == 1 then
             doPlayerSendTextMessage(cid,22,"You have no vocation or already promoted!")
return true
end
	if  getPlayerLevel(cid) >= 20 then
		doRemoveItem(item.uid, 1)
		doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
                setPlayerStorageValue(cid, 3333, 1)
		doSendMagicEffect(playerpos, 12)
		doPlayerSendTextMessage(cid,22,"You just got Promoted!.")
 else
	doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
	end
return true
end

Not working either.
The item ID is 5545 by the way!


This script adds vocation up, but doesnt check if the player is allready promoted or non vocation or level 20:

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


If we somehow just could edit this script so it check if the player is allready promoted, got non vocation or level 20+ ? if not it should not allow the person to use the item.
 
Can you give us the download link of the server that you are using? I tried my code and works perfectly on TFS...

I am not using TFS, i am using Avesta as it says in the topic.
There is no download link for the server and i dont plan on uploading my whole server right now.
 
Not working either.
The item ID is 5545 by the way!


This script adds vocation up, but doesnt check if the player is allready promoted or non vocation or level 20:




If we somehow just could edit this script so it check if the player is allready promoted, got non vocation or level 20+ ? if not it should not allow the person to use the item.

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