BBQ Fanatic
New Member
- Joined
- Jul 10, 2022
- Messages
- 13
- Reaction score
- 3
Hi
I'm trying to create a feature, which gives player experience when he arrives at specific location for the first time.
So far, I've made something like that (I'm not good at lua (yet ), so code review would be appreciated)
movements.xml
discover.lua
In RME:
And, whats surprising to me, it works.
But I'd like to have multiple places like this.
Theoretically I can copy-paste that X times. But I imagine it can be done somehow using arrays. But I don't know how to do it. The only thing that came up to my head was starting with array like this:
And on that I stuck. Have no idea how modify that code to work with array, dunno if i gotta use for loop or whatever.
And, how link that in movements.xml since it has actionId parameter, which will be different for each place.
I'm trying to create a feature, which gives player experience when he arrives at specific location for the first time.
So far, I've made something like that (I'm not good at lua (yet ), so code review would be appreciated)
movements.xml
Code:
<movevent event="StepIn" actionid="6661" script="discover.lua"/>
discover.lua
Code:
function onStepIn(cid, item, pos)
local discover = 7670
if isPlayer(cid) then
if getPlayerStorageValue(cid,discover) < 0 then
setPlayerStorageValue(cid, discover, 1)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You discovered new place. \n You gained 1750 experience points.")
doPlayerAddExp(cid, 1750)
end
end
end
In RME:
And, whats surprising to me, it works.
But I'd like to have multiple places like this.
Theoretically I can copy-paste that X times. But I imagine it can be done somehow using arrays. But I don't know how to do it. The only thing that came up to my head was starting with array like this:
Code:
local places = {
{ aid = 6661, storage = 7670, name = 'Cave', expgain = 500 }, --"name" appears here, because message will be showing discovered place's name
{ aid = 6662, storage = 7671, name = 'Other Place', expgain = 1000 }, -- exp will be various depending on the location level
}
And on that I stuck. Have no idea how modify that code to work with array, dunno if i gotta use for loop or whatever.
And, how link that in movements.xml since it has actionId parameter, which will be different for each place.
Last edited: