Jump to content
  • 0

Check Partymembers status


Question

Posted

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

			getpartymember getcharid(1),0;
			setarray .@name$[0], $@partymembername$[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.

 

3 answers to this question

Recommended Posts

  • 1
Posted

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;

 

  • 0
Posted
1 hour ago, Radian said:

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


			getpartymember getcharid(1),0;
			setarray .@name$[0], $@partymembername$[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], $@partymembername$[0];

You're just setting the first value of '$@partymembername$' 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:


copyarray .@name$[0], $@partymembername$[0], $@partymembercount;


 

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 ( .@i = 0; .@i < getarraysize(.@name$); ++.@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.";
				}

Complete function:


				getpartymember getcharid(1), 0;
				copyarray .@name$[0], $@partymembername$[0], $@partymembercount;

				for ( .@i = 0; .@i < getarraysize(.@name$); ++.@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;

 

 

  • Love 1

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