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

How to enter in a guild with a NPC?

mikeware

New Member
Joined
Jul 17, 2007
Messages
338
Reaction score
0
Location
Brazil
hey,

im trying to make a npc that join you to a guild but it seems not working, heres the error:
attempt to call global 'doPlayerSetGuildId' (a nil value)

here's what im trying:
Code:
guild1 = getGuildId(GUILD1)
doPlayerSetGuildId(cid, guild1)
doPlayerSetGuildRank(cid,1)

obs: obviously have the other part of the script but its all right

i guess im using this doPlayerSetGuildId wrong...

any sugestions or tips? thanks
 
Here's the whole script:
Code:
local GUILD1 = "guildname"
local GUILD1TYPE = "guild"

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) 

end
function onCreatureDisappear(cid) 

npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end


function creatureSayCallback(cid, type, msg) 
if(npcHandler.focus ~= cid) then 
return false 
end 

if msgcontains(msg, 'guild') or msgcontains(msg, 'found') or msgcontains(msg, 'join') then

if getPlayerGuildId(cid) == 0 then
if getPlayerLevel(cid) >= 50 then
selfSay('Do you want to join in ' .. GUILD1 .. '?')
talk_state = 10
else
selfSay('You must be level 50 or more to join in the guild.')
return false
end
else
selfSay('You already are in a guild.')
return false
end

elseif talk_state == 10 then
if msgcontains(msg, GUILD1TYPE) then
selfSay('' .. GUILD1 .. ', are you sure? This decision is irreversible!')
talk_state = 11
end

elseif talk_state == 11 then
if msgcontains(msg, 'yes') then
cname = getPlayerName(cid)
selfSay('Congratulations ' .. cname .. ', you are now a member of the ' .. GUILD1 .. '!')
guildid1 = getGuildId(GUILD1)
doPlayerSetGuildId(cid, guildid1)
doPlayerSetGuildRank(cid,1)
doPlayerSendTextMessage(cid,19,"You can now enter in your guild channel.")
end
end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

what's wrong with the script?
 
i belive that's 'doPlayerSetGuildId' is unknown comand by the newest svn (if u create the npc based at newest svn). If based at old (april or old SVNs) just use evolutions npcs ;b

I need npc of guild to newest svn too ;/
 
this was a fast edid and not tested... try this script:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)			 npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)	 npcHandler:onCreatureSay(cid, type, msg) end
function onThink()						 npcHandler:onThink() end
-- OTServ event handling functions end
-------------local shot
local GUILD1 = guildname
local GUILD1TYPE = guild
----------------localshit

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

if msgcontains(msg, 'guild') or msgcontains(msg, 'found') or msgcontains(msg, 'join') then

if getPlayerGuildId(cid) == 0 then
if getPlayerLevel(cid) >= 50 then
selfSay('Do you want to join in ' .. GUILD1 .. '?')
talk_state = 10
else
selfSay('You must be level 50 or more to join in the guild.')
return false
end
else
selfSay('You already are in a guild.')
return false
end

elseif talk_state == 10 then
if msgcontains(msg, GUILD1TYPE) then
selfSay('' .. GUILD1 .. ', are you sure? This decision is irreversible!')
talk_state = 11
end

elseif talk_state == 11 then
if msgcontains(msg, 'yes') then
cname = getPlayerName(cid)
selfSay('Congratulations ' .. cname .. ', you are now a member of the ' .. GUILD1 .. '!')
guildid1 = getGuildId(GUILD1)
doPlayerSetGuildId(cid, guildname)
doPlayerSetGuildRank(cid,1)
doPlayerSendTextMessage(cid,19,"You can now enter in your guild channel.")
end
end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

i can see oyu pirred some parts.. what are talkstate 10/11 good fore?
 
Last edited:
I saw Talaturen said that doPlayerSetGuildId(cid, guildname) wasn't added yet.
If you check that sticky, you will see that the part is commented out.
 
Back
Top