Jump to content
  • 0
Sign in to follow this  
Lord Ganja

Help with this script

Question

I'm currently creating a script that will be triggered by OnPCLoadMapEvent.

 

My problem here is, it has lot's of errors like buildin_rid2name: invalid RID, buildin_checkvending: Player (null) is not online!
I modified and applied  THIS ONE(this script actually extract account id's but i've modified it) in my server to extract character id's in a specific area. 
 
What I wanted to happen here is, after the event started. It will kick the vending players inside the event_wroom map.
but the thing is, it can't kick the vendors because the character id's are somehow messy. BUT when I use this script below, it returns the char id's of the players in the area.
prontera,148,177,5	script	getareausers	100,{	.@len = getareausers("event_wroom",1,1,500,500);	for( .@a = 0; .@a < .@len; .@a++ )		npctalk ""+.@char_ids[.@a];	end;}

 

This is the messy script that I use:

OnPCLoadMapEvent:	if( getmapusers("event_wroom") >= 10 ) {		if( .@running )end; // To avoid double trigger		if( !.@running ).@running = 1;		.@len = getareausersid("event_wroom",1,1,500,500);		for( .@i = 0; .@i < .@len; .@i++ ) {		if( checkvending(rid2name(.@char_ids[.@i])) )				.@vending += 1;		}		if ( .@vending >= 1 ) {			mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;			sleep 1000;			mapannounce "event_wroom", "3",0;			sleep 1000;			mapannounce "event_wroom", "2",0;			sleep 1000;			mapannounce "event_wroom", "1",0;			sleep 1000;			mapannounce "event_wroom", "Let's get it on!",0;			sleep 1000;			donpcevent "event_quest::OnStart"; // This will warp players on the main event map			//This part will kick the vendors			for( .@i = 0; .@i < getareausersid("event_wroom",1,1,500,500); .@i++ ) {			if(checkvending(rid2name(.@char_ids[.@i])))				atcommand "@kick "+rid2name(.@char_ids[.@i]);			}		}	}	end;

Thanks in advance!

Share this post


Link to post
Share on other sites

13 answers to this question

Recommended Posts

  • 0

 

 

 

use this script command

http://herc.ws/board/topic/4593-getmemberaid-checkmes/

 

then

 

-	script	test777	-1,{OnPCLoadMapEvent:    if(strcharinfo(3) =="event_wroom" && getmapusers("event_wroom") >= 10 && !$@gamerunning ) {        $@gamerunning = 1; //--->when the event end , remember to set this varaible to 0;        mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;        sleep2 1000;        mapannounce "event_wroom", "3",0;        sleep2 1000;        mapannounce "event_wroom", "2",0;        sleep2 1000;        mapannounce "event_wroom", "1",0;        sleep2 1000;        mapannounce "event_wroom", "Let's get it on!",0;	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;        donpcevent "event_quest::OnStart";    } end;OnInit: setmapflag "event_wroom", mf_loadevent;}

 

already tested , it was working fine for me

@@Angelmelody Thank you for this. anyway I just tested it but it still doesn't kick vendors :/ do you think vendors on auto trade mode cannot be kicked using an npc script?

 

 

I tried this script and clicked the npc.. It announces the char name of the vendors on the map but doesn't kick them..

event_wroom,34,157,4	script	kickertest	100,{	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);		mapannounce "event_wroom", strcharinfo(0),0;            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;	end;}

try 'detachrid' then kick the 'rid2name( $@onlineaid[.@i])' , I think it should work on @AT state vendors

event_wroom,34,157,4	script	kickertest	100,{	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {		mapannounce "event_wroom", rid2name( $@onlineaid[.@i]),0;		detachrid;                atcommand "@kick "+rid2name( $@onlineaid[.@i]);            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;	end;}
Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.

changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);

to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);

 

and extracting the char id's works successfully. the problem is with the script only.

Share this post


Link to post
Share on other sites
  • 0

 

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.

changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);

