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

Solved Problem with creaturescripts

Delvire

°£°
Joined
Feb 24, 2008
Messages
236
Reaction score
9
Hello everybody...

Some days ago, I did a script, and It works like:

"The player logs his new character in a little island, in this island, there are trainers, but the player cannot rain there forever... when he get a X amount of melee/distance/shield/magic level he is kicked from the trainers and is no more able to enter in the Trainers room"

This is the script:
local config =
{
pos = {x = 537, y = 558, z = 7},
message = "Você já não pode mais treinar.",
levelToTeleport = 40,
skillfi = 0, -- 0 = fist
skillcl = 1, -- 1 = club
skillsw = 2, -- 2 = sword
skillax = 3, -- 3 = axe
skillsh = 5 -- 5 = shielding
}

function onAdvance(cid, skill, oldlevel, newlevel)

if (getPlayerStorageValue(cid,9000) == 1 and skill == config.skillfi and newlevel == config.levelToTeleport or config.skillcl and newlevel == config.levelToTeleport or config.skillsw and newlevel == config.levelToTeleport or config.skillax and newlevel == config.levelToTeleport or config.skillsh and newlevel == config.levelToTeleport) then
doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1, config.message)
doTeleportThing(cid, config.pos)
doSendMagicEffect(config.pos, 10)
setPlayerStorageValue(cid,9000,2)


end
return TRUE
end
The problem is the "getPlayerStorageValue(cid,9000) == 1", the script works, but simply don't check if the player have the following storage value, and It causes several bugs:

For example: "The player advanced his sword fighting skill to 40, he will be kicked from the training room... ok Some time later... he decides to train his club skill, and when he get 40 of club, he will be teleported to the small island, sayng:'You may not train anymore')"

:(

So, the basical problem is the storage value checking, It's obious that I'll REP++ those who help me
 
Last edited:
Hello!

Try this:
Lua:
local config =
{
pos = {x = 537, y = 558, z = 7},
message = "Você já não pode mais treinar.",
levelToTeleport = 40,
skillfi = 0, -- 0 = fist
skillcl = 1, -- 1 = club
skillsw = 2, -- 2 = sword
skillax = 3, -- 3 = axe
skillsh = 5 -- 5 = shielding
}

function onAdvance(cid, skill, oldlevel, newlevel)

if (getPlayerStorageValue(cid,9000) == 1 and skill == config.skillfi and newlevel == config.levelToTeleport or config.skillcl and newlevel == config.levelToTeleport or config.skillsw and newlevel == config.levelToTeleport or config.skillax and newlevel == config.levelToTeleport or config.skillsh and newlevel == config.levelToTeleport) then
doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1, config.message)
doTeleportThing(cid, config.pos)
doSendMagicEffect(config.pos, 10)
setPlayerStorageValue(cid,9000,1)


end
return TRUE
end
I don't tested it but it should work, the problem was setPlayerStorageValue(cid,9000,2).

Regards!
 
The problem, Xampy, is that I used the setPlayerStorageValue(cid,9000,1) in another script :/ but thanks for trying to help
 
I got the problem! It was a logic problem!

getPlayerStorageValue(cid,9000) == 1 --> It checks if the player have the storage value, If yes... the script acts, and add to the player the Storage Value # (cid,9000,2)

Doesn't matters if the player have the storage value # (cid,9000,2) or not, he's still having the Storage Value # (cid,9000,1) so, what I should do is:

setPlayerStorageValue(cid,9000,-1)
instead of
setPlayerStorageValue(cid,9000,2)
 
Back
Top