Jump to content
  • 0
AnnieRuru

how to declare a new PLAYER source variable in a plugin file

Question

ok I'm converting this script into patch and plugin
http://herc.ws/board/topic/4421-bst-stand-for-buy-sell-and-trade/?p=29021

patch
http://upaste.me/349b75
into plugin
http://upaste.me/823b70

noticed that in the patch file, I declare a new source variable 'bst_delay' inside map_session_data
so it should be fast to just retrieve the value 'sd->bst_delay' in the source, without using Sql or script type variable

but in the plugin, I currently have no known way to declare a new struct that points to map_session_data
because I'm using pc_setreg which is a script type variable, bad method ...
just like Brainstorm once told me, using a cannon to pick a lock

is there any way to make a plugin declare a new variable from another struct ? like pc.h or itemdb.h

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

sample.c

struct sample_data_struct {	struct point lastMSGPosition;	unsigned int someNumber;};void sample_packet0f3(int fd) {	struct map_session_data *sd = session[fd]->session_data;	struct sample_data_struct *data;		if( !sd ) return;/* socket didn't fully log-in? this packet shouldn't do anything then! */		ShowInfo("sample_packet0f3: Hello World! received 0xf3 for '%s', redirecting!n",sd->status.name);		/* sample usage of appending data to a map_session_data (sd) entry */	if( !(data = getFromMSD(sd,0)) ) {		CREATE(data,struct sample_data_struct,1);				data->lastMSGPosition.map = sd->status.last_point.map;		data->lastMSGPosition.x = sd->status.last_point.x;		data->lastMSGPosition.y = sd->status.last_point.y;		data->someNumber = rand()%777;				ShowInfo("Created Appended map_session_data data, %d %d %d %dn",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber);		addToMSD(sd,data,0,true);	} else {		ShowInfo("Existent Appended map_session_data data, %d %d %d %dn",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber);		if( rand()%4 == 2 ) {			ShowInfo("Removing Appended map_session_data datan");			removeFromMSD(sd,0);		}	}		clif->pGlobalMessage(fd,sd);}

I use that getfromMSD Method, and saves the data into sql at regular intervals..

Share this post


Link to post
Share on other sites
  • 0

got it

http://upaste.me/3700f1

 

I got help from this topic too

http://rathena.org/board/topic/89230-can-any-one-convert-this-for-use-with-rathena-version-17690-or-diff-please/

 

 


.

.

.

but why only these few ?

 

/* HPData handy redirects *//* session[] */#define addToSession(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_SESSION,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromSession(ptr,index) (HPMi->getFromHPData(HPDT_SESSION,HPMi->pid,(ptr),(index)))#define removeFromSession(ptr,index) (HPMi->removeFromHPData(HPDT_SESSION,HPMi->pid,(ptr),(index)))/* map_session_data */#define addToMSD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_MSD,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromMSD(ptr,index) (HPMi->getFromHPData(HPDT_MSD,HPMi->pid,(ptr),(index)))#define removeFromMSD(ptr,index) (HPMi->removeFromHPData(HPDT_MSD,HPMi->pid,(ptr),(index)))/* npc_data */#define addToNPCD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_NPCD,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromNPCD(ptr,index) (HPMi->getFromHPData(HPDT_NPCD,HPMi->pid,(ptr),(index)))#define removeFromNPCD(ptr,index) (HPMi->removeFromHPData(HPDT_NPCD,HPMi->pid,(ptr),(index)))/* map_data */#define addToMAPD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_MAP,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromMAPD(ptr,index) (HPMi->getFromHPData(HPDT_MAP,HPMi->pid,(ptr),(index)))#define removeFromMAPD(ptr,index) (HPMi->removeFromHPData(HPDT_MAP,HPMi->pid,(ptr),(index)))/* party_data */#define addToPAD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_PARTY,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromPAD(ptr,index) (HPMi->getFromHPData(HPDT_PARTY,HPMi->pid,(ptr),(index)))#define removeFromPAD(ptr,index) (HPMi->removeFromHPData(HPDT_PARTY,HPMi->pid,(ptr),(index)))/* guild */#define addToGLD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_GUILD,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromGLD(ptr,index) (HPMi->getFromHPData(HPDT_GUILD,HPMi->pid,(ptr),(index)))#define removeFromGLD(ptr,index) (HPMi->removeFromHPData(HPDT_GUILD,HPMi->pid,(ptr),(index)))/* instance_data */#define addToINSTD(ptr,data,index,autofree) (HPMi->addToHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(data),(index),(autofree)))#define getFromINSTD(ptr,index) (HPMi->getFromHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(index)))#define removeFromINSTD(ptr,index) (HPMi->removeFromHPData(HPDT_INSTANCE,HPMi->pid,(ptr),(index)))
where is item_data and mob_data ?

gonna suggest them

Edited by AnnieRuru

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
Answer this question...

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

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.