Jump to content
  • 0

Check Partymembers status


Radian

Question


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

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.

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

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;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  50
  • Reputation:   39
  • Joined:  01/13/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

@sader1992 Yes, thank you again!

@Cretino Thanks for the time checking this!

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