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

Lua Script give random exp?

Godshiryu

New Member
Joined
Mar 15, 2010
Messages
40
Reaction score
0
I'm trying do a script to do this:
In a random time, for example, for each 10 seconds it will give a random experience between 5k and 10k.
I tried and failed, as have someone help me please? I'm so bad with lua.
Thank you!
 
Lua:
function onThink()
	for _, name in ipairs(getOnlinePlayers()) do
        local cid = getPlayerByName(name)
		doPlayerAddExperience(cid, math.random(5000,10000))
	end
	return true
end

Globalevent script, make it trigger each 10 seconds if you want to give exp to all online players each 10 second.
 
Hmm, thanks but I wanna do a 'tile', for example, or action or other thing to give the random exp to 'one' player understand?
Sorry for bad explain! Thanks!
 
Code:
function onStepIn(cid, item, position, fromPosition)

if doPlayerAddExp(cid, 10000)
doSendMagicEffect(getPlayerPosition(cid), 31)
doPlayerSendTextMessage(cid,22,"You Recieved 10 000 EXP")

In actions, just set the same Unique ID on the tile that you're writing in actions.xml.
 
cant do it automatically? for example each 10 seconds he gain 10k exp? or to easily that, in this globalevent by Znote, can it do the exp only to who have X storage? Thanks!
 
I'm trying to break down the ideas for the people helping.

What you want:

Someone steps on tile
- If has storage value
They get 10k experience for each 10 seconds
- If doesn't have storage value
Nothing happens

Correct?
 
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if(getPlayerStorageValue(cid, PUT YOUR STORAGE HERE, 1) then
		for k = 1, 10 do
			addEvent(doPlayerAddExperience, k * 1000, cid, math.random(5000, 10000))
		end
		setPlayerStorageValue(cid, PUT YOUR STORAGE HERE, 0)
	end
	return true
end
 
Hi, I think is not that I want..
Is 'semi' that, but take exp forever, if are in this tile you receive 10k exp with a random time forever..
But I tried teckman's script and error... But are missing ")", then:

Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if (getPlayerStorageValue(cid, 30001, 1)) then
		for k = 1, 10 do
			addEvent(doPlayerAddExperience, k * 1000, cid, math.random(5000, 10000))
		end
		setPlayerStorageValue(cid, 30001, 0)
	end
	return true
end

But I receive this error:
Description:
(luaGetCreatureStorage) Creature not found.. Help please!
 
Back
Top