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

Lua need help with a script

shadeness

@ Hackintosh
Joined
Jan 15, 2011
Messages
31
Reaction score
1
Location
Sweden
i need help with a lua script.
i am trying to create an npc that you can get nightmare or brotherhood outfit.
and if you already have nightmare you cant get brotherhood and if you already have brotherhood you cant get nightmare.
i want to know if someone could refine this code.
i have the code here
Code:
function SayText(cid)
		if(getPlayerSex(cid) == 0)then
        if doPlayerSendTextMessage == brotherhood then
            local pPos = getPlayerPosition(cid)
            doSendMagicEffect(pPos, 28)
                doPlayerAddOutfit(cid,279,0)
				else
				if doPlayerSendTextMessage == nightmare then
					local pPos = getPlayerPosition(cid)
					doSendMagicEffect(pPos, 28)
						doPlayerAddOutfit(cid,269,0)
						else
		 if doPlayerSendTextMessage == brotherhood then
            local pPos = getPlayerPosition(cid)
            doSendMagicEffect(pPos, 28)
                doPlayerAddOutfit(cid,278,0)
				else
				if 
				if doPlayerSendTextMessage == nightmare then
					local pPos = getPlayerPosition(cid)
					doSendMagicEffect(pPos, 28)
						doPlayerAddOutfit(cid,268,0)
        end
        return TRUE
Please.

~Shade~
 
Since Its an Npc, you should use msgcontains firstly, and then make the npc say something?
Lua:
local t = {
['brotherhood'] = {8001, 8002, 279, 'nightmare', 'brotherhood'},
['nightmare'] = {8002, 8001, 269, 'brotherhood', 'nightmare'}
}

for k, v in pairs(t) do
    if msgcontains(msg, k) then
       if getPlayerStorageValue(cid, v[1]) < 0 then
          if not getPlayerStorageValue(cid, v[2]) > 0 then
             npcHandler:say('Congratulations, here is your reward!', cid)
             doPlayerAddOutfit(cid, v[3], 0)
             doSendMagicEffect(getPlayerPosition(cid), 28)
             setPlayerStorageValue(cid, v[1], 1)
          else
              npcHandler:say('You already have ' .. v[4] .. ' outfit!', cid)
          end
       else
           npcHandler:say('You already have ' .. v[5] .. ' outfit', cid)
       end
    end
end
 
Since Its an Npc, you should use msgcontains firstly, and then make the npc say something?
Lua:
local t = {
['brotherhood'] = {8001, 8002, 279, 'nightmare', 'brotherhood'},
['nightmare'] = {8002, 8001, 269, 'brotherhood', 'nightmare'}
}

for k, v in pairs(t) do
    if msgcontains(msg, k) then
       if getPlayerStorageValue(cid, v[1]) < 0 then
          if not getPlayerStorageValue(cid, v[2]) > 0 then
             npcHandler:say('Congratulations, here is your reward!', cid)
             doPlayerAddOutfit(cid, v[3], 0)
             doSendMagicEffect(getPlayerPosition(cid), 28)
             setPlayerStorageValue(cid, v[1], 1)
          else
              npcHandler:say('You already have ' .. v[4] .. ' outfit!', cid)
          end
       else
           npcHandler:say('You already have ' .. v[5] .. ' outfit', cid)
       end
    end
end

this does not work.
i tried on my server/localhost.
it said *Cant load data\npc\scripts\brothernight.lua*
what is the problem here?
 
Cannot load script data/npc/scripts/brothernight.lua directory not found.
That?
You probably didn't make the XML.

i made the xml with the name brothernight.xml
and the error was something like "Cannot load script data/npc/scripts/brothernight.lua bad encoding" or somethnig like that.
 
Why the hell are you using storages to store if player has an outfit?
Lua:
local k = msgcontains(msg, 'nightmare') and 17 or msgcontains(msg, 'nightmare') and 19
if k then 
	if not canPlayerWearOutfitId(cid, 17) and not canPlayerWearOutfitId(cid, 19) then
		 npcHandler:say('Congratulations, here is your reward!', cid)
		 doPlayerAddOutfitId(cid, k, 0)
		 doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
	else
		npcHandler:say('You have already chosen an outfit.', cid)
	end
end
 
Last edited:
Why the hell are you using storages to store if player has an outfit?
Lua:
local k = msgcontains(msg, 'nightmare') and 17 or msgcontains(msg, 'nightmare') and 19
if k then 
	if not canPlayerWearOutfitId(cid, 17) and not canPlayerWearOutfitId(cid, 19) then
		 npcHandler:say('Congratulations, here is your reward!', cid)
		 doPlayerAddOutfitId(cid, k, 0)
		 doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
	else
		npcHandler:say('You have already chosen an outfit.', cid)
	end
end

is
(msg, 'nightmare') and 17 or msgcontains(msg, 'nightmare') and 19
the outfit ids?
 
so this is like if you are a female and you say nightmare, you will get female nightmare outfit and if you say brotherhood you will get female brotherhood outfit. and if you are a male you will get male outfit and so on...
and you should only get one of it?
im just asking since i didnt find any brotherhood name in there.
 
Back
Top