Jump to content
Masuka00

Help with SendExchangeData

Recommended Posts

hello i wanted to know how to add my own items

 

sshot-336.png

 

on npc scrip i found

 

    ExchangeData(    2608    ,    100    ,    2682    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2683    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2684    ,    1    ,    1)
    ExchangeData(    2608    ,    100    ,    2692    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2693    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2694    ,    1    ,    1)
    ExchangeData(    2608    ,    100    ,    2702    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2703    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2704    ,    1    ,    1)
    ExchangeData(    2608    ,    100    ,    2712    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2713    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2714    ,    1    ,    1)

 

and i saw in variable

 

ChangeItemList[ 248    ]=    {    855    ,    600    ,    803    ,    1    }

 

buti still donth understand and i got lost, can some one guide me please :D


☠️🏴‍☠️💀ǤØĐ βŁ€ŞŞ ƤƗŘΔĆ¥💀🏴‍☠️☠️

Share this post


Link to post
Share on other sites

Since the packet sent from client to server when you use the exchange npc contains the item ID, the ChangeItemList table is required as it contains all the valid exchanges and compares the IDs in the packet received to it.

 

You can edit ExchangeData function to contain something like:

 

table.insert(ChangeItemList,{srcID, srcNum, tarID, tarNum})

 

To automaticly make this table for you, then you can just use:

 

ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, Billy said:

Since the packet sent from client to server when you use the exchange npc contains the item ID, the ChangeItemList table is required as it contains all the valid exchanges and compares the IDs in the packet received to it.

 

You can edit ExchangeData function to contain something like:

 

table.insert(ChangeItemList,{srcID, srcNum, tarID, tarNum})

 

To automaticly make this table for you, then you can just use:

 

ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )

 

Could you write and example how will be added in an NPC and in the variable i still got lost

 


☠️🏴‍☠️💀ǤØĐ βŁ€ŞŞ ƤƗŘΔĆ¥💀🏴‍☠️☠️

Share this post


Link to post
Share on other sites
6 hours ago, Billy said:

Since the packet sent from client to server when you use the exchange npc contains the item ID, the ChangeItemList table is required as it contains all the valid exchanges and compares the IDs in the packet received to it.

 

You can edit ExchangeData function to contain something like:

 

table.insert(ChangeItemList,{srcID, srcNum, tarID, tarNum})

 

To automaticly make this table for you, then you can just use:

 

ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )

 

Can you explain a more?

 

Would this just be for automatically creating a table for ChangeItemList?

 

How would you implement that? With a new function or with an existing one?

 

Edited by Shako

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
13 hours ago, Covadola said:

hello i wanted to know how to add my own items

 

sshot-336.png

 

on npc scrip i found

 

    ExchangeData(    2608    ,    100    ,    2682    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2683    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2684    ,    1    ,    1)
    ExchangeData(    2608    ,    100    ,    2692    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2693    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2694    ,    1    ,    1)
    ExchangeData(    2608    ,    100    ,    2702    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2703    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2704    ,    1    ,    1)
    ExchangeData(    2608    ,    100    ,    2712    ,    1    ,    1)
    ExchangeData(    2609    ,    100    ,    2713    ,    1    ,    1)
    ExchangeData(    2609    ,    1000    ,    2714    ,    1    ,    1)

 

and i saw in variable

 

ChangeItemList[ 248    ]=    {    855    ,    600    ,    803    ,    1    }

 

buti still donth understand and i got lost, can some one guide me please :D

Check guide section> how to make a new npc, i explained a bit there 

Share this post


Link to post
Share on other sites

@Covadola

 

U have to add to NPC, and then add that exchange to ChangeItemList in variable.lua.


Warning: Long post below

Spoiler

 

@Billy's script addition made it so that you don't have to change ChangeItemList anymore, by adding the line 


table.insert( ChangeItemList , { srcID , srcNum , tarID , tarNum } )

into the function


function ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )
	if srcID == nil or srcNum == nil or tarID == nil or tarNum == nil or timeNum == nil then
		LG( "npcinit_error", "ExchangeData: Function parameter error!srcID, srcNum, tarID, tarNum, timeNum", srcID, srcNum, tarID, tarNum, timeNum )
		return
	end
	
	Exchange.count = Exchange.count + 1
	
	--兑换数据
	Exchange.srcid[Exchange.count] = srcID
	Exchange.srcnum[Exchange.count] = srcNum
	Exchange.tarid[Exchange.count] = tarID
	Exchange.tarnum[Exchange.count] = tarNum
	Exchange.timenum[Exchange.count] = timeNum
end

in ScriptSDK.lua

 

(like this)

 


function ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )
	if srcID == nil or srcNum == nil or tarID == nil or tarNum == nil or timeNum == nil then
		LG( "npcinit_error", "ExchangeData: Function parameter error!srcID, srcNum, tarID, tarNum, timeNum", srcID, srcNum, tarID, tarNum, timeNum )
		return
	end

	table.insert( ChangeItemList , { srcID , srcNum , tarID , tarNum } )

	Exchange.count = Exchange.count + 1
	
	--兑换数据
	Exchange.srcid[Exchange.count] = srcID
	Exchange.srcnum[Exchange.count] = srcNum
	Exchange.tarid[Exchange.count] = tarID
	Exchange.tarnum[Exchange.count] = tarNum
	Exchange.timenum[Exchange.count] = timeNum
