Jump to content
  • 0

Command '@question' problem/doubt


Echoes

Question


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

Hello :D!

 

Yesterday I was testing a command that was requested by the user 'Fresh prince', called @question, and I'm using the script similar to Capuche's one.

But, when I tested it with my "normal" account (level 0, a normal player), it doesn't create the Chat Room, just teleports me and sits me.

 

This are the scripts (an exact copy of the script owned (or given by) by Capuche , since I don't find mines D:!)

-	script	atcmd_example	-1,{
OnInit:
	bindatcmd "question",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	warp "prontera",150,150;
	createchatroom( getcharid(3), "Question", "",5 );
	sit;
	end;
}

And its .src modification at script.inc

// createchatroom( <char|account|name>, <title>, <password>, {<limit>, <type>} );
// password : only enabled for type 0
// limit[ 1,20 ], 1 by default
// type : 1 -> public, 0 -> private

BUILDIN_FUNC(createchatroom)
{
	int len = strlen( script_getstr(st,3) );
	int limit = 1;
	char title[ CHATROOM_TITLE_SIZE ];
	char password[ CHATROOM_PASS_SIZE ];
	bool type = 1;// chat public by default
	TBL_PC *sd = NULL;

	if ( script_isstring(st,2) )
		sd = map_nick2sd( script_getstr(st,2) );
	else {
		int id = script_getnum(st,2);
		sd = map_charid2sd(id) ? map_charid2sd(id) : map_id2sd(id);
	}
	if ( sd == NULL ) {
		ShowWarning( "createchatroom : none player attached.\n" );
		return 0;
	}
	if ( (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM) || (battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 4 ) || npc_isnear(&sd->bl) ) return 0;
	if ( len > CHATROOM_TITLE_SIZE || strlen( script_getstr(st,4) ) > CHATROOM_PASS_SIZE ) return 0;
	if ( sd->chatID != 0 ) return 0;

	safestrncpy( title, script_getstr(st,3), min( len+1,CHATROOM_TITLE_SIZE ) );
	safestrncpy( password, script_getstr(st,4), CHATROOM_PASS_SIZE );

	if ( script_hasdata(st,5) ) {
		int tmp = script_getnum(st,5);
		if ( tmp > limit && tmp <= 20 ) limit = tmp;
		else if ( tmp > 20 ) limit = 20;
	}
	if ( script_hasdata(st,6) && script_getnum(st,6) == 0 ) type = 0;

	chat_createpcchat( sd, title, password, limit, type );
	chat_changechatstatus( sd, title, password, limit, type );
	return 0;
}

And script_def.inc

BUILDIN_DEF(createchatroom,"vss??"),

As I said before, it works with any GM account (level 99 tested at least), but when used in level 0 accounts, it does not create the pub when teleported.

 

Where is the possible error or what is the problem here?

 

Thanks C:

Link to comment
Share on other sites

14 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

You're welcome!

I forgot, the source doesn't create a chat if the player doesn't have basic skill lvl 4 too, is near a npc or is mute

  • Upvote 1
Link to comment
Share on other sites

  • 1

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

there is a little bug when loading from another map, it could be your issue

ie you see

-- warp

-- loading (create the chat when loading, don't display the chat)

-- sit

maybe add a sleep2 after the warp

warp "prontera",150,150;
sleep2 2000;
createchatroom( getcharid(3), "Question", "",5 );
  • Upvote 1
Link to comment
Share on other sites

  • 1

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

@Yonko

createchatroom works as the following

// createchatroom( <char|account|name>, <title>, <password>, {<limit>, <type>} );

the title is the 2nd parameter

-	script	atcmd_example	-1,{
OnInit:
	bindatcmd "question",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	warp "prontera",150,150;
	if ( .@atcmd_numparameters == 0 )
		.@atcmd_parameters$[0] = "Question";// default value
	createchatroom( getcharid(3), .@atcmd_parameters$[0], "",5 );
	sit;
	end;
}
  • Upvote 2
Link to comment
Share on other sites

  • 1

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

As https://github.com/rathena/rathena/commit/88aaa9be98c4e9f8494a2012cb3b7700d3b844f5 map_nick2sd need a second parameter to accept (true) or not (false) partial name.

sd = map_nick2sd( script_getstr(st,2),false );

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  59
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

 

On 9/26/2014 at 3:42 AM, Echoes said:

// createchatroom( <char|account|name>, <title>, <password>, {<limit>, <type>} );
// password : only enabled for type 0
// limit[ 1,20 ], 1 by default
// type : 1 -> public, 0 -> private

BUILDIN_FUNC(createchatroom)
{
	int len = strlen( script_getstr(st,3) );
	int limit = 1;
	char title[ CHATROOM_TITLE_SIZE ];
	char password[ CHATROOM_PASS_SIZE ];
	bool type = 1;// chat public by default
	TBL_PC *sd = NULL;

	if ( script_isstring(st,2) )
		sd = map_nick2sd( script_getstr(st,2) );
	else {
		int id = script_getnum(st,2);
		sd = map_charid2sd(id) ? map_charid2sd(id) : map_id2sd(id);
	}
	if ( sd == NULL ) {
		ShowWarning( "createchatroom : none player attached.\n" );
		return 0;
	}
	if ( (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM) || (battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 4 ) || npc_isnear(&sd->bl) ) return 0;
	if ( len > CHATROOM_TITLE_SIZE || strlen( script_getstr(st,4) ) > CHATROOM_PASS_SIZE ) return 0;
	if ( sd->chatID != 0 ) return 0;

	safestrncpy( title, script_getstr(st,3), min( len+1,CHATROOM_TITLE_SIZE ) );
	safestrncpy( password, script_getstr(st,4), CHATROOM_PASS_SIZE );

	if ( script_hasdata(st,5) ) {
		int tmp = script_getnum(st,5);
		if ( tmp > limit && tmp <= 20 ) limit = tmp;
		else if ( tmp > 20 ) limit = 20;
	}
	if ( script_hasdata(st,6) && script_getnum(st,6) == 0 ) type = 0;

	chat_createpcchat( sd, title, password, limit, type );
	chat_changechatstatus( sd, title, password, limit, type );
	return 0;
}

i use this but i got error im using rathena Lates Rev.  i got error on this sd = map_nick2sd( script_getstr(st,2) );

 

Edited by Kuneho
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  59
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

On 11/9/2013 at 3:34 AM, Capuche said:

-	script	atcmd_example	-1,{
OnInit:
	bindatcmd "question",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	warp "prontera",150,150;
	createchatroom( getcharid(3), "Question", "",5 );
	sit;
	end;
}

 

 

Add in src/custom/script.inc


// createchatroom( <char|account|name>, <title>, <password>, {<limit>, <type>} );
// password : only enabled for type 0
// limit[ 1,20 ], 1 by default
// type : 1 -> public, 0 -> private

BUILDIN_FUNC(createchatroom)
{
	int len = strlen( script_getstr(st,3) );
	int limit = 1;
	char title[ CHATROOM_TITLE_SIZE ];
	char password[ CHATROOM_PASS_SIZE ];
	bool type = 1;// chat public by default
	TBL_PC *sd = NULL;

	if ( script_isstring(st,2) )
		sd = map_nick2sd( script_getstr(st,2) );
	else {
		int id = script_getnum(st,2);
		sd = map_charid2sd(id) ? map_charid2sd(id) : map_id2sd(id);
	}
	if ( sd == NULL ) {
		ShowWarning( "createchatroom : none player attached.\n" );
		return 0;
	}
	if ( (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM) || (battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 4 ) || npc_isnear(&sd->bl) ) return 0;
	if ( len > CHATROOM_TITLE_SIZE || strlen( script_getstr(st,4) ) > CHATROOM_PASS_SIZE ) return 0;
	if ( sd->chatID != 0 ) return 0;

	safestrncpy( title, script_getstr(st,3), min( len+1,CHATROOM_TITLE_SIZE ) );
	safestrncpy( password, script_getstr(st,4), CHATROOM_PASS_SIZE );

	if ( script_hasdata(st,5) ) {
		int tmp = script_getnum(st,5);
		if ( tmp > limit && tmp <= 20 ) limit = tmp;
		else if ( tmp > 20 ) limit = 20;
	}
	if ( script_hasdata(st,6) && script_getnum(st,6) == 0 ) type = 0;

	chat_createpcchat( sd, title, password, limit, type );
	chat_changechatstatus( sd, title, password, limit, type );
	return 0;
}

 

and in src/custom/script_def.inc


BUILDIN_DEF(createchatroom,"vss??"),

then recompile

	if ( script_isstring(st,2) )
		sd = map_nick2sd( script_getstr(st,2) ); i got error on this one when i recompile
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  59
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

thank you fixed !!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  59
  • Reputation:   2
  • Joined:  08/01/12
  • Last Seen:  

6 hours ago, Capuche said:

As https://github.com/rathena/rathena/commit/88aaa9be98c4e9f8494a2012cb3b7700d3b844f5 map_nick2sd need a second parameter to accept (true) or not (false) partial name.


sd = map_nick2sd( script_getstr(st,2),false );

 

Question when player using @question command with out words or anything they can warp them self like just using @warp how to fix it no words no warp @Emistry @Capuche??? help me pls thanks!!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

First of all Capuche, thank you for responding C: Glad of being supported by the person who actually created the script.

 

 

there is a little bug when loading from another map, it could be your issue

 

 

Now, I tried when teleporting as a GM and that worked, but as a normal player doesn't, even being in the same map, still doesn't work :C

 

I will test your suggestion anyways.

 

Again, thank you C:

Edited by Echoes
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

You're welcome!

I forgot, the source doesn't create a chat if the player doesn't have basic skill lvl 4 too, is near a npc or is mute

Yep! Tested under that condition too, but also don't worked (in that time), now I will proceed with the test.. finally.

 

C:

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.04
  • Content Count:  789
  • Reputation:   50
  • Joined:  04/16/12
  • Last Seen:  

Hey Capuche i'm using this too but it has a problem the script works fine but when I type "@question Who drops jellopy?" the player will warp and make a chatroom name "Question" only how to modify like I type  "@question Who drops jellopy?" the name of Chatroom will be "Who drops jellopy?"

Link to comment
Share on other sites


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

Hey Capuche i'm using this too but it has a problem the script works fine but when I type "@question Who drops jellopy?" the player will warp and make a chatroom name "Question" only how to modify like I type  "@question Who drops jellopy?" the name of Chatroom will be "Who drops jellopy?"

try

if ( .@atcmd_numparameters == 0 )
		.@atcmd_parameters$[0] = "Question";// default value
else
	.@atcmd_parameters$[0] = implode( .@atcmd_parameters$," " );
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  166
  • Topics Per Day:  0.04
  • Content Count:  789
  • Reputation:   50
  • Joined:  04/16/12
  • Last Seen:  

 

Hey Capuche i'm using this too but it has a problem the script works fine but when I type "@question Who drops jellopy?" the player will warp and make a chatroom name "Question" only how to modify like I type  "@question Who drops jellopy?" the name of Chatroom will be "Who drops jellopy?"

try

if ( .@atcmd_numparameters == 0 )
		.@atcmd_parameters$[0] = "Question";// default value
else
	.@atcmd_parameters$[0] = implode( .@atcmd_parameters$," " );

Thanks It works like a charm =)

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  155
  • Reputation:   5
  • Joined:  03/30/13
  • Last Seen:  

Thank you Capuche and Emistry, now definitely I will test the script.

Had hard times arround here but now I'm better.

 

 

Going to test :D!

 

 

EDIT

 

Done! :D! thank you Capuche, Emistry!

Edited by Echoes
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...