Jump to content
Sign in to follow this  
Phoenix

NPC check pet Lv

Recommended Posts

untested and not sure if every step is correct, but as a starting hint will be really good.

 

Inside functions.lua add

function CheckPetLv (role)
		local Pet_Slot = GetChaItem ( role , 2 , 1  )
		local Pet_ID = GetItemID ( Pet_Slot )
		local item_type = GetItemType ( Pet_Slot )
        local str = GetItemAttr( Pet_Slot ,ITEMATTR_VAL_STR )  
        local con = GetItemAttr( Pet_Slot ,ITEMATTR_VAL_CON ) 
        local agi = GetItemAttr( Pet_Slot ,ITEMATTR_VAL_AGI )
        local dex = GetItemAttr( Pet_Slot ,ITEMATTR_VAL_DEX )
        local sta = GetItemAttr( Pet_Slot ,ITEMATTR_VAL_STA ) 
		local Lv = str + agi + dex + con + sta		
		if item_type == 59 then
			return Lv
		else
			return 0
		end
end
function GiveIfHasPet(role)
	local petLv = CheckPetLv (role)
	local done = HasRecord( role, RecordID)
		if petLv ~= 0 then
			if done == 0 then
			GiveItem( role, 0, ItemID, Qt, Ql )
			SetRecord( role, RecordID)
			else
			SystemNotice(role, 0. "You took your prize already")
			end
		else
			SystemNotice(role, 0, "You don't have a fairy on the Pet Slot")
		end
end

and edit: petLv condition (set "if petLv  ~= 0 then" to "if petLv < 40 then", in case you set the condition to have a lv 41 or higher pet)

edit ItemID to the item you're willing to give players, Qt to its quantity, Ql to its quality, RecordID to an unused record (just to avoid players re-take the items more than once)

 

then go to npcsdk and under 

		if item.func == JumpPage then
			return JumpPage( character, npc, page, item.p1 )

add

		elseif item.func == GiveIfHasPet then
			return GiveIfHasPet( character)

and now you can use the following line on a npc script

 

		Text(1, "Redeem your item", GiveIfHasPet)

 

Edited by iZae
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...