DE
dúvida

Dúvida No Script De Uma Runa.

Por Derlexy, 28 de ago. de 2012 em Scripts

script
14
1.6k
DerlexyD
28 de agosto de 2012 às 14:00

Minha dúvida é se essa função (No caso seria uma runa que somente gm, god e adm poderiam usar).

Bom, estou tetando aprender a criar funções, então, estava fazendo mas acho que tem algo errado ai... Alguém pode me ajudar? A ver se tem algo errado e que não deixaria a runa funcionar corretamente?

 

function onUse(cid, item, frompos, item2, topos)
player1pos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}
player1 = getThingfromPos(player1pos)
target = player1.uid
templewinpos = {x=0,y=0,z=0} -- Coordenadas da sala de Recompensas.
player1positions = {
{x=0,y=0,z=0},
{x=1,y=1,z=1},
{x=2,y=2,z=2}
} -- Locais onde é possível usar a runa no player.
if getPlayerAccess(cid) =>= 2 then
if getCreaturePosition(target) = isInArray(player1positions, TRUE) then
 if getPlayerAccess(target) = 1 then
 doTeleportThing(target, templewinpos)
 setPlayerStorageValue(target, 9999, 0)
 doPlayerBroadcastMessage(target, "Congratulations, you won the game. Take your prizes in the chests and head to the exit.", 10)
 doSendMagicEffect(topos, 10)
 doSendAnimatedText(topos, "Winner!", 140)
 else doPlayerBroadcastMessage(cid, "Sorry, you can not use this item if not in a player.", 10)
else doPlayerBroadcastMessage(cid, "Sorry, you can only use this item for players who are in the awards position.", 10)
else doPlayerBroadcastMessage(cid, "Sorry, you havent access to use this item.", 10)
 end
end
end
end

 

PS: Os valores dos efeitos, e da storage são ficticios....

Editado Agosto 28 por Derlexy

notle2012N
28 de agosto de 2012 às 14:35

não testei só tirei os erros que vi

function onUse(cid, item, frompos, item2, topos)
player1pos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}
player1 = getThingfromPos(player1pos)
target = player1.uid
templewinpos = {x=0,y=0,z=0} -- Coordenadas da sala de Recompensas.
player1positions = {
{x=0,y=0,z=0},
{x=1,y=1,z=1},
{x=2,y=2,z=2}
} -- Locais onde é possível usar a runa no player.
if getPlayerAccess(cid) >= 2 then
if getCreaturePosition(target) == isInArray(player1positions, TRUE) then
if getPlayerAccess(target) == 1 then
doTeleportThing(target, templewinpos)
setPlayerStorageValue(target, 9999, 0)
doPlayerBroadcastMessage(target, "Congratulations, you won the game. Take your prizes in the chests and head to the exit.", 10)
doSendMagicEffect(topos, 10)
doSendAnimatedText(topos, "Winner!", 140)
else
doPlayerBroadcastMessage(cid, "Sorry, you can not use this item if not in a player.", 10)
end
else
doPlayerBroadcastMessage(cid, "Sorry, you can only use this item for players who are in the awards position.", 10)
end
else
doPlayerBroadcastMessage(cid, "Sorry, you havent access to use this item.", 10)
end
end

DerlexyD
28 de agosto de 2012 às 21:07

Bom, tentei rodar o script no servidor, e arrumei alguns erros que estavam dando... Agora, ao entrar com o ADM e tentar usar o script ele denunciou o seguinte:

[28/08/2012 21:03:19] [Warning - Action::loadFunction] Function "other/runewin.lua" does not exist.

 

O script está assim:

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


player1pos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}
player1 = getThingfromPos(player1pos)
target = player1.uid
templewinpos = {x=0,y=0,z=0} -- Coordenadas da sala de Recompensas.

player1positions = {
{x=0,y=0,z=0},
{x=1,y=1,z=1},
{x=2,y=2,z=2}
} -- Locais onde é possível usar a runa no player.


if getPlayerAccess(cid) >= 2 then
if getCreaturePosition(target) == isInArray(player1positions, TRUE) then
 if getPlayerAccess(target) == 1 then
 doTeleportThing(target, templewinpos)
 setPlayerStorageValue(target, 9999, 0)
 doPlayerBroadcastMessage(target, "Congratulations, you won the game. Take your prizes in the chests and head to the exit.", 22)
 doSendMagicEffect(topos, 28)
 doSendMagicEffect(topos, 14)
 doSendAnimatedText(topos, "Winner!", 82)
 else
 doPlayerBroadcastMessage(cid, "Sorry, you can not use this item if not in a player.", 22)
 end
else
doPlayerBroadcastMessage(cid, "Sorry, you can only use this item for players who are in the awards position.", 22)
end
else
doPlayerBroadcastMessage(cid, "Sorry, you havent access to use this item.", 22)
end
return TRUE
end

 

