• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Problem, help :)

Verdis

Ciekawy świata.
Joined
May 28, 2012
Messages
394
Reaction score
9
Location
Poland
Mój npc:
PHP:
-- ## EVENT NPC -- 
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
local pos = {x=1003,y =1000,z=4} 
local storage = getPlayerStorageValue(cid, 2000)
 if msgcontains(msg, 'event') then
           npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?', cid)
            talk_state = 2
        elseif msgcontains(msg, 'tak') and talk_state == 2 then
		  if getPlayerStorageValue(cid,2000) == -1 then
				if doPlayerRemoveItem(cid,8614,40) then
                npcHandler:say('Zostales przeniesiony na event!', cid)
				doTeleportThing(cid,pos) 
				doSendMagicEffect(pos,CONST_ME_TELEPORT)
                talk_state = 0
				setPlayerStorageValue(cid,2000,1)
				end
            else
                npcHandler:say('Dzis juz tu nie wejdziesz!', cid)
                talk_state = 0
            end
			
			
        elseif msgcontains(msg, 'nie') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid)
            talk_state = 0
        end

    return true
end


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

Mój globalevent, który resetuje storage:
PHP:
function onStartup()
	db.executeQuery("DELETE FROM `player_storage` WHERE `key` = 2000;")
	return true
end

To nie działa dlaczego ?
Chodzi o to, że pojawia się npc, który wpuszcza graczy na event, ale można wejść tylko raz, ponowne wejście po zrestartowaniu silnika..
Gdy ustawiłem to na globalstorage to działało ale tylko jeden gracz może wejść na cały server, a na player storagę nie działa ;/
Proszę o pomoc, wskazanie błędu :)
 
masz:

LUA:
-- ## EVENT NPC --  
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid  
local pos = {x=1003,y =1000,z=4}  
local storage = getPlayerStorageValue(cid, 2000) 		
if msgcontains(msg, 'event') then 
			npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?', cid) 
			talk_state = 2 
        elseif msgcontains(msg, 'tak') and talk_state == 2 then 
			if getPlayerStorageValue(cid, 2000) < 1 then 
                if getPlayerItemCount(cid, 8614) >= 30 then 
					doPlayerRemoveItem(cid, 8614,40)
					setPlayerStorageValue(cid, 2000,1) 
					doTeleportThing(cid,pos)  
					doSendMagicEffect(pos,CONST_ME_TELEPORT) 
					npcHandler:say('Zostales przeniesiony na event!', cid) 
					talk_state = 0 
				else
					npcHandler:say('Nie masz wymaganej liczby itemow!', cid) 
					talk_state = 0 
                end
            else 
				npcHandler:say('Dzis juz tu nie wejdziesz!', cid) 
				talk_state = 0 
            end 
             
        elseif msgcontains(msg, 'nie') and (talk_state >= 1 and talk_state <= 3) then 
            npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid) 
            talk_state = 0 
        end 
		
	return true 
end 


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
 
Dziękuję, za pomoc..... :)
Da się to tego dodać funkcję, np gracz pisze "item" i gdy ma więcej cc niż 100, daje mu item.... oprócz tego, że przeniesie :)
Myślę nad:
PHP:
elseif msgcontains(msg, 'item') and talk_state == 2 then 
if getPlayerStorageValue(cid, 3000) < 1 then 
 if getPlayerItemCount(cid, 8614) >= 30 then 
doPlayerAddItem(cid, ID,LICZBA)
npcHandler:say('Otrzymales przedmiot.', cid) 
talk_state = 0 
else
npcHandler:say('Posiadaz juz ten item!', cid) 
talk_state = 0 
end
end
end

- - - Updated - - -

Dobra jakoś zrobiłem:
PHP:
-- ## EVENT NPC --  
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid  
local pos = {x=1003,y =1000,z=4}  
local storage = getPlayerStorageValue(cid, 2000) 		
if msgcontains(msg, 'event') then 
			npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?', cid) 
			talk_state = 2 
        elseif msgcontains(msg, 'tak') and talk_state == 2 then 
			if getPlayerStorageValue(cid, 2000) < 1 then 
                if getPlayerItemCount(cid, 8614) >= 30 then 
					doPlayerRemoveItem(cid, 8614,40)
					setPlayerStorageValue(cid, 2000,1) 
					doTeleportThing(cid,pos)  
					doSendMagicEffect(pos,CONST_ME_TELEPORT) 
					npcHandler:say('Zostales przeniesiony na event!', cid) 
					talk_state = 0 
				else
					npcHandler:say('Nie masz wymaganej liczby itemow!', cid) 
					talk_state = 0 
                end
            else 
				npcHandler:say('Dzis juz tu nie wejdziesz!', cid) 
				talk_state = 0 
            end 
 
        elseif msgcontains(msg, 'nie') and (talk_state >= 1 and talk_state <= 3) then 
            npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid) 
            talk_state = 0 
        end 
		 local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
		
		  
        if msgcontains(msg, 'item') then
                local price = 1000
			if getPlayerStorageValue(cid, 3000) < 1 then 
               if getPlayerItemCount(cid, 2160) >= 100 and getPlayerMoney(cid) >= price then
                        if doPlayerRemoveMoney(cid, price) then
                                selfSay('Otrzymales item!', cid)
                                doPlayerRemoveItem(cid, 2160, 100)
                                doPlayerAddItem(cid, 8293, 1)
								setPlayerStorageValue(cid, 3000,1) 
                                talkState[talkUser] = 0
                        end
                else
                        selfSay('Potrzebujesz 1kk aby kupic item!', cid)
                        talkState[talkUser] = 0
                end
			else 
				npcHandler:say('Juz nie kupisz tego itemu!', cid) 
				talk_state = 0 
            end 
			end
 
	return true 
end
Proszę tylko o poprawienie małych błędów, ale ścrypt i tak działa
 
Back
Top