end

in ScriptSDK.lua

 

Now, you can make your NPC, and put in 


    ExchangeData(    2608    ,    100    ,    2682    ,    1    ,    1)

or whatever you want. 

 

 

Now, for my explanation xD

 

If you wanted to make an exchange function with another character in the map already using the function, it will overlap and won't work.

 

So you have to make your own:

 

Search for: 


function ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )

function SendExchangeData( character, npc )

function InitExchange()

and make your own script, such as:


ExchangeData2
SendExchangeData2
InitExchange2

and then put into NpcSdk.lua


 function MsgProc

		elseif item.func == SendExchangeData2 then
		return SendExchangeData2( character, npc )

next to the original one.

 

Then, you will have 2 exchange NPCs in 1 map.

 

This can be a guide on it's own xD


 

 

  • Like 1

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
1 minute ago, Shako said:

@Covadola

 

U have to add to NPC, and then add that exchange to ChangeItemList in variable.lua.


Warning: Long post below

  Reveal hidden contents

 

@Billy's script addition made it so that you don't have to change ChangeItemList anymore, by adding the line 



table.insert( ChangeItemList , { srcID , srcNum , tarID , tarNum } )

into the function



function ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )
	if srcID == nil or srcNum == nil or tarID == nil or tarNum == nil or timeNum == nil then
		LG( "npcinit_error", "ExchangeData: Function parameter error!srcID, srcNum, tarID, tarNum, timeNum", srcID, srcNum, tarID, tarNum, timeNum )
		return
	end
	
	Exchange.count = Exchange.count + 1
	
	--兑换数据
	Exchange.srcid[Exchange.count] = srcID
	Exchange.srcnum[Exchange.count] = srcNum
	Exchange.tarid[Exchange.count] = tarID
	Exchange.tarnum[Exchange.count] = tarNum
	Exchange.timenum[Exchange.count] = timeNum
end

in ScriptSDK.lua

 

(like this)

 



function ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )
	if srcID == nil or srcNum == nil or tarID == nil or tarNum == nil or timeNum == nil then
		LG( "npcinit_error", "ExchangeData: Function parameter error!srcID, srcNum, tarID, tarNum, timeNum", srcID, srcNum, tarID, tarNum, timeNum )
		return
	end

	table.insert( ChangeItemList , { srcID , srcNum , tarID , tarNum } )

	Exchange.count = Exchange.count + 1
	
	--兑换数据
	Exchange.srcid[Exchange.count] = srcID
	Exchange.srcnum[Exchange.count] = srcNum
	Exchange.tarid[Exchange.count] = tarID
	Exchange.tarnum[Exchange.count] = tarNum
	Exchange.timenum[Exchange.count] = timeNum
end

in ScriptSDK.lua

 

Now, you can make your NPC, and put in 



    ExchangeData(    2608    ,    100    ,    2682    ,    1    ,    1)

or whatever you want. 

 

 

Now, for my explanation xD

 

If you wanted to make an exchange function with another character in the map already using the function, it will overlap and won't work.

 

So you have to make your own:

 

Search for: 



function ExchangeData( srcID, srcNum, tarID, tarNum, timeNum )

function SendExchangeData( character, npc )

function InitExchange()

and make your own script, such as:



ExchangeData2
SendExchangeData2
InitExchange2

and then put into NpcSdk.lua



 function MsgProc


		elseif item.func == SendExchangeData2 then
		return SendExchangeData2( character, npc )

next to the original one.

 

Then, you will have 2 exchange NPCs in 1 map.

 

This can be a guide on it's own xD

 

 

 

 

 

Now the question: Is there a better way to do this?

  • Like 1

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

Well @Shako i think i am gonna pass this one xD its complicated and donth take me wrong guys but i got 1 day no sleep and still not figure out :( i forgot this is 2016 not 2009 :P all you guys know alot and i am still with the basic stuff :) 


☠️🏴‍☠️💀ǤØĐ βŁ€ŞŞ ƤƗŘΔĆ¥💀🏴‍☠️☠️

Share this post


Link to post
Share on other sites

Okay ._. @Covadola

Edited by Shako

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
12 minutes ago, Covadola said:

Well @Shako i think i am gonna pass this one xD its complicated and donth take me wrong guys but i got 1 day no sleep and still not figure out :( i forgot this is 2016 not 2009 :P all you guys know alot and i am still with the basic stuff :) 

One day? It might seem basic, yet you don't know how to do it, so how is it basic? A lot of people with knowledge started the same, just because they didn't get answers on a forum didn't mean they gave up, they started looking how scripts worked and eventually worked them out or found a way around it. That didn't take one day, it might of took a week even to understand everything completely.

  • Like 1

Share this post


Link to post
Share on other sites
46 minutes ago, Angelix said:

One day? It might seem basic, yet you don't know how to do it, so how is it basic? A lot of people with knowledge started the same, just because they didn't get answers on a forum didn't mean they gave up, they started looking how scripts worked and eventually worked them out or found a way around it. That didn't take one day, it might of took a week even to understand everything completely.

 

Thanks @Angelix It was more difficult than I thought thanks to @Shako for helping me to solve this problem and @Billy for the table.insert, thank you guys :D

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


×
×
  • Create New...