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

Attempt to compare number with boolean.

Hitsugaya

New Member
Joined
Mar 28, 2008
Messages
90
Reaction score
0
Location
Poland, Łódź, RTK
Taki oto błąd pojawia się w :
PHP:
if getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) <= 99 then
Troszku czytałem na ten temat ale, nie bardzo wiem jak to zastosować żeby miało taki sam sens :p
 
Lua:
local function reply(cid)
    local poziom = getPlayerLevel(cid)
    if getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) <= 99 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGWHITE)
    elseif getPlayerLevel(cid) >= 100 and getPlayerLevel(cid) <= 149 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGGREEN)
    elseif getPlayerLevel(cid) >= 150 and getPlayerLevel(cid) <= 199 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGPURPLE)
    return poziom
    end
    addEvent(reply, 1*350, cid) 
return true
end

function onLogin(cid)
    addEvent(reply, 1*350, cid)
return true
end

function onLogout(cid)
    stopEvent(reply)
return true
end
Prosim :>
 
Last edited by a moderator:
Zakładasz już chyba 4 temat o pomocy w lua. Rozumiem, że można prosić o pomoc ale mózg to chyba po coś Bóg nam dał?
 
1 temat był zbędny, tu się przyznam :p Napisałem go a potem znalazłem odpowiedź. Co do tego i po przedniego to naprawdę nie wiedziałem jak to zrobić. Wiem, przesadzam, ostatni temat i zacznę kombinować i szukać w internecie :> Wybaczysz ?
 
niepotrzebnie deklarujesz zmienną poziom jeśli ją później tylko niepotrzebnie zwracasz(jeśli poziom będzie między 150 a 199 nie doda eventa, chyba że tak ma być)

ale dlaczego boolean dostajesz to nie wiem

try
Code:
local function reply(cid)
    local poziom = getPlayerLevel(cid)
    if getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) <= 99 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGWHITE)
    elseif getPlayerLevel(cid) >= 100 and getPlayerLevel(cid) <= 149 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGGREEN)
    elseif getPlayerLevel(cid) >= 150 and getPlayerLevel(cid) <= 199 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGPURPLE)
    end
    addEvent(reply, 1*350, cid) 
end
 
function onLogin(cid)
    addEvent(reply, 1*350, cid)
return true
end
 
function onLogout(cid)
    stopEvent(reply)
return true
end
ale niewiele to zmieni jeśli getPlayerLevel daje ci boola

pff
 
Last edited:
Twój skrypt dał crasha silnika :p

Próbowałem tak :
Lua:
local function reply(cid)
    if getPlayerLevel(cid) >= 50 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGWHITE)
		addEvent(reply, 1*350, cid) 
	end
    if getPlayerLevel(cid) >= 100 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGGREEN)
		addEvent(reply, 1*350, cid) 
	end
    if getPlayerLevel(cid) >= 150 then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_AURARINGPURPLE)
		addEvent(reply, 1*350, cid) 
	end
    addEvent(reply, 1*350, cid) 
end
 
function onLogin(cid)
    addEvent(reply, 1*350, cid)
return true
end

Wywala taki błąd :

[07/01/2011 20:44:18] GoD Logical Scripts has logged in.
[07/01/2011 20:44:21] GoD Logical Scripts has logged out.

[07/01/2011 20:44:21] [Error - CreatureScript Interface]
[07/01/2011 20:44:21] In a timer event called from:
[07/01/2011 20:44:21] data/creaturescripts/scripts/auralevel.lua:eek:nLogin
[07/01/2011 20:44:21] Description:
[07/01/2011 20:44:21] (internalGetPlayerInfo) Player not found when requesting player info #3

[07/01/2011 20:44:21] [Error - CreatureScript Interface]
[07/01/2011 20:44:21] In a timer event called from:
[07/01/2011 20:44:21] data/creaturescripts/scripts/auralevel.lua:eek:nLogin
[07/01/2011 20:44:21] Description:
[07/01/2011 20:44:21] data/creaturescripts/scripts/auralevel.lua:2: attempt to compare number with boolean
[07/01/2011 20:44:21] stack traceback:
[07/01/2011 20:44:21] data/creaturescripts/scripts/auralevel.lua:2: in function <data/creaturescripts/scripts/auralevel.lua:1>
Ogólnie skrypt działa tylko te błędy w silniku :(

Czemu tak się dzieje ? I to tylko przy wylogowaniu.
 
Last edited by a moderator:
walnij przed pierwszym ifem w reply if isPlayer(cid)(i oczywiście domknij po)

@down: w code mniej się sypie i lepiej wygląda...
 
Last edited:
Przypominam, że należy stosować właściwie tagi dla kodu spośród dostępnych:
c# [cs], c++ [cpp], erlang [erl], javascript [js], lua
Lua:
, php [php], python [py], sql [code=sql], xml [code=xml]

[/B]W przeciwnym wypadku posty będą kasowane.
 
Przypominam, że należy stosować właściwie tagi dla kodu spośród dostępnych:
c# [cs], c++ [cpp], erlang [erl], javascript [js], lua
Lua:
, php [php], python [py], sql [code=sql], xml [code=xml]

[/B]W przeciwnym wypadku posty będą kasowane.[/QUOTE]
 
Powodzenia z tagami, ktore psuja tabulatory.
 
Przypominam, że należy stosować właściwie tagi dla kodu spośród dostępnych:
c# [cs], c++ [cpp], erlang [erl], javascript [js], lua
Lua:
, php [php], python [py], sql [code=sql], xml [code=xml]

[/B]W przeciwnym wypadku posty będą kasowane.[/QUOTE]
 
Albo Talaturen zmieni taby w tych tagach na 4 albo każdy zamiast tabów musi używać spacji(żeby jakoś wyglądało).
 
Back
Top