Jump to content
  • 0

Getcharid Fatal Error


Question

Posted

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)

 

12 answers to this question

Recommended Posts

  • 0
Posted

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

 

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

  • 0
Posted
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"

  • 0
Posted (edited)

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
  • 0
Posted (edited)
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
  • -1
Posted

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
}
  • -1
Posted
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.

  • -1
Posted
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 :)

  • -1
Posted
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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...