Jump to content
  • 0

Adquire a BGM Id from the Name of the map


Fratini

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

Hi,
I would like to know if it's possible to get the
ID of the BGM with the Map Name in source codes. I know that it can be done by creating a table in MySql or with a huge Array variable with all the BGM from All Maps of the Server (more than 1,000 without the custom maps =/) but cost a lot of time.

 

Thank you for your time =)

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  326
  • Reputation:   47
  • Joined:  04/01/12
  • Last Seen:  

check the mp3nametable.txt on your client, it is located on your data folder/grf

Edited by frenzmu06
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

Yep, I know that. What I'm thinking is to get the ID of the BGM with a custom command created in 'src\map\script.c' (Creating a command in source. Something like getBGMid("Prontera").)

What I don't know is: How can I get the information from the player. Is it a packet information? Is there another way to access this information?

 

If not, I'll start create a table to catalog the IDs

Edited by Fratini
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

I dont think you can retrieve the BGM info from the client.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

I dont think you can retrieve the BGM info from the client.

Then, I'll start a table on MySQL =/

Thank you /no1  anyway !

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

Why not make a script command that parses your mp3nametable.txt?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

Why not make a script command that parses your mp3nametable.txt?

 

Nice! With your tip secret, I think I'm on the right track:

BUILDIN_FUNC(getbgmid){
	struct map_session_data* sd;
	FILE *bgm;
	const char* mcheck="";
	const char* m="";
	int id=0,r=0;
	char output[150];
	
	if(script_getstr(st,2))
		m = script_getstr(st,2);
	else{
		if(!sd){
			ShowDebug("getbgmid: No Player Attached");
			return SCRIPT_CMD_FAILURE;
		}
		m = map_mapid2mapname(sd->bl.m);
	}
	
	if(!(bgm=fopen("db/data/mp3nametable.txt", "r"))){
		ShowDebug("getbgmid: Can't find file 'mp3nametable.txt'");
		sprintf(output, "getbgmid: Can't find file 'mp3nametable.txt'");
		return SCRIPT_CMD_FAILURE;
	}
	
	while(fscanf(bgm,"%s.rsw#bgm\\%d.mp3#\n",mcheck,id)!=EOF && !r){
		if(m==mcheck)
			r=id;
	}
	
	if(r){
		script_pushint(st,id);
		return SCRIPT_CMD_SUCCESS;
	} else {
		sprintf(output, "Couldn't found the BGM ID from %s", m);
		return SCRIPT_CMD_FAILURE;
	}
	
}

I tried to made by writing the name of the Map that you want to know the ID or if you omit the script_getstr(st,2), the script will get the name of the map from the character.

But the map-server keeps crashing...

 

I think it's something about the 'fscanf'. I don't know much about C by the way.

 

PS: I add the BUILDIN_DEF =)

	BUILDIN_DEF(getbgmid,"?"),
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

Don't parse the file every time you call the script command. Parse it on startup and make the script command grab the name from (maybe) a DBMap.

Link to comment
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.   Paste as plain text instead

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