E a tag está assim:

<action itemid="2420" event="function" value="other/runewin.lua"/>

 

Alguém sabe arrumar?

 

/\

Editado Agosto 28 por Derlexy

LuckOakeL
28 de agosto de 2012 às 21:09

Bom, o script ficaria melhor organizado assim:

 

 

function onUse(cid, item, topos)

player1pos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}

player1 = getThingfromPos(player1pos)

target = player1.uid

templewinpos = {x=0,y=0,z=0} -- Coordenadas da sala de Recompensas

player1positions = {

{x=0,y=0,z=0},

{x=1,y=1,z=1},

{x=2,y=2,z=2}

} -- Locais onde é possível usar a runa no player

 

if getPlayerAccess(cid) < 2 then

doPlayerSendCancel(cid, "Sorry, you haven't access to use this item.")

return true

end

 

if getCreaturePosition(target) ~= isInArray(player1positions, TRUE) then

doPlayerSendCancel(cid, "Sorry, you can only use this item in players which are in the awards position.")

end

 

if getPlayerAccess(target) ~= 1 then

doPlayerSendCancel(cid, "Sorry, you can not use this item if not in a player.")

end

 

doTeleportThing(target, templewinpos)

setPlayerStorageValue(target, 9999, 0)

doPlayerSendCancel(target, "Congratulations, you won the game. Take your prizes in the chests and head to the exit.")

doSendMagicEffect(topos, 10)

doSendAnimatedText(topos, "Winner!", 140)

return true

end

 

 

Usa essa tag:

 

<action itemid="xxxx" script="other/runewin.lua"/>

 

Substitua o xxxx por um itemid que desejar.

Editado Agosto 28 por LuckOake

DerlexyD
28 de agosto de 2012 às 21:15

Opa, algum sinal... Parece ter funcionado, porém, quando eu uso no ADM, ele informa a mensagem de que nao é possivel usar em ADM, nao teleporta, mas mesmo assim os efeitos sao executados... No caso os efeitos seriam somente se funcionasse... Oque pode ser?

 

E os seguintes erros:

[28/08/2012 21:18:36] [Error - Action Interface]
[28/08/2012 21:18:36] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:18:36] Description:
[28/08/2012 21:18:36] (luaGetThingFromPos) Tile not found
[28/08/2012 21:18:36] [Error - Action Interface]
[28/08/2012 21:18:36] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:18:36] Description:
[28/08/2012 21:18:36] (luaGetThingPosition) Thing not found
[28/08/2012 21:18:36] [Error - Action Interface]
[28/08/2012 21:18:36] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:18:36] Description:
[28/08/2012 21:18:36] (internalGetPlayerInfo) Player not found when requesting player info #1
[28/08/2012 21:18:36] [Error - Action Interface]
[28/08/2012 21:18:36] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:18:36] Description:
[28/08/2012 21:18:36] (luaDoTeleportThing) Thing not found
[28/08/2012 21:18:36] [Error - Action Interface]
[28/08/2012 21:18:36] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:18:36] Description:
[28/08/2012 21:18:36] (luaDoCreatureSetStorage) Creature not found
[28/08/2012 21:18:36] [Error - Action Interface]
[28/08/2012 21:18:36] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:18:36] Description:
[28/08/2012 21:18:36] (luaDoPlayerSendCancel) Player not found

Editado Agosto 28 por Derlexy

LuckOakeL
28 de agosto de 2012 às 21:22

Erro meu. Vê se assim resolve:

 

 

function onUse(cid, item, frompos, topos)

player1pos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}

player1 = getThingfromPos(player1pos)

target = player1.uid

templewinpos = {x=0,y=0,z=0} -- Coordenadas da sala de Recompensas

player1positions = {

{x=0,y=0,z=0},

{x=1,y=1,z=1},

{x=2,y=2,z=2}

} -- Locais onde é possível usar a runa no player

 

if getPlayerAccess(cid) < 2 then

doPlayerSendCancel(cid, "Sorry, you haven't access to use this item.")

return true

end

 

if getCreaturePosition(target) ~= isInArray(player1positions, TRUE) then

doPlayerSendCancel(cid, "Sorry, you can only use this item in players which are in the awards position.")

return true

end

 

if getPlayerAccess(target) ~= 1 then

doPlayerSendCancel(cid, "Sorry, you can not use this item if not in a player.")

return true

end

 

doTeleportThing(target, templewinpos)

setPlayerStorageValue(target, 9999, 0)

doPlayerSendCancel(target, "Congratulations, you won the game. Take your prizes in the chests and head to the exit.")

doSendMagicEffect(topos, 10)

doSendAnimatedText(topos, "Winner!", 140)