to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);

 

and extracting the char id's works successfully. the problem is with the script only.

 

script->setd_sub(st, NULL, ".@char_ids", *users, (void *)h64BPTRSIZE(sd->status.char_id), NULL);

Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

 

 

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.

changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);

to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);

 

and extracting the char id's works successfully. the problem is with the script only.

 

script->setd_sub(st, NULL, ".@char_ids", *users, (void *)h64BPTRSIZE(sd->status.char_id), NULL);

Thanks for this.. But it still doesn't kick the vendors :/

Would you mind to check the script itself? Coz I have a hunch that it's actually because of the script..

Share this post


Link to post
Share on other sites
  • 0

 

 

 

 

 

 

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.

changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);

to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);

 

and extracting the char id's works successfully. the problem is with the script only.

 

 

script->setd_sub(st, NULL, ".@char_ids", *users, (void *)h64BPTRSIZE(sd->status.char_id), NULL);

 

 

Thanks for this.. But it still doesn't kick the vendors :/

Would you mind to check the script itself? Coz I have a hunch that it's actually because of the script..

 

 

I can't understand the logic of your script , why did you need to kick all vendors on that event map?

why not just set mapflag novending to that map?

Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

 

 

 

 

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.

changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);

to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);

 

and extracting the char id's works successfully. the problem is with the script only.

 

script->setd_sub(st, NULL, ".@char_ids", *users, (void *)h64BPTRSIZE(sd->status.char_id), NULL);

 

Thanks for this.. But it still doesn't kick the vendors :/

Would you mind to check the script itself? Coz I have a hunch that it's actually because of the script..

 

I can't understand the logic of your script , why did you need to kick all vendors on that event map?

why not just set mapflag novending to that map?

I have my own reasons for the vendors.. The event can't run unless there are 10 players participating.. but during night time, there are less players who want to play the event.

That's why I they can vend inside the event map for it to start.. I also don't want to use timer for it.. Right now the only problem im facing here is the script wont kick the vendors for some reason.

but im pretty sure that it extracts their char ids. 

Share this post


Link to post
Share on other sites
  • 0

Just a question, why did you have to modify it to get charIDs when most commands work with accIDs, including *attachrid and *rid2name? You can just go through the accID array, attaching the players to script, and do checkvending() without any extra options on it.

 

Speaking of which that's why you're getting an error. For rid2name you need to provide accID, not charID.

Share this post


Link to post
Share on other sites
  • 0

 

 

 

 

 

 

 

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.
changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);
to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);
 
and extracting the char id's works successfully. the problem is with the script only.

 

script->setd_sub(st, NULL, ".@char_ids", *users, (void *)h64BPTRSIZE(sd->status.char_id), NULL);

 

Thanks for this.. But it still doesn't kick the vendors :/
Would you mind to check the script itself? Coz I have a hunch that it's actually because of the script..

 

I can't understand the logic of your script , why did you need to kick all vendors on that event map?
why not just set mapflag novending to that map?

 

I have my own reasons for the vendors.. The event can't run unless there are 10 players participating.. but during night time, there are less players who want to play the event.
That's why I they can vend inside the event map for it to start.. I also don't want to use timer for it.. Right now the only problem im facing here is the script wont kick the vendors for some reason.
but im pretty sure that it extracts their char ids.

 


As I remembered, the rid2name only support player's account id not char id,
you should change back to account id
script->setd_sub(st, NULL, ".@account_ids", *users, (void *)h64BPTRSIZE(sd->status.account_id), NULL);

 

and
 

