What's new

Skrypty!

Status
Not open for further replies.

Arts18

Signed...
Joined
May 7, 2009
Messages
2,888
Reaction score
231
Age
33
Witajcie!

Mamy do Was ogromn? pro?b?.Jestem dopiero pocz?tkuj?cym skrypterem, a dla mnie s? to do?? wa?ne skrypty.Nie musz? wymienia? do ko?ca jaki to jest pow?d abym Was prosi? o pomoc.Powiem wprost wszystko posz?o si? chrzani? przez m?j kochany system.Wracajac do tego prosi?bym was o par? skrypt?w :

- Skrypt na ?owienie Sea Serpent?w
- Skrypt na NPC od misjii - dok?adnie chodzi mi o taki schemat :

Player : Welcome!
NPC : Hello player [NAME] How can help you. I wanna..
Player : Where is castle of minotaur?
NPC : Castle is in north site.

Z g?ry dzi?kuj?,
Arts
 
T

Tairens

Guest
Odp: Skrypty!

Code:
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end

local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v)) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end

local items = {}
for _, item in ipairs(itemWindow) do
	items[item.id] = {buyPrice = item.buy, sellPrice = item.sell, subType = item.subType, realName = item.name}
end

local function getPlayerMoney(cid)
	return ((getPlayerItemCount(cid, 2160) * 10000) +
	(getPlayerItemCount(cid, 2152) * 100) +
	getPlayerItemCount(cid, 2148))
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
		if(isPlayer(cid)) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
end

function onCreatureSay(cid, type, msg)
local msg = string.lower(msg)
local newMsg = msg
	if((msg == "hi") and not (isFocused(cid))) then
		selfSay("Hello player ".. getCreatureName(cid) .." How can help you. I wanna...", cid, true)
		addFocus(cid)
	elseif((isFocused(cid)) and msg == "Where is castle of minotaur?") then
		selfSay("Castle is in north site.", cid)
	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
		selfSay("Goodbye!", cid, true)
		removeFocus(cid)
	end
end

function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		closeShopWindow(cid)
		removeFocus(cid)
	end
end


function onThink()
	for i, focus in pairs(focuses) do
		if(not isCreature(focus)) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Hmph!")
				closeShopWindow(focus)
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end

Tutaj masz npc, kt?rego mo?esz dowolnie edytowa? w ka?dy mo?liwy spos?b. Co do ?owienia napisz? Ci to wieczorem
 

Arts18

Signed...
Joined
May 7, 2009
Messages
2,888
Reaction score
231
Age
33
Odp: Skrypty!

----- Od?wie?am------
 

Maniucza

Advanced User
Joined
Jan 18, 2009
Messages
374
Reaction score
57
Odp: Skrypty!

Witam, Co do NPC to nie zrozumia?em ale wyglada to tak :
PHP:
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
	if msgcontains(msg, 'Where is castle of minotaur?') or msgcontains(msg, 'mino') then
		return selfSay('Castle is in north site.', cid)
	end
	
---------------------------------------------------------
	if(msgcontains(msg, 'minotaur leathers')) then
		selfSay('You have 50 minotaur leathers?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
	
	if(doPlayerRemoveItem(cid, XXXX, 50) == TRUE) then
		setPlayerStorageValue(cid, 11111, 1)
		selfSay('Thanks.', cid)
	else
		selfSay('You do not have 50 minotaur leathers.', cid)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

NPC :
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NAME" script="SKRYPT.lua" walkinterval="2000" floorchange="0">
	<health now="150" max="150"/>
	<look type="128" head="20" body="100" legs="50" feet="99" corpse="2212"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. How can help you. I wanna.. "/>
	</parameters>
</npc>

Gracz przychodzi do NPC pisze to co pisa?e?, je?li napisze "minotaur leathers" Zabiera mu 50 Mino i dostaje storage.

Co do pierwszego skrypty dam w edicie.

Pozdrawiam.

#Edit:
PHP:
local = cfg
{
    m = "Serpent Sea"
}

local p =
{
    summon =
    {
        {x = 100, y = 100, z = 7},
        {x = 100, y = 100, z = 7},
        {x = 100, y = 100, z = 7},
        {x = 100, y = 100, z = 7}
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local rand = [math.random(1, #p.summon)]
    if itemEx.itemid == XXXX then 
        doCreateMonster(cfg.m, p.summon[rand])
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        doPlayerSendCancel(cid, "Were you able to pick out Serpent Sea.")
    else
        return doPlayerSendCancel(cid, "Sorry, not possible.")
    end
    return true
end
 
Last edited:
Status
Not open for further replies.
Top