return true

end

 

 

Se ainda não funcionar, qual a versão do seu server?

Editado Agosto 28 por LuckOake

DerlexyD
28 de agosto de 2012 às 21:29

Modifiquei, e agora esta dando este erro:

[28/08/2012 21:28:37] [Error - Action Interface]
[28/08/2012 21:28:37] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:28:37] Description:
[28/08/2012 21:28:37] (luaGetThingFromPos) Tile not found
[28/08/2012 21:28:37] [Error - Action Interface]
[28/08/2012 21:28:37] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:28:37] Description:
[28/08/2012 21:28:37] (luaGetThingPosition) Thing not found
[28/08/2012 21:28:37] [Error - Action Interface]
[28/08/2012 21:28:37] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:28:37] Description:
[28/08/2012 21:28:37] (internalGetPlayerInfo) Player not found when requesting player info #1

 

Desta vez eu usei em um player com access normal, de player, e mesmo assim deu a mensagem pro ADM de que nao podia usar no player por causa do access...

 

VERSAO 8.60....

Editado Agosto 28 por Derlexy

SkymagnumS
28 de agosto de 2012 às 21:33

 

function onUse(cid, item, item2)
local pos = {x = 123, y = 123, z = 7} --- pos aonde sera teleportado

if getPlayerAcess(cid) < 2 then
doSendMagicEffect(getPlayerPosition(cid), 2)
doPlayerSendCancel(cid, "You need acces to use this rune.") return true
end



if getPlayerAcess(item2.uid) > 2 then
doSendMagicEffect(getPlayerPosition(cid), 2)
doPlayerSendCancel(cid, "You can't use this rune in this player.") return true
end

if isPlayer(item2.uid) then
doSendAnimatedText(getPlayerPosition(item2.uid), "Winner!", math.random(1, 255))
doTeleportThing(item2.uid, pos)
setPlayerStorageValue(item2.uid, 9999, 0)
doPlayerSendTextMessage(item2.uid, 27, "Congratulations, you won the game. Take your prizes in the chests and head to the exit.")
doSendMagicEffect(item2.uid, 10)
doSendMagicEffect(item2.uid, math.random(28, 30))
end
return true
end

 

 

 

OBS tera que usar no player

DerlexyD
28 de agosto de 2012 às 21:38

Não funcionou Skymagnum... =/

 

[Error - Action Interface]
[28/08/2012 21:37:56] data/actions/scripts/other/runewin.lua:onUse
[28/08/2012 21:37:56] Description:
[28/08/2012 21:37:56] data/actions/scripts/other/runewin.lua:4: attempt to call global 'getPlayerAcess' (a nil value)
[28/08/2012 21:37:56] stack traceback:
[28/08/2012 21:37:56]  data/actions/scripts/other/runewin.lua:4: in function <data/actions/scripts/other/runewin.lua:1>

Editado Agosto 28 por Derlexy

MulizeuM
28 de agosto de 2012 às 22:17
function onUse(cid,item,position,item2,fromPosition)
local remove = false ---item quando usado sera removido? false == nao

if getPlayerAccess(cid) <= 4 then
return doPlayerSendCancel(cid,"Sorry, only members to staff")
end
--------------------------------------------------------------------------
if getPlayerAccess(item2.uid) >= 4 then
return doPlayerSendCancel(cid,"Sorry, not used in staff")
end
--------------------------------------------------------------------------
doTeleportThing(item2.uid,{x=0,y=0,z=0}) -----pos onde sera teleportado
doPlayerSendTextMessage(item2.uid,27,"Oh!, you is a winner player!")
doSendMagicEffect(getCreaturePosition(item2.uid), 10)
doSendAnimatedText(getCreaturePosition(item2.uid), "Winner!", 140)
setPlayerStorageValue(item2.uid,999,0) ---------altere a storage
--------------------------------------------------------------------------
if remove == true then
doPlayerRemoveItem(item.uid)
end

return TRUE
end

DerlexyD
28 de agosto de 2012 às 22:21

mulizeu.... Funcionou, a não ser por aquela parte que te mandei por PM... Ja usei o rep+ de hoje, mas assim que liberar estarei lhe dando por me ajudar. Grato, espero que possa me ajudar mais :p thxthx

MulizeuM
28 de agosto de 2012 às 22:22

Sobre aquilo assim q tiver tempo te mando ageitado! esquenta com rep+ nao, oq vale é ajudar e aprender cada dia!

Editado Agosto 28 por mulizeu

CriticalC
29 de agosto de 2012 às 22:29

Dúvida sanada, tópico movido.

 

Atenciosamente, Critical.

DerlexyD
30 de agosto de 2012 às 08:35

Obg =), estava procurando para reportar, mas já foi movido ^^

Editado Agosto 30 por Derlexy