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

Reward on Advance

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
The player are'nt receiving the reward, only the msg:
"You won a reward for advance level."

Code:
function onAdvance(cid, skill, oldlevel, newlevel)
 local stor = 12301
  if ((oldlevel == "18") and (newlevel == "19") and (getPlayerStorageValue(cid, stor) == -1)) then
   if isSorcerer(cid) == TRUE then
    doPlayerAddItem(cid, 2188, 1)
     elseif isDruid(cid) == TRUE then
      doPlayerAddItem(cid, 2185, 1)
     elseif isPaladin(cid) == TRUE then
    doPlayerAddItem(cid, 7366, 10)
   else
  doPlayerAddItem(cid, 2515, 1)
 end
setPlayerStorageValue(cid, stor, 1)

local stor = 12302
 elseif ((oldlevel == "27") and (newlevel == "28") and (getPlayerStorageValue(cid, stor) == -1)) then
  if isSorcerer(cid) == TRUE then
   doPlayerAddItem(cid, 8871, 1)
    elseif isDruid(cid) == TRUE then
     doPlayerAddItem(cid, 8871, 1)
      elseif isPaladin(cid) == TRUE then
    doPlayerAddItem(cid, 8872, 1)
   else
  doPlayerAddItem(cid, 2476, 1)
 end
setPlayerStorageValue(cid, stor, 1)

local stor = 12303
 elseif ((oldlevel == "40") and (newlevel == "41") and (getPlayerStorageValue(cid, stor) == -1)) then
  if isSorcerer(cid) == TRUE then
   doPlayerAddItem(cid, 8900, 1)
    doPlayerAddItem(cid, 2187, 1)
     elseif isDruid(cid) == TRUE then
      doPlayerAddItem(cid, 8900, 1)
       doPlayerAddItem(cid, 2183, 1)
       elseif isPaladin(cid) == TRUE then
      doPlayerAddItem(cid, 7367, 15)
     doPlayerAddItem(cid, 2656, 1)
    else
   doPlayerAddItem(cid, 2477, 1)
  doPlayerAddItem(cid, 2536, 1)
 end
setPlayerStorageValue(cid, stor, 1)

local stor = 12304
 elseif ((oldlevel == "60") and (newlevel == "61") and (getPlayerStorageValue(cid, stor) == -1)) then
 doPlayerAddItem(cid, 2645, 2)
setPlayerStorageValue(cid, stor, 1)

end
 doPlayerSendTextMessage(cid, 22, "You won a reward for advance level.")
 return TRUE
end
Help-me :thumbup:
 
Wow, thank you!

Found a couple of things that could go wrong though, so I tried to fix em up, let me know what you think **not tested**

