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

Windows Training Room Script

terciomatos

New Member
Joined
Oct 22, 2008
Messages
2
Reaction score
0
TheForgottenServer 831

I have 2 scripts about training room, the first just leave some vocations enter, but can enter more than 1 people in the box.

function onUse(cid, item, frompos, item2, topos)
reqvoc = getPlayerVocation(cid)
if item.uid == 5637 then
if (reqvoc == 1 or reqvoc == 2 or reqvoc == 3 or reqvoc == 4 or reqvoc == 5 or reqvoc == 6 or reqvoc == 7 or reqvoc == 8) then
pos = getPlayerPosition(cid)

if pos.x == topos.x then
if pos.y < topos.y then
pos.y = topos.y + 1
else
pos.y = topos.y - 1
end
elseif pos.y == topos.y then
if pos.x < topos.x then
pos.x = topos.x + 1
else
pos.x = topos.x - 1
end
else
doPlayerSendTextMessage(cid,22,'Stand in front of the door.')
return 1
end

doTeleportThing(cid,pos)
doSendMagicEffect(topos,12)
else
doPlayerSendTextMessage(cid,22,'Only the characters NOT vip can enter here.')
end
return 1
else
return 0
end
end

The second, just one person can enter, but don't ask the vocation, any voc can enter.

function onUse(cid, item, frompos, item2, topos)



-- <beginning> Training Room script by Alreth.

-- Version 1.0, last edited 2006-06-02 17:39



-- Beginning of editable Variabels

aidNor = 4211 -- Action id for door where training room is north of door

aidSou = 4212 -- Action id for door where training room is south of door

aidWes = 4213 -- Action id for door where training room is west of door

aidEas = 4214 -- Action id for door where training room is east of door

-- End of editable Variabels



emptyRoom = true

charPos = getPlayerPosition(cid)



if (item.actionid == aidNor) then

if (charPos.y < frompos.y) then

othersidePos = {x=frompos.x, y=frompos.y+1, z=frompos.z}

else

othersidePos = {x=frompos.x, y=frompos.y-1, z=frompos.z, stackpos=253}

things = getThingfromPos(othersidePos)

if (things.itemid == 1) then

if (getPlayerLevel(things.uid) > 0) then

emptyRoom = false

end

end

end



elseif (item.actionid == aidSou) then

if (charPos.y > frompos.y) then

othersidePos = {x=frompos.x, y=frompos.y-1, z=frompos.z}

else

othersidePos = {x=frompos.x, y=frompos.y+1, z=frompos.z, stackpos=253}

things = getThingfromPos(othersidePos)

if (things.itemid == 1) then

if (getPlayerLevel(things.uid) > 0) then

emptyRoom = false

end

end

end



elseif (item.actionid == aidEas) then

if (charPos.x > frompos.x) then

othersidePos = {x=frompos.x-1, y=frompos.y, z=frompos.z}

else

othersidePos = {x=frompos.x+1, y=frompos.y, z=frompos.z, stackpos=253}

things = getThingfromPos(othersidePos)

if (things.itemid == 1) then

if (getPlayerLevel(things.uid) > 0) then

emptyRoom = false

end

end

end



elseif (item.actionid == aidWes) then

if (charPos.x < frompos.x) then

othersidePos = {x=frompos.x+1, y=frompos.y, z=frompos.z}

else

othersidePos = {x=frompos.x-1, y=frompos.y, z=frompos.z, stackpos=253}

things = getThingfromPos(othersidePos)

if (things.itemid == 1) then

if (getPlayerLevel(things.uid) > 0) then

emptyRoom = false

end

end

end



end



if (emptyRoom == true) then

doTeleportThing(cid, othersidePos)

doSendMagicEffect(charPos, 2)

doSendMagicEffect(frompos, 12)

doSendMagicEffect(othersidePos, 10)



else

doPlayerSendTextMessage(cid, 22, "Essa sala de treinamento está ocupada.")

end

-- <end> Training Room script by Alreth.



return 1

end

I wanna a script who 1 person can enter in the box (trainer) but ask for voc x, y or z (1, 2, 3, 4, 5, 6, 7, 8).

If someone can help me, tks.
 
Please do not use quote tags for codes.

Something like this should do, let me know if any errors occurrs.
PHP:
local directon = "north"

function onUse(cid, item, fromPosition, itemEx, toPosition)
     if isInArray({1,2,3,4,5,6,7,8}, getPlayerVocation(cid)) then
           if direction == "north" then
               toPosition.y = toPosition.y - 1
           elseif direction == "east" then
                 toPosition.x = toPosition.x + 1
           elseif direction == "south" then
                 toPosition.y = toPosition.y + 1
           else
                 toPosition.x = toPosition.x - 1
           end
           if isPlayer(getThingfromPos(toPosition)) == 1 then
                doPlayerSendTextMessage(cid, 21, "This room is already occupied.")
                doSendMagicEffect(getCreaturePosition(cid), 2)
           else
                doTeleportThing(cid, toPosition)
                doSendMagicEffect(getCreaturePosition(cid), 12)
           end
     else
          doPlayerSendTextMessage(cid, 21, "Your vocation is not allowed to enter this room.")
            doSendMagicEffect(getCreaturePosition(cid), 2)
     end
end
 
Aswer

Don't work, the player go 1 SQM to left, he need will 2 sqm to north.

I change my Trainer Room and now its ok, I´m using the 2 scripts to 2 romms.

Ty all.. :thumbup:
 
Back
Top