Jump to content
  • 0

Getcharid Fatal Error


pajodex

Question


  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

Hi,

Sorry I cant post the full script but I think the main problem is this part

if(getcharid(1))
		{
			party_delmember();
			sleep 1;
		}
		party_create md5(gettimetick(2)+"A");
		sleep 1;
		.PID[1] = getcharid(1);
		detachrid;
		attachrid .@teamA2[0];
		if(getcharid(1))
		{
			party_delmember();
			sleep 1;
		}
		party_create md5(gettimetick(2)+"B");
		sleep 1;
		.PID[2] = getcharid(1);
		detachrid;
		for(.@i = 1; .@i < .@num; .@i++)
		{
			attachrid .@teamA1[.@i];
			if(getcharid(1))
			{
				party_delmember();
				sleep 1;
			}
			party_addmember .PID[1],getcharid(0);
			detachrid;
			attachrid .@teamA2[.@i];
			if(getcharid(1))
			{
				party_delmember();
				sleep 1;
			}
			party_addmember .PID[2],getcharid(0);
			detachrid;
		}

I'm having this error in console:

[Error]: buildin_getcharid: fatal error ! player not attached!
[Debug]: Function: getcharid (1 parameter):
[Debug]: Data: number value=1
[Debug]: Source (NPC): MD at prontera (150,174)

 

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 1

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

Sleep detaches the player from the script. Just use sleep2 instead.

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

you need to attach the party members :)) something like this

 

.@party_id = getcharid(1);
getpartymember .@party_id,1;
getpartymember .@party_id,2;
	for( set .@i, 0; .@i < $@partymembercount; set .@i,.@i+1 ){
	if(isloggedin($@partymemberaid[.@i],$@partymembercid[.@i])){
	attachrid $@partymemberaid[.@i];
	//your stuffs here
	}
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

15 minutes ago, crazyarashi said:

you need to attach the party members :)) something like this

 


.@party_id = getcharid(1);
getpartymember .@party_id,1;
getpartymember .@party_id,2;
	for( set .@i, 0; .@i < $@partymembercount; set .@i,.@i+1 ){
	if(isloggedin($@partymemberaid[.@i],$@partymembercid[.@i])){
	attachrid $@partymemberaid[.@i];
	//your stuffs here
	}
}

 

That "Your stuffs here" part should my recent edit go? Or the unedited one? Sorry, I kinda learn things the hard way. 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

6 hours ago, Secrets said:

Sleep detaches the player from the script. Just use sleep2 instead.

I tried using sleep2 but it gives me error in console. something like "buildin_func_sleep2 bla bla cannot attach bla bla"

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

This is crazy but I've messed it up quite a bit.. /hehe 

Here is how I did it now

		@party_id = getcharid(1);
		getpartymember .@party_id,1;
		getpartymember .@party_id,2;
			for( set .@i, 0; .@i < $@partymembercount; set .@i,.@i+1 ){
			if(isloggedin($@partymemberaid[.@i],$@partymembercid[.@i])){
			attachrid $@partymemberaid[.@i];
			//your stuffs here
		if (attachrid(.@teamA1[0])) {
		//attachrid .@teamA1[0];
		if(getcharid(1))
		{
			party_delmember();
			sleep2 1;
		}
		party_create md5(gettimetick(2)+"A");
		sleep2 1;
		.PID[1] = getcharid(1);
		detachrid;
		} 
		if (attachrid(.@teamA2[0])) {
		//attachrid .@teamA2[0];
		if(getcharid(1))
		{
			party_delmember();
			sleep2 1;
		}
		party_create md5(gettimetick(2)+"B");
		sleep2 1;
		.PID[2] = getcharid(1);
		detachrid;
		}
		for(.@i = 1; .@i < .@num; .@i++)
		{
			if (attachrid(.@teamA1[.@i])) {
			//attachrid .@teamA1[.@i];
			if(getcharid(1))
			{
				party_delmember();
				sleep2 1;
			}
			party_addmember .PID[1],getcharid(0);
			detachrid;
			} 
			if (attachrid(.@teamA2[.@i])) {
			//attachrid .@teamA2[.@i];
			if(getcharid(1))
			{
				party_delmember();
				sleep2 1;
			}
			party_addmember .PID[2],getcharid(0);
			detachrid;
			}
		}
		end;
		// your stuff here
			}
		}

