• 0
Sign in to follow this  
Radian

Check Partymembers status

Question

I got this code, and trying to do it by my self.

			getpartymember getcharid(1),0;
			setarray .@name$[0], [email protected]$[0];
				for ( .@i = 0; .@i < getarraysize(.@name$[0]); ++.@i )
				dispbottom "Your current members are " + .@name$[.@i];
					.@state = checkvending(.@name$[.@i]);
						if ( .@state&1 )
							mes "Someone is currently vending.";
						if ( .@state&4 )
							mes "Someone is currently in buying store.";
						if ( .@state&2 )
							mes "Someone is currently in autotrading.";
						end;

map error is this 

[Error]: buildin_checkvending: Player with nick '' is not found.

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1

i think you already got the answer in discord, however this is the answer if someone wanted it

    getpartymember getcharid(1),0,.@name$[0];
    getpartymember getcharid(1),1,.@charid[0];
    getpartymember getcharid(1),2,.@accid[0];
    for(.@i=0;.@i<getarraysize(.@name$[0]);.@i++){
        if(isloggedin(.@accid[.@i],.@charid[.@i])){
            if(.@state = checkvending(.@name$[.@i])){
                if (.@state&1)
                    mes .@name$[.@i] + " is currently vending!";
                if (.@state&4)
                    mes .@name$[.@i] + " has a buying store!";
                if (.@state&2)
                    mes .@name$[.@i] + " is autotrading!";
                .@someone_vinding = true;
            }
        }
    }
    if(.@someone_vinding) end;

 

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Radian said:

I got this code, and trying to do it by my self.

			getpartymember getcharid(1),0;
			setarray .@name$[0], [email protected]$[0];
				for ( .@i = 0; .@i < getarraysize(.@name$[0]); ++.@i )
				dispbottom "Your current members are " + .@name$[.@i];
					.@state = checkvending(.@name$[.@i]);
						if ( .@state&1 )
							mes "Someone is currently vending.";
						if ( .@state&4 )
							mes "Someone is currently in buying store.";
						if ( .@state&2 )
							mes "Someone is currently in autotrading.";
						end;

map error is this 

[Error]: buildin_checkvending: Player with nick '' is not found.

 

Have 2 problems in your function.

First:

Spoiler


setarray .@name$[0], [email protected]$[0];

You're just setting the first value of '[email protected]$' array, if you want all values.

You need to use:

copyarray <destination array>[<first value>],<source array>[<first value>],<amount of data to copy>;

Example:


 

Second:

Spoiler
				for ( .@i = 0; .@i < getarraysize(.@name$[0]); ++.@i )
				dispbottom "Your current members are " + .@name$[.@i];
					.@state = checkvending(.@name$[.@i]);

You forgot to put the 'for' brackets '{}' and when you 'for' loop ends, the script command 'checkvending' is receiving a empty variable.

This is why you receive this error message.

You need to this:

				for ( [email protected] = 0; [email protected] < getarraysize([email protected]$); [email protected] )
				{
					dispbottom "Your current members are " + [email protected]$[[email protected]];

					[email protected] = checkvending([email protected]$[[email protected]]);

						if ( [email protected]&1 )
							mes "Someone is currently vending.";
						if ( [email protected]&4 )
							mes "Someone is currently in buying store.";
						if ( [email protected]&2 )
							mes "Someone is currently in autotrading.";
				}

Complete function:

				getpartymember getcharid(1), 0;
				copyarray [email protected]$[0], [email protected]$[0], [email protected];

				for ( [email protected] = 0; [email protected] < getarraysize([email protected]$); [email protected] )
				{
					dispbottom "Your current members are " + [email protected]$[[email protected]];

					[email protected] = checkvending([email protected]$[[email protected]]);

						if ( [email protected]&1 )
							mes "Someone is currently vending.";
						if ( [email protected]&4 )
							mes "Someone is currently in buying store.";
						if ( [email protected]&2 )
							mes "Someone is currently in autotrading.";
				}

				end;

 

 

  • Love 1

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

Loading...
Sign in to follow this