kyeme Posted June 25, 2012 Posted June 25, 2012 I need a Party checker NPC script for not allowing same Job in the Party. Can anyone help me? Quote
deathscythe13 Posted June 27, 2012 Posted June 27, 2012 try this prontera,156,180,4 script Party Checker 100,{ if(getcharid(1) != 1) { mes "Sorry you don't have party."; close; } getpartymember getcharid(1),1; getpartymember getcharid(1),2; for( set .@i,0; .@i<$@partymembercount && !.@classdupe; set .@i,.@i+1 ) { if (isloggedin($@partymemberaid[.@i],$@partymembercid[.@i]) ) { attachrid($@partymemberaid[.@i]); set .@comparemember1, Class; attachrid($@partymemberaid[.@i+1]); set .@comparemember2, Class; if(.@comparemember2 == .@comparemember1) set .@classdupe, 1; detachrid; } } if(.@classdupe) { mes "Sorry there is someone in your party with the same Class."; close; } mes "Good your ready to go"; close; } Quote
Tonetzkii Posted July 10, 2012 Posted July 10, 2012 bump not working on me he say always "Sorry you don't have party." I have a party with same job. Quote
Emistry Posted July 10, 2012 Posted July 10, 2012 change if(getcharid(1) != 1) { into if(!getcharid(1) ) { Quote
KeyWorld Posted July 10, 2012 Posted July 10, 2012 The script above can't work : - If the party is : mage, archer, swordman, mage, it will not find the 2 mages. - Can have problem with offline member (Class will throw an error ?) - What about a user disconnect before the test and reconnect after ? So here a function (not tested), I just write on the fly, should do the work. function script party_has_duplicate_job { set .@party_id, getarg( 0, getcharid(1) ); // Need to have a party. if ( .@party_id != 1 ) { return -1; } // Loading party members variables getpartymember getcharid(1),1; getpartymember getcharid(1),2; // Keep rid attached. set .@rid, playerattached(); // Check all members for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 ) { // Online user if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) ) { // Attach the member to access "Class" attachrid( $@partymemberaid[.@i] ); if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + Class; } // Offline user (use sql) else { set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) "`char_id`='" + $@partymembercid[.@i] + "' "; set .@sql_i, .@sql_i + 1; } } // SQL for offline users if ( getstrlen(.@sql$) ) { // get class from offline members set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class ); // Check the class. for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 ) { if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i]; } } // Restore RID. if ( .@rid ) attachrid(.@rid); else detachrid; return 0; } Example of used: if ( callfunc("party_has_duplicate_job") ) { mes "It seems that someone in the party has the same class than another member. Please check again the requirements..."; close; } mes "OK, no problem with your party, let's go !"; ... Quote
Virtue Posted July 10, 2012 Posted July 10, 2012 The script above can't work : - If the party is : mage, archer, swordman, mage, it will not find the 2 mages. - Can have problem with offline member (Class will throw an error ?) - What about a user disconnect before the test and reconnect after ? So here a function (not tested), I just write on the fly, should do the work. function script party_has_duplicate_job { set .@party_id, getarg( 0, getcharid(1) ); // Need to have a party. if ( .@party_id != 1 ) { return -1; } // Loading party members variables getpartymember getcharid(1),1; getpartymember getcharid(1),2; // Keep rid attached. set .@rid, playerattached(); // Check all members for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 ) { // Online user if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) ) { // Attach the member to access "Class" attachrid( $@partymemberaid[.@i] ); if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + Class; } // Offline user (use sql) else { set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) "`char_id`='" + $@partymembercid[.@i] + "' "; set .@sql_i, .@sql_i + 1; } } // SQL for offline users if ( getstrlen(.@sql$) ) { // get class from offline members set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class ); // Check the class. for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 ) { if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i]; } } // Restore RID. if ( .@rid ) attachrid(.@rid); else detachrid; return 0; } Example of used: if ( callfunc("party_has_duplicate_job") ) { mes "It seems that someone in the party has the same class than another member. Please check again the requirements..."; close; } mes "OK, no problem with your party, let's go !"; ... Can you make this script + limit the party members to seven only? Quote
KeyWorld Posted July 10, 2012 Posted July 10, 2012 Can you make this script + limit the party members to seven only? Just 7 members or 1 to 7 members ? Quote
Tonetzkii Posted July 10, 2012 Posted July 10, 2012 Im trying.... Still not working i need this script. bump Quote
KeyWorld Posted July 10, 2012 Posted July 10, 2012 Im trying.... Still not working i need this script. bump Maybe due to the header "{" in the next line, try replace this: function script party_has_duplicate_job { With: function script party_has_duplicate_job { Quote
GM Takumirai Posted July 10, 2012 Posted July 10, 2012 - waiting for this to finish.. this will be a good start for RPC 7vs 7 event Quote
Tonetzkii Posted July 10, 2012 Posted July 10, 2012 Yes ill try this later. im on work i hope it works this is my last script to finish my rwc organizer automated. Quote
GM Takumirai Posted July 10, 2012 Posted July 10, 2012 http://rathena.org/board/topic/66873-party-vs-party/ = check this script i found on eAthena - its check party but not that good Quote
Tonetzkii Posted July 10, 2012 Posted July 10, 2012 Thanks but i have already party registration this script is 1 missing Quote
Virtue Posted July 10, 2012 Posted July 10, 2012 Can you make this script + limit the party members to seven only? Just 7 members or 1 to 7 members ? Yup just 7 members fixed. not 1 to 7. I'll try to make some too, but just in case could you make it possible. Quote
KeyWorld Posted July 10, 2012 Posted July 10, 2012 @Khaii This should fixed the problem : function script party_has_duplicate_job { set .@party_id, getarg( 0, getcharid(1) ); // Need to have a party. if ( .@party_id != 1 ) { return -1; } // Loading party members variables getpartymember .@party_id,1; getpartymember .@party_id,2; // Keep rid attached. set .@rid, playerattached(); // Check all members for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 ) { // Online user if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) ) { // Attach the member to access "Class" attachrid( $@partymemberaid[.@i] ); if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + Class; } // Offline user (use sql) else { set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) + "`char_id`='" + $@partymembercid[.@i] + "' "; set .@sql_i, .@sql_i + 1; } } // SQL for offline users if ( getstrlen(.@sql$) ) { // get class from offline members set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class ); // Check the class. for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 ) { if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i]; } } // Restore RID. if ( .@rid ) attachrid(.@rid); else detachrid; return 0; } @Emnaj if ( callfunc("party_has_duplicate_job") ) { mes "It seems that someone in the party has the same class than another member. Please check again the requirements..."; close; } if ( $@partymembercount != 7 ) { mes "You have to be 7 on the team."; close; } mes "OK, no problem with your party, let's go !"; Quote
Virtue Posted July 10, 2012 Posted July 10, 2012 (edited) @khaii have you tried this? function<tab>script<tab>party_has_duplicate_job<tab>{ set .@party_id, getarg( 0, getcharid(1) ); // Need to have a party. if ( .@party_id != 1 ) { return -1; } // Loading party members variables getpartymember getcharid(1),1; getpartymember getcharid(1),2; // Keep rid attached. set .@rid, playerattached(); // Check all members for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 ) { // Online user if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) ) { // Attach the member to access "Class" attachrid( $@partymemberaid[.@i] ); if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + Class; } // Offline user (use sql) else { set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) "`char_id`='" + $@partymembercid[.@i] + "' "; set .@sql_i, .@sql_i + 1; } } // SQL for offline users if ( getstrlen(.@sql$) ) { // get class from offline members set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class ); // Check the class. for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 ) { if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i]; } } // Restore RID. if ( .@rid ) attachrid(.@rid); else detachrid; return 0; } Edited July 10, 2012 by Emnaj Quote
Tonetzkii Posted July 10, 2012 Posted July 10, 2012 @Emnaj , KeyWorld Its working now thank you very much! for fast reply. Now my problem is i have a 2 jobs not same. look the picture prontera,153,167,3 script War Organizer 89,{ mes "[War Organizer]"; mes "Welcome "+strcharinfo(0)+"!"; mes "I am the War Arena Organizer"; menu "Choose the Room Battle",L_Choose; L_Choose: menu "Arena 3 (Open)",L_Arena3; L_Arena3: next; mes "[War Organizer]"; if ( callfunc("party_has_duplicate_job") ) { mes "It seems that someone in the party has the same class than another member. Please check again the requirements..."; close; } if ( $@partymembercount != 2 ) { mes "You have to be 2 on the team."; close; } mes "OK, no problem with your party, let's go !"; warp "quiz_02",37,63; end; } Quote
Virtue Posted July 10, 2012 Posted July 10, 2012 i have not yet tested this but I will reply as soon as i can, Quote
KeyWorld Posted July 11, 2012 Posted July 11, 2012 My fault, I copy deathscythe13's base script without reading : function script party_has_duplicate_job { set .@party_id, getarg( 0, getcharid(1) ); // Need to have a party. if ( !.@party_id ) { return -1; } // Loading party members variables getpartymember .@party_id, 1; getpartymember .@party_id, 2; // Keep rid attached. set .@rid, playerattached(); // Check all members for ( set .@i,0; .@i<$@partymembercount; set .@i, .@i+1 ) { // Online user if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i]) ) { // Attach the member to access "Class" attachrid( $@partymemberaid[.@i] ); if ( compare( .@tmp_class$ + "|", "|" + Class + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + Class; } // Offline user (use sql) else { set .@sql$, .@sql$ + ( .@sql_i ? "OR " : "" ) + "`char_id`='" + $@partymembercid[.@i] + "' "; set .@sql_i, .@sql_i + 1; } } // SQL for offline users if ( getstrlen(.@sql$) ) { // get class from offline members set .@count, query_sql("SELECT `class` FROM `char` WHERE " + .@sql$, .@class ); // Check the class. for ( set .@i, 0; .@i<.@count; set .@i, .@i+1 ) { if ( compare( .@tmp_class$ + "|", "|" + .@class[.@i] + "|" ) ) { if ( .@rid ) attachrid(.@rid); else detachrid; return 1; } set .@tmp_class$, .@tmp_class$ + "|" + .@class[.@i]; } } // Restore RID. if ( .@rid ) attachrid(.@rid); else detachrid; return 0; } 1 Quote
Tonetzkii Posted July 11, 2012 Posted July 11, 2012 Its working now thank you! i have organizer rwc now. Quote
SlashGeeGee Posted July 11, 2012 Posted July 11, 2012 Its working now thank you! i have organizer rwc now. will you share it ? Quote
Virtue Posted July 11, 2012 Posted July 11, 2012 its not quite easy to make one but if he is willing to share it it would be great for the others. clue : make the KVM scripts as a pattern then add the partychecker. at least thats what i did. Quote
Question
kyeme
I need a Party checker NPC script for not allowing same Job in the Party. Can anyone help me?
29 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.