Still getting 

[Error]: buildin_getcharid: fatal error ! player not attached!
[Debug]: Function: getcharid (1 parameter):
[Debug]: Data: number value=1
[Debug]: Source (NPC): MD at prontera (150,174)

Sorry for really annoying rAthena x_x

Edited by pajodex
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

16 hours ago, pajodex said:

if (attachrid(.@teamA1[0])) {

    attachrid .@teamA1[0];

Hey, you don't need to attachrid twice it is already done in the IF statement.

 

16 hours ago, pajodex said:

for(.@i = 1; .@i < .@num; .@i++) {

    if (attachrid(.@teamA1[0])) {

        attachrid .@teamA1[.@i];

Same here and i think it go like this?

for(.@i = 1; .@i < .@num; .@i++) {
	if (attachrid(.@teamA1[.@i])) {
      // Your stuff here

Note to attachrid: "The command returns 0 if the player cannot be attached (if the account is offline or does not exist), and 1 upon success."

It's a good practice to do checks to avoid possible errors and help to find them.

// Check party create was successful
if (party_create(<party name>)) {
  // Success
}

// Check party delete member was successful
if (party_delmember()) {
  // Success
}

// Check party add member was successful
if (party_addmember(<party id>,<character id>)) {
  // Success
}

 

Edited by Sehrentos
Fix typo
Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

Hey,

Have you tried to add in some checks like if player is offline before accessing hes RID status?

1 hour ago, pajodex said:

attachrid .@teamA2[0];

if (attachrid(.@teamA2[0])) {
	// Success
}
Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

Doesn't this part check if he's offline?

attachrid .@teamA2[.@i];

 

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

1 minute ago, pajodex said:

Doesn't this part check if he's offline?

No, that is the part where it tries to attach the member into your script. It can fail if you dont check if attach was successful.

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

Sorry, I'm just new to this complex scripting (at least for me) but where do I put that?

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   22
  • Joined:  10/24/14
  • Last Seen:  

2 minutes ago, pajodex said:

Sorry, I'm just new to this complex scripting (at least for me) but where do I put that?

Hi, add the above check i posted before to every "attachrid" command :)

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  431
  • Reputation:   164
  • Joined:  12/12/17
  • Last Seen:  

1 hour ago, Sehrentos said:

Hi, add the above check i posted before to every "attachrid" command :)

I dunno if I'm doing it right. This is how I did it:

if (attachrid(.@teamA1[0])) {
		attachrid .@teamA1[0];
		if(getcharid(1))
		{
			party_delmember();
			sleep 1;
		}
		party_create md5(gettimetick(2)+"A");
		sleep 1;
		.PID[1] = getcharid(1);
		detachrid;
		}
		if (attachrid(.@teamA2[0])) {
		attachrid .@teamA2[0];
		if(getcharid(1))
		{
			party_delmember();
			sleep 1;
		}
		party_create md5(gettimetick(2)+"B");
		sleep 1;
		.PID[2] = getcharid(1);
		detachrid;
		}
		for(.@i = 1; .@i < .@num; .@i++)
		{
			if (attachrid(.@teamA1[0])) {
			attachrid .@teamA1[.@i];
			if(getcharid(1))
			{
				party_delmember();
				sleep 1;
			}
			party_addmember .PID[1],getcharid(0);
			detachrid;
			}
			if (attachrid(.@teamA2[0])) {
			attachrid .@teamA2[.@i];
			if(getcharid(1))
			{
				party_delmember();
				sleep 1;
			}
			party_addmember .PID[2],getcharid(0);
			detachrid;
			}

but I'm getting this in console:

[Error]: script:run_script_main: infinity loop !
[Debug]: Source (NPC): Mushroom Defense at prontera (150,174)

Sorry for bugging you

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