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

Kolejne pytanie odnośnie doPlayerAddItem

Lares

Member
Joined
Feb 8, 2010
Messages
315
Reaction score
7
kontynuacja problemu z http://otland.net/f28/problem-z-doplayeradditem-109449/

Czy dało by się zrobić aby ta funkcja działała tak jak dawniej czyli dodawała item w wolne miejsce rękę bp czy miejsce na strzały i jeszcze jedno pytanie jak powinien prawidłowo wyglądać ten skrypt aby dawało item na szyje a jak nie to do bp lub do ręki?

Lua:
function onSay(cid, words, param)
if doPlayerRemoveMoney(cid, 10000) then
doPlayerAddItem(cid, 2173, 1)
doPlayerSendTextMessage(cid, 19,"Kupiles aol, kosztowalo cie to 1cc.")
doSendMagicEffect(getPlayerPosition(cid), 19)
else
doPlayerSendCancel(cid, "Sorry, Nie masz tyle kasy. aol kosztuje 1cc.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
end
end
 
Plus minus.
Lua:
if not getPlayerSlotItem(cid, CONST_SLOT_NECKLACE) then
    doPlayerAddItem(cid, itemid, count = 1, canDropOnMap = true, subtype = 1, CONST_SLOT_NECKLACE) -- ustaw sobie paramy jak tam chcesz
else
    doPlayerAddItem(cid, itemid, count) -- powinno dac w pierwszy wolny slot (?)
end
Pomyśl.
 
Dzięki ale chodziło mi o coś bardziej globalnego bo jeśli bym chciał zrobić tak jak było musiał bym przerobić wszystkie skrypty z funkcją doPlayerAddItem

doPlayerAddItem(cid, itemid, count) -- powinno dac w pierwszy wolny slot (?)

No właśnie nie powinno bo daje albo do bp albo pod nogi...
 
Zaczalem pisac funkcje (zapewne da sie inaczej, a ja niepotrzebnie pisze cos xd):
Code:
local oldFunc = doPlayerAddItem
local slots = {SLOT_FIRST, SLOT_HEAD, SLOT_kurwamac}
doPlayerAddItem = function(cid, id, count, canDropOnMap, subType, slot)
	count = count or 1
	canDropOnMap = canDropOnMap or true
	subtype = subType or 1
	slot = slot or 0

	for _, tmp in ipairs(slots) do
		if(getPlayerSlotItem(cid, tmp).uid < 0) then
			oldFunc(cid, id, count, canDropOnMap, subType, tmp)
			return
		end
	end

	oldFunc(cid, id, count, canDropOnMap, subType, slot)
end

Ale musze spadac, wiec sobie dokoncz xD
 
A co tu należy dodać poza slotami bo nigdy nie robiłem funkcji ale widzę że ma to za zadanie nadawać domyślne parametry jeśli takowe nie zostaną podane w skrypcie. Jednak mówię że nie wiem czego brakuje.

Lua:
local oldFunc = doPlayerAddItem
local slots = {SLOT_HEAD, SLOT_NECKLACE, SLOT_BACKPACK, SLOT_ARMOR, SLOT_RIGHT, SLOT_LEFT, SLOT_LEGS, SLOT_FEET, SLOT_RING, SLOT_AMMO}
doPlayerAddItem = function(cid, id, count, canDropOnMap, subType, slot)
	count = count or 1
	canDropOnMap = canDropOnMap or true
	subtype = subType or 1
	slot = slot or 0

	for _, tmp in ipairs(slots) do
		if(getPlayerSlotItem(cid, tmp).uid < 0) then
			oldFunc(cid, id, count, canDropOnMap, subType, tmp)
			return true
		end
	end

	oldFunc(cid, id, count, canDropOnMap, subType, slot)
end
 
Back
Top