For the advancereward.lua:
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
	if skill == 8 then
		if getPlayerStorageValue(cid, 20202) == 4 then
			if getPlayerStorageValue(cid, 20201) ~= newLevel then
				doPlayerAddItem(cid, 2151, 1)
				setPlayerStorageValue(cid, 20201, newLevel)
				setPlayerStorageValue(cid, 20202, -1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You advanced 5 levels!")
			end
		end
	if getPlayerStorageValue(cid, 20202) < 0 then
		setPlayerStorageValue(cid, 20202, getPlayerLevel(cid)-getPlayerStorageValue(cid, 20201))
    else
		setPlayerStorageValue(cid, 20202, getPlayerStorageValue(cid, 20202)+1)
	end
	end	
end


And the death.lua:
Lua:
function onDeath(cid, corpse, deathList)
	if(getPlayerStorageValue(cid, 20201) == 10) then
		getPlayerStorageValue(cid, 20201)
	elseif(getPlayerLevel(cid)-getPlayerStorageValue(cid, 20201) < 0) then
		setPlayerStorageValue(cid, 20201, getPlayerStorageValue(cid, 20201)-5)
	end
	setPlayerStorageValue(cid, 20202, getPlayerStorageValue(cid, 20202)-1)
end

Should work, still testing though
 
Last edited:
Pardon my ignorance, but why? I usually do, but I suppose it's because I'm used to. Someone once told me to place it behind. Why should I?
The table only gets parsed when loading the scripts (aka starting up the server or reloading actions/creaturescripts/movements/whatever).
 
Wow, thank you!

Found a couple of things that could go wrong though, so I tried to fix em up, let me know what you think **not tested**

For the advancereward.lua:
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
	if skill == 8 then
		if getPlayerStorageValue(cid, 20202) == 4 then
			if getPlayerStorageValue(cid, 20201) ~= newLevel then
				doPlayerAddItem(cid, 2151, 1)
				setPlayerStorageValue(cid, 20201, newLevel)
				setPlayerStorageValue(cid, 20202, -1)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You advanced 5 levels!")
			end
		end
	if getPlayerStorageValue(cid, 20202) < 0 then
		setPlayerStorageValue(cid, 20202, getPlayerLevel(cid)-getPlayerStorageValue(cid, 20201))
    else
		setPlayerStorageValue(cid, 20202, getPlayerStorageValue(cid, 20202)+1)
	end
	end	
end


And the death.lua:
Lua:
function onDeath(cid, corpse, deathList)
	if(getPlayerStorageValue(cid, 20201) == 10) then
		getPlayerStorageValue(cid, 20201)
	elseif(getPlayerLevel(cid)-getPlayerStorageValue(cid, 20201) < 0) then
		setPlayerStorageValue(cid, 20201, getPlayerStorageValue(cid, 20201)-5)
	end
	setPlayerStorageValue(cid, 20202, getPlayerStorageValue(cid, 20202)-1)
end

Should work, still testing though

Why did you edit them? :/
Use my scripts. Don't use these. These are defective and wouldn't work how you want them to work.

@Cykotitan
Ah. That's what I'd figured out. Thank you. :p
 
Ok, thanks for the feedback. Just a couple questions. How do your scripts work? The way I gather that they work, the 20202 storage value will just keep going up unless you die. Meaning once it hits 5, it will keep going up as you level, so you wouldn't get the reward again

And the "if skill == 8 then" is actually needed or else every time ANY skill goes up you will get the reward(ie. magic level, sword fighting, fishing....)
 
I checked your scripts detailedly now. I had quickly taken a look before I'd go, so I only saw the structure, and supposed it was wrong. It would work right. ^_^

Also; mine would, too. D;.

And, oh, I didn't know about the 'skill = 8' part.

I gave you the idea, you made the system.
Good job, hehe.
 
Yah, I was getting there, but you definitly helped quite a bit.

I think the one I threw out there still needs a bit of work though: how exactly do you set the default value for the firs time a player encounters a storage value (For this one the storage value in 20202) Some times for me it sets to 4, other times 0, then sometimes 10.. (This is with a bit of tinkering, but I can't figure it out)
 
if getPlayerStorageValue(cid, XXX) == -1 then
**setPlayerStorageValue(cid, XXX, YYY)
end

Oh, and with another storage value.
 
Last edited:
Ok, for anyone who wants it:

advancereward.lua:
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
	if skill == 8 then
		if getPlayerStorageValue(cid, 20201) == -1 then
			setPlayerStorageValue(cid, 20201, 5)
		end
		
		setPlayerStorageValue(cid, 20202, getPlayerLevel(cid) - getPlayerStorageValue(cid, 20201))
		
		if getPlayerStorageValue(cid, 20202) == 5 then
			if getPlayerStorageValue(cid, 20201) ~= newLevel then
				itemcount = getPlayerItemCount(cid, 2151)
				if(itemcount == 0) then
					doPlayerAddItem(cid, 2151, 1)
				else
					doPlayerRemoveItem(cid, 2151, itemcount)
					doPlayerAddItem(cid, 2151, itemcount+1)
				end
				setPlayerStorageValue(cid, 20201, newLevel)
				setPlayerStorageValue(cid, 20202, 0)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You advanced 5 levels!")
			end
		end
	end
	return true
end

death.lua:
Lua:
function onDeath(cid, corpse, deathList)
	if(getPlayerStorageValue(cid, 20201) == -1) then
		setPlayerStorageValue(cid, 20201, 5)
	end
	
	setPlayerStorageValue(cid, 20202, getPlayerLevel(cid) - getPlayerStorageValue(cid, 20201))
end

If you see any errors, or want clarification just post here or PM me. Thanks
 
Back
Top