OnPCLoadMapEvent:    if(strcharinfo(3)!="event_wroom") end;    if( getmapusers("event_wroom") >= 10 && !$@gamerunning ) {        $@gamerunning = 1; //--->when the event end ,  remember to set this varaible to 0;        mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;        sleep2 1000;        mapannounce "event_wroom", "3",0;        sleep2 1000;        mapannounce "event_wroom", "2",0;        sleep2 1000;        mapannounce "event_wroom", "1",0;        sleep2 1000;        mapannounce "event_wroom", "Let's get it on!",0;        .@len = getareausersid("event_wroom",1,1,500,500);        freeloop(1);        for( .@i = 0; .@i < .@len; .@i++ ) {            if( attachrid(.@account_ids[.@i]) && checkvending() ) {                atcommand "@kick "+strcharinfo(0);            }        }        freeloop(0);        donpcevent "event_quest::OnStart";    }    end;
Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

Just a question, why did you have to modify it to get charIDs when most commands work with accIDs, including *attachrid and *rid2name? You can just go through the accID array, attaching the players to script, and do checkvending() without any extra options on it.

 

Speaking of which that's why you're getting an error. For rid2name you need to provide accID, not charID.

Thanks for the heads up.

Anyway I didn't know such. I thought a character can only be kicked when I use its char id. so will it work also with account ids?

im noob at scripting :/  I also didn't know about the rid2name. thanks though :)

 

 

 

 

 

 

 

 

 

its .@account_ids[.@i]  not .@char_ids[.@i]

I've modified it.

changed this part -> setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);

to this one -> setd_sub(st, NULL, ".@char_ids", *users, (void *)__64BPRTSIZE(sd->status.char_id), NULL);

 

and extracting the char id's works successfully. the problem is with the script only.

 

script->setd_sub(st, NULL, ".@char_ids", *users, (void *)h64BPTRSIZE(sd->status.char_id), NULL);

 

Thanks for this.. But it still doesn't kick the vendors :/

Would you mind to check the script itself? Coz I have a hunch that it's actually because of the script..

 

I can't understand the logic of your script , why did you need to kick all vendors on that event map?

why not just set mapflag novending to that map?

 

I have my own reasons for the vendors.. The event can't run unless there are 10 players participating.. but during night time, there are less players who want to play the event.

That's why I they can vend inside the event map for it to start.. I also don't want to use timer for it.. Right now the only problem im facing here is the script wont kick the vendors for some reason.

but im pretty sure that it extracts their char ids.

 

 

As I remembered, the rid2name only support player's account id not char id,

you should change back to account id

script->setd_sub(st, NULL, ".@account_ids", *users, (void *)h64BPTRSIZE(sd->status.account_id), NULL);

 

and

 

