SK
pedido

Script de look com erro

Por Skailord, 20 de jan. de 2013 em Scripts

script
29
1.9k
SkailordS
20 de janeiro de 2013 às 18:11

Galera eu vi uma script do #Skaymagnum que adiciona uma palavra quando se dá look, só que esta com erro, toda vez que eu dou look no player dá um erro ai o forgotem dá pau e fecha num se qual é o problema, quem ajudar rep ++.

 

creaturescripts/scripts/showvocation.lua:

 

function onLook(cid, thing, position, lookDistance)
local table = {
[222] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Feiticeiro" or "He's Feiticeira",
[222] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Mago" or "He's Maga"
}
local table = table[getPlayerStorageValue(cid)]
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n[Promotion: " .. a .."]")
end
return true
end

 

Tag creaturescript.xml:

 

<event type="look" name="showVoc" event="script" value="showVocation.lua"/>

 

Tag creaturescript/scripts/ loguin.lua:

 

registerCreatureEvent(cid, "showVoc"

Editado Janeiro 20 por LuckOake

Arrumando a formata&#231;&#227;o

SlicerS
20 de janeiro de 2013 às 18:32

doPlayerSetSpecialDescription(thing.uid, "\n[Promotion: " .. a .."]")

troca pra

doPlayerSetSpecialDescription(thing.uid, "\n[Promotion: " .. table .."]")

SkailordS
20 de janeiro de 2013 às 18:38

Cara dá esse erro:

[20/01/2013 18:36:41] [Error - CreatureScript Interface]

[20/01/2013 18:36:41] data/creaturescripts/scripts/showVocation.lua:onLook

[20/01/2013 18:36:41] Description:

[20/01/2013 18:36:41] (luaGetCreatureStorage) Creature not found

 

[20/01/2013 18:36:41] [Error - CreatureScript Interface]

[20/01/2013 18:36:41] data/creaturescripts/scripts/showVocation.lua:onLook

[20/01/2013 18:36:41] Description:

[20/01/2013 18:36:41] data/creaturescripts/scripts/showVocation.lua:9: attempt to concatenate local 'table' (a nil value)

[20/01/2013 18:36:41] stack traceback:

[20/01/2013 18:36:41] data/creaturescripts/scripts/showVocation.lua:9: in function <data/creaturescripts/scripts/showVocation.lua:1>

[20/01/2013 18:36:41] Error during getDataInt(rep).

 

Editado Janeiro 20 por Skailord

SkyLighS
20 de janeiro de 2013 às 18:58
function onLook(cid, thing, position, lookDistance)
local table = {
["222"] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Feiticeiro" or "He's Feiticeira",
["222"] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Mago" or "He's Maga"
}
local table = table[getPlayerStorageValue(cid)]
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n[Promotion: " .. table .."]")
end
return true
end

SlicerS
20 de janeiro de 2013 às 18:59

mano agora q olhei melhor, esse script ta muito estranhu o.O as promotions ae sao com storages values? ou sao vocations normais? o.O

 

/\ n vai da certo..

table[getPlayerStorageValue(cid)] 

Editado Janeiro 20 por Slicer

SkailordS
20 de janeiro de 2013 às 19:06

são com storage, e skylight o seu num deu certo não:(

SlicerS
20 de janeiro de 2013 às 19:07

ta quais sao as storages entao...

SkailordS
20 de janeiro de 2013 às 19:14

Por enquanto é só uma 3426.

SlicerS
20 de janeiro de 2013 às 19:16

dai se o cara tem a promotion essa storage fica com valor 1?

SkailordS
20 de janeiro de 2013 às 19:18

sim

SlicerS
20 de janeiro de 2013 às 19:21

tenta assim..

 

function onLook(cid, thing, position, lookDistance)
local table = {
--[storage] = descriçao,
[3426] = {male = "He's a Wizard", female = "She's a Wizard"},
}
local descricao = ""
if isPlayer(thing.uid) then
  for sto, desc in pairs(table) do
   if getPlayerStorageValue(thing.uid, sto) >= 1 then
	  descricao = getPlayerSex(thing.uid) == 0 and desc.female or desc.male
	  break
   end
  end
  if descricao == "" then return true end

  doPlayerSetSpecialDescription(thing.uid, "\n[Promotion: " .. descricao .."]")
end
return true
end

 

Editado Janeiro 20 por Slicer

LuckOakeL
20 de janeiro de 2013 às 19:25

Cara, é claro que vai dar erro, a tabela tá com dois index iguais .-.

 

Troca o 222 de um desses dois aqui:

 

[222] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Feiticeiro" or "He's Feiticeira",
[222] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Mago" or "He's Maga"

 

Além do que a variável table tá com o mesmo nome da table .-.

Editado Janeiro 20 por LuckOake

SlicerS
20 de janeiro de 2013 às 19:27

tinha muitos outros erros luck '--'

SkailordS
20 de janeiro de 2013 às 19:28

Cara deu esse erro: [20/01/2013 19:26:34] Error during getDataInt(rep).

LuckOakeL
20 de janeiro de 2013 às 19:31

É, realmente.

 

function onLook(cid, thing, position, lookDistance)
local vocs = {
[1] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Feiticeiro" or "He's Feiticeira",
[2] = getPlayerSex(cid) == PLAYERSEX_MALE and "He's Mago" or "He's Maga",
}

local table = vocs[getPlayerStorageValue(cid, 222)]
if not table then return true end
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n[Promotion: " .. table .."]")
end
return true
end

 

Dei uma arrumada no script.

Editado Janeiro 20 por LuckOake