OnPCLoadMapEvent:	if( getmapusers("event_wroom") >= 10 && !$@gamerunning ) {		$@gamerunning = 1; //--->when the event end ,  remember to set this varaible to 0; 		mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;		sleep2 1000;		mapannounce "event_wroom", "3",0;		sleep2 1000;		mapannounce "event_wroom", "2",0;		sleep2 1000;		mapannounce "event_wroom", "1",0;		sleep2 1000;		mapannounce "event_wroom", "Let's get it on!",0;		.@len = getareausersid("event_wroom",1,1,500,500);		freeloop(1);		for( .@i = 0; .@i < .@len; .@i++ ) {			if( attachrid(.@account_ids[.@i]) && checkvending() ) {				atcommand "@kick "+strcharinfo(0);			}		}		freeloop(0);		donpcevent "event_quest::OnStart";	}	end;

I'll try this one when I got home.. Anyway thank you for this one. :) I'll comment back after I test it.

 

@@Angelmelody I test your script. I didn't got any warnings or errors but the vendors are not kicked.

Share this post


Link to post
Share on other sites
  • 0

 

use this script command

http://herc.ws/board/topic/4593-getmemberaid-checkmes/

 

then

 

-	script	test777	-1,{OnPCLoadMapEvent:    if(strcharinfo(3) =="event_wroom" && getmapusers("event_wroom") >= 10 && !$@gamerunning ) {        $@gamerunning = 1; //--->when the event end , remember to set this varaible to 0;        mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;        sleep2 1000;        mapannounce "event_wroom", "3",0;        sleep2 1000;        mapannounce "event_wroom", "2",0;        sleep2 1000;        mapannounce "event_wroom", "1",0;        sleep2 1000;        mapannounce "event_wroom", "Let's get it on!",0;	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;        donpcevent "event_quest::OnStart";    } end;OnInit: setmapflag "event_wroom", mf_loadevent;}

 

already tested , it was working fine for me

Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

 

 

use this script command

http://herc.ws/board/topic/4593-getmemberaid-checkmes/

 

then

 

-	script	test777	-1,{OnPCLoadMapEvent:    if(strcharinfo(3) =="event_wroom" && getmapusers("event_wroom") >= 10 && !$@gamerunning ) {        $@gamerunning = 1; //--->when the event end , remember to set this varaible to 0;        mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;        sleep2 1000;        mapannounce "event_wroom", "3",0;        sleep2 1000;        mapannounce "event_wroom", "2",0;        sleep2 1000;        mapannounce "event_wroom", "1",0;        sleep2 1000;        mapannounce "event_wroom", "Let's get it on!",0;	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;        donpcevent "event_quest::OnStart";    } end;OnInit: setmapflag "event_wroom", mf_loadevent;}

 

already tested , it was working fine for me

@@Angelmelody Thank you for this. anyway I just tested it but it still doesn't kick vendors :/ do you think vendors on auto trade mode cannot be kicked using an npc script?

 

 

I tried this script and clicked the npc.. It announces the char name of the vendors on the map but doesn't kick them..

event_wroom,34,157,4	script	kickertest	100,{	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);		mapannounce "event_wroom", strcharinfo(0),0;            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;	end;}

Share this post


Link to post
Share on other sites
  • 0

 

 

 

 

use this script command

http://herc.ws/board/topic/4593-getmemberaid-checkmes/

 

then

 

-	script	test777	-1,{OnPCLoadMapEvent:    if(strcharinfo(3) =="event_wroom" && getmapusers("event_wroom") >= 10 && !$@gamerunning ) {        $@gamerunning = 1; //--->when the event end , remember to set this varaible to 0;        mapannounce "event_wroom", "Event is about to start in 3 seconds.",0;        sleep2 1000;        mapannounce "event_wroom", "3",0;        sleep2 1000;        mapannounce "event_wroom", "2",0;        sleep2 1000;        mapannounce "event_wroom", "1",0;        sleep2 1000;        mapannounce "event_wroom", "Let's get it on!",0;	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;        donpcevent "event_quest::OnStart";    } end;OnInit: setmapflag "event_wroom", mf_loadevent;}

 

already tested , it was working fine for me

@@Angelmelody Thank you for this. anyway I just tested it but it still doesn't kick vendors :/ do you think vendors on auto trade mode cannot be kicked using an npc script?

 

 

I tried this script and clicked the npc.. It announces the char name of the vendors on the map but doesn't kick them..

event_wroom,34,157,4	script	kickertest	100,{	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {                atcommand "@kick "+strcharinfo(0);		mapannounce "event_wroom", strcharinfo(0),0;            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;	end;}

try 'detachrid' then kick the 'rid2name( $@onlineaid[.@i])' , I think it should work on @AT state vendors

event_wroom,34,157,4	script	kickertest	100,{	getmemberaid ALL_SAMEMAP, "event_wroom";        freeloop(1);        for( .@i = 0; .@i < $@onlinecount; .@i++ ) {            if( attachrid($@onlineaid[.@i]) && strcharinfo(3) == "event_wroom" && checkvending() ) {		mapannounce "event_wroom", rid2name( $@onlineaid[.@i]),0;		detachrid;                atcommand "@kick "+rid2name( $@onlineaid[.@i]);            }        }        freeloop(0);	$@onlinecount = 0;	deletearray $@onlineaid;	end;}

That's it!! LOL it's working fine now. I only need to detachrid before kicking the vendors on at mode. lol thank you so much @@Angelmelody

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

  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  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.