Jump to content

PvP Recruiter (Previously PvP [4v4])


Recommended Posts


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

Made a rewrite of a script for this thread: https://rathena.org/board/topic/103264-how-to-add-reward-to-winning-team-for-this-pvp-script/#entry290622

 

This video is running v1.4 of the script

Some Add'l Screenshots:

post-7005-0-16484500-1443890861_thumb.jpg

change number of players by searching for .NumPlayers to your needs.

Example You want a 2v2: set .Numplayers, 2;

 

Currently working on:

1. Making rounds configurable [Suggested by PandaLovesHamster]
2. Player will not be able to kill a player on the same team [Suggested by Litro Endemic]
Changelog:

v1.6 by Me PvP Recruiter.txt

- Changed Line up view to PlayerName instead of CharID and shows "None Yet" if no player has registered yet [suggested by Emistry]
v1.5 by Me PvP Recruiter.txt

- Will be tagged as stable if noone complains about any bug

- Fixed the "fatal error: player not attached problem" caused by @MyTeam

- Participant will be taken as a casualty if he logs out when the session is on-going

- Added mapflags and can be modified through .@mapflags

- Tested and results were without errors, bugs, and exploits.

v1.4 by Me PvP Recruiter.txt

- Will be tagged as stable if noone complains about any bug

- Thoroughly fixed a lot of logical and semantic errors

- Optimized a lot of codes

- Fixed a lot of exploits and bugs

- Made it functionally working 

- Demo video uploaded

v1.3 by Me PvP Recruiter.txt

- Quick fix for event not being able to function correctly because of mishandled variables

- Optimized OnEventStart algorithm

- Optimized and Improved Logged in/Logged Off Checking [suggested by PandaLovesHamster]

- Takes off logged off players from the roster instead of resetting the whole recruitment process [Response to the question of PandaLovesHamster]

- Took off OnFailLack

- Added OnPCLoginEvent and OnPCLogoutEvent

- Added GM OnAtCommand Safe failcheck [suggested by Litro Endemic]

v1.2 by Me PvP Recruiter.txt

- Renamed to "PvP Recruiter"

- Changed @4v4 to @pvprecruitment <on|off>

- Added flexibility on number of parcipants (set .NumPlayers)

- Fixed and improved free slot checking algorithm

- Fixed and improved registration checking and team transfer algorithm

- Added Player Variable @MyTeam for easier checkings:

    [0] Team number ( 0 for No Team Yet | 1 for Odin | 2 for Freya)

    [1] Slot number of his team

- Fixed OnClear event

- Fixed Menu not closing on registration

- Added a variable to indicate if the session is on-going (set .started)

- Check if the event is already running at the beginning

v1.1 by PandaLovesHamster http://pastebin.com/Nya7kzsQ

- Player Logoff Detection

- Team change on recruitment stage 

v1.0 by Me pvp4v4.txt

- Rewrote the whole script

- Multiple registration detection

- Free slot detection

- Warp in and warp out function

- Rewards per kill

- Rewards for round win

- Search for "getitem" to change rewards and their quantity

- GM Commands: @4v4 on ~ to start | @4v4 off ~ to interrupt at anytime

- Broadcast message on registering when noone else has or during GM atcommand trigger

Screenshots:

post-7005-0-03500500-1443551890_thumb.jpgpost-7005-0-65317500-1443551887_thumb.jpgpost-7005-0-11353400-1443551886_thumb.jpgpost-7005-0-04818100-1443551883_thumb.jpgpost-7005-0-59595900-1443551880_thumb.jpgpost-7005-0-20223800-1443551878_thumb.jpgpost-7005-0-10641800-1443551875_thumb.jpg

 

Credits:

Credits to jTynne for the original script that this was based on and to PandaLovesHamster for saving my file XD

Credits to PandaLovesHamster for suggestions making addons

Credits to Litro Endemic for suggestions

Edited by jezznar
  • Upvote 3
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.02
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

Suggestion/s:

1. Player will be able to "back-out" of the match.

 - Reason: These would actually let players in and out of the list if they wish to.

2  Player can switch teams before match starts.

 - Reason: One might "accidentally" join another team rather than the team he is on, 100% of the time he's gonna pm a gm to transfer him or something.
3. NPC will not warp if there are disconnected users. I'm not sure on this part if its do-able or not

 - Reason: So that GMs don't have to @recall every now and then. Maybe the NPC should recall the players when the event is on-going. Also if they die, they get warped back to their corner (with activated setwall stuff) or warped to another map so they can easily be warped back to their corner after the match is over.

4. Make the number of rounds configurable. Meaning after round 1 finished, teams will be warped to some random corner or to their previous corner.

 - Reason: People might request for Best of 3 or Best of 5 rounds and it would be hassle if they have to wait another 5 minutes for another match to start.

 - Default: If there is no specified number of rounds (probably can be set in-game using @command) it round will be defaulted to 1 only
 - Note: Player-activated 4v4(7v7 on my part) event should be set always to 1 round only (only GMs can configure how many rounds - as it is a special event of sorts)

 

Question/s:
1. Will the player still retain his seat/spot if he accidentally logs off or gets disconnected?

 

Hope some of those will be implemented. Very nice script by the way.

Edited by PandaRapesHamster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

Suggestion/s:

1. Player will be able to "back-out" of the match.

- Reason: These would actually let players in and out of the list if they wish to.

2 Player can switch teams before match starts.

- Reason: One might "accidentally" join another team rather than the team he is on, 100% of the time he's gonna pm a gm to transfer him or something.

3. NPC will not warp if there are disconnected users. I'm not sure on this part if its do-able or not

- Reason: So that GMs don't have to @recall every now and then. Maybe the NPC should recall the players when the event is on-going. Also if they die, they get warped back to their corner (with activated setwall stuff) or warped to another map so they can easily be warped back to their corner after the match is over.

4. Make the number of rounds configurable. Meaning after round 1 finished, teams will be warped to some random corner or to their previous corner.

- Reason: People might request for Best of 3 or Best of 5 rounds and it would be hassle if they have to wait another 5 minutes for another match to start.

- Default: If there is no specified number of rounds (probably can be set in-game using @command) it round will be defaulted to 1 only

- Note: Player-activated 4v4(7v7 on my part) event should be set always to 1 round only (only GMs can configure how many rounds - as it is a special event of sorts)

Question/s:

1. Will the player still retain his seat/spot if he accidentally logs off or gets disconnected?

Hope some of those will be implemented. Very nice script by the way.

Thank you for the appreciation, I will consider those suggestions and try to work those out. :)

For your question:

right now, yes he will be able to retain his spot unless he logs in after the round has concluded.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.02
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

I'll try to add modifications to it to try and help you out, hopefully i can get some going.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

I'll try to add modifications to it to try and help you out, hopefully i can get some going.

 

would love to see your mods, Thanks :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.02
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

3 and 4 I could probably do. But #3 is iffy, I'll need that if the player logs out, he should be evicted from the list. Making it impossible for the timer to proceed since putting a check OnTimer30000 would prevent it from running since a missing player is detected.

Or perhaps a variable will be set if a player who is registered logs off, increasing a certain variable, and if they log back in, they decrease the variable, making it possible to check even if he is still inside the array.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  14
  • Reputation:   0
  • Joined:  06/27/14
  • Last Seen:  

the npc doesnt seem to show up in the specified coordinates. @4v4 doesnt work as well

AIxZN2i.png

Edited by Caves
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

the npc doesnt seem to show up in the specified coordinates. @4v4 doesnt work as well

 

That's weird? anyway, I'll reupload it once I get home. Sorry for that.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

3 and 4 I could probably do. But #3 is iffy, I'll need that if the player logs out, he should be evicted from the list. Making it impossible for the timer to proceed since putting a check OnTimer30000 would prevent it from running since a missing player is detected.

Or perhaps a variable will be set if a player who is registered logs off, increasing a certain variable, and if they log back in, they decrease the variable, making it possible to check even if he is still inside the array.

Simply add the account I'd to an array then do a check if all in the array are logged in.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.02
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

How to actually do a check if the players are logged in or not? [DONE]

Known issues:

 - When a match finishes, there will be no other matches because the arrays are not emptied. No idea why the callsub is not working for OnClear.

 - Player who registers last will be stuck on the menu screen.

Current Progress:
 

 - NPC will now detect if a player logs off before starting the event.

 - NPC will now allow team changing if there are slots available.

 

NPC still has errors, I will post the updated mod for it later on.

 

Here's a copy of my modified script - It is NOT WORKING because it throws errors even if the two registered players are online. :) If anyone can fix, would be glad. Credits to jezznar.

// ------------------------------------------------------------------------------------------
// ------ rAthena Script Release
// Title: PvP [4v4] Rewrite
// Author: jezznar
// Version: 1.0 Jezznar
// Search for "getitem" to change rewards and their quantity
// ------------------------------------------------------------------------------------------
prontera,145,186,6    script    7vs7 Recruiter    416,{
set .@n$,"[^FF0000Party Battle Recruiter^000000]";
set .@charid,getcharid(0);
set .@rid,getcharid(3);
mes .@n$;
mes "Would you like to register for a 4 versus 4 Party Battle?";
next;
Select("Yes:No");
if (@menu == 2)
    end;
// Check if there is free slot
if (getarraysize($Odin) >= 1 && getarraysize($Freya) >= 1) {
    mes "Sorry, there are no slots available right now. Please come back again later.";
    close;
}  else if (getmapusers("guild_vs3") > 0) { // Check if there is an on-going session
    mes .@n$;
    mes "There appears to be a match currently in session. Check back momentarily.";
    close;
}

// Check if character is already registered
for (set .@x, 0; .@x < 1; set .@x, .@x + 1){
    if ($Odin[.@x] == .@charid){
        mes "You are already registered in slot "+(.@x+1)+" of the Odin Team.";
        if(getarraysize($Freya) <= 1){
            menu "Transfer to other side?",-;
            for( set .y, 0; .y < 1; set .y, y++){
                if(!attachrid($Freya[.y])){
                    set $Freya[.y], $Odin[.@x];
                    set $Odin[.@x], 0;
                }
            }
        }
        close;
    }
    else if ($Freya[.@x] == .@charid){
        mes "You are already registered in slot "+(.@x+1)+" of the Freya Team.";
        if(getarraysize($Odin) <= 1){
            menu "Transfer to other side?",-;
            for( set .y, 0; .y < 1; set .y, y++){
                if(!attachrid($Odin[.y])){
                    set $Odin[.y], $Freya[.@x];
                    set $Freya[.@x], 0;
                }
            }
        }
        close;
    }
}



mes .@n$;
mes "Which side are you going to play for?";
next;
    
switch(select("Odin ("+(getarraysize($Odin))+"/1):Freya ("+(getarraysize($Freya))+"/1)")) {
    case 1:
        if (getarraysize($Odin) < 1) {
            if (getarraysize($Odin) == 0 && getarraysize($Freya) == 0 && .OnGMStart == 0) { // Check if he is the first one to register & not manually started by a GM
                initnpctimer;
                announce "The PvP[7v7] Event has been triggered by "+strcharinfo(0)+"! Join now!",bc_all;
            }            
            set $Odin[getarraysize($Odin)], .@charid;
            set $OdinR[getarraysize($OdinR)], .@rid;
            npctalk strcharinfo(0)+" has entered the round on Odin's Side.";
            close;

        } else {
            mes "This team is full.";
            close;
        }
        break;
    case 2:
        if (getarraysize($Freya) < 1) {
            if (getarraysize($Odin) == 0 && getarraysize($Freya) == 0 && .OnGMStart == 0) { // Check if he is the first one to register & not manually started by a GM
                initnpctimer;
                announce "The PvP[7v7] Event has been triggered by "+strcharinfo(0)+"! Join now!",bc_all;
            }                
            set $Freya[getarraysize($Freya)], .@charid;
            set $FreyaR[getarraysize($FreyaR)], .@rid;
            npctalk strcharinfo(0)+" has entered the round on Freya's Side.";
            close;
        } else {
            mes "This team is full.";
            close;
        }
        break;
}


if((getarraysize($Odin)) == 1 && (getarraysize($Freya)) == 1) {  
    stopnpctimer;
    callsub OnEventStart;
    close;
}
    
close;
end;


OnEventStart:
set $OdinCount, 1; // Set team alive player counter
set $FreyaCount, 1; // Set team alive player counter
npctalk "Both teams have been filled. All participants currently logged in will be transferred to the arena in ten seconds.";
sleep2 10000;
//Warp all participants to the event place - guild_vs3
for(set .i,0; .i < 14; set .i,.i++){
    if(!attachrid($Freya[.i]) || !attachrid($Odin[.i])) { goto OnFailLack; }
}
for (set .@x, 0; .@x < 1; set .@x, .@x + 1) {
    warpchar "guild_vs3",18,50,$Odin[.@x];
    warpchar "guild_vs3",83,50,$Freya[.@x];
}
end;

L_cancel:
    mes .@n$;
    mes "Do come back if you change your mind.";
    close;
end;



OnTimer10000:
    npctalk "Ten seconds have passed. Entry to the round ends in 20 seconds.";
    end;
OnTimer20000:
    npctalk "Twenty seconds have passed. Entry to the round ends in 10 seconds.";
    end;
OnTimer30000:
    npctalk "Thirty seconds have passed and thus I have canceled the round.";
    stopnpctimer;
    goto OnClear;
    end;
    
OnFailLack:
    announce "7 vs 7 Event has failed due to a missing participant.",0;
    sleep 10000;
    announce "Event has been reset. Please register again.",0;
    set .OnGMStart, 0;
    cleararray $Odin,0,1;
    cleararray $Freya,0,1;
    end;

OnClear:
    set .OnGMStart, 0;
    cleararray $Odin,0,1;
    cleararray $Freya,0,1;
    stopnpctimer;
end;

OnAtCommand:
    if (.@atcmd_parameters$[0] == "on"){
        initnpctimer;
        announce "A GM has started a PvP[7v7] Event! Join now!",bc_all;
        set .OnGMStart, 1;
    } else if (.@atcmd_parameters$[0] == "off"){
        stopnpctimer;
        announce "A GM has stopped a PvP[7v7] Event!",bc_all;
        for (set .@x, 0; .@x < 1; set .@x, .@x + 1) { // warp all characters out if a session was on-going
            warpchar "prontera",156,191,$Odin[.@x];
            warpchar "prontera",156,191,$Freya[.@x];
        }    
        callsub OnClear;
        set .OnGMStart, 0;
    }
end;


OnInit:
    bindatcmd "4v4", strnpcinfo(0)+"::OnAtCommand";
    set .OnGMStart, 0;
    end;
    
OnPCDieEvent:
if(strcharinfo(3) == "guild_vs3") { warp "SavePoint",0,0;}
end;


OnPCKillEvent:
if( strcharinfo(3) == "guild_vs3") {
    mapannounce "guild_vs3","PvP[7v7] Event:"+strcharinfo(0)+" has killed "+rid2name(killedrid)+".",1,0xD6A4E6;
    Getitem 607, 5; //Reward for killing a member of the other team
    for (set .@x, 0; .@x < 1; set .@x, .@x + 1) { // Decrease Team Alive Player Counter
        if ($OdinR[.@x] == killedrid)
            set $OdinCount, $OdinCount - 1;
        else if ($FreyaR[.@x] == killedrid)
            set $FreyaCount, $FreyaCount - 1;
    }
    mapannounce "guild_vs3","PvP[7v7] Event: Odin:"+$OdinCount+" Freya:"+$FreyaCount,1,0xD6A4E6;
    if ($OdinCount <= 0){ // Check if Team Odin is all dead
        mapannounce "guild_vs3","PvP[4v4] Event: The Odin Team has dominated this round!",1,0xD6A4E6;
        //Reward all of Team Freya for kill of Team Odin
        for (set .@x, 0; .@x < 1; set .@x, .@x + 1){
            detachrid; //detach killer rid
            attachrid($FreyaR[.@x]);
            getitem 607, 50; //reward for winning the round
            warp "SavePoint",0,0;
            detachrid;            
        }
        callsub OnClear;
    }    
    else if ($FreyaCount <= 0){ // Check if Team Freya is all dead
        mapannounce "guild_vs3","PvP[7v7] Event: The Freya Team has dominated this round!",1,0xD6A4E6;
        //Reward all of Team Freya for kill of Team Odin
        for (set .@x, 0; .@x < 1; set .@x, .@x + 1){
            detachrid; //detach killer rid
            attachrid($OdinR[.@x]);
            getitem 607, 50; //reward for winning the round
            warp "SavePoint",0,0;
            detachrid;            
        }    
        callsub OnClear;
    }    
}
end;
}
Edited by PandaRapesHamster
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

Will look at this when I get inside the office. Awesome addons :D

And oh, please post your txt file :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.02
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

NPC actually does not display an error on the mapserver which is what makes it a formidable error /panic
 

Issue with my version:
 - The arrays are being registered, however the check for total players/online players kicks in even if the correct number of players are online and both are online /hum

 

Pastebin: http://pastebin.com/Nya7kzsQ

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

i think the order of script is confused,

 

1. event session runing should be check when player begin to talk to the npc, instead checking if there is player on the map i think it better to set variable when event is starting

2. after event session checked then script should be checking either team has registered participant, if there... script will check if the player that talking to npc is in the either team or not and give menu to transfer to other team or leave the event

3. the script isn't using battle ground system, so it posible player killing his/her member team, what if this happen ? the current script not checking the killer and killed is the same member or not

 

 

this is the script i re-write from yours, not included kill check

// ------------------------------------------------------------------------------------------
// ------ rAthena Script Release
// Title: PvP [4v4] Rewrite
// Author: jezznar
// Version: 1.0 Jezznar
// Search for "getitem" to change rewards and their quantity
// ------------------------------------------------------------------------------------------
prontera,145,186,6	script	Party Battle Recruiter	416,{
	set .@npc_name$, "[^FF0000Party Battle Recruiter^000000]";
	mes .@npc_name$;
	if (.EventInit) { // Check if there is an on-going session
		mes .@npc_name$; 
		mes "There appears to be a match currently in session. Check back momentarily."; 
		close; 
	}
	// Check if the player have been registered and give menu to transfer to other team or leave the event
	if (getarraysize($@Odin_aid) || getarraysize($@Freya_aid)) 
		callsub RegisteredCheck, getcharid(3), getcharid(0);
	mes "Would you like to register for a 4 versus 4 Party Battle?";
	next;
	if (select("Yes:No") == 2) {
		mes .@npc_name$;
		mes callfunc("F_Bye");
		close;
	}
	mes .@npc_name$;
	mes "Which side are you going to play for?";
	next;
	// Odin = 1, Freya = 2
	set .@s, select("Odin ("+(getarraysize($@Odin_aid))+"/"+.TeamCount+"):Freya ("+(getarraysize($@Freya_aid))+"/"+.TeamCount+")");
	if (!$@Odin_aid && !$@Freya_aid && !.OnGMStart) {
		announce "The "+.EventName$+" Event has been triggered by "+strcharinfo(0)+"! Join now!",bc_all;
		initnpctimer;
	}
	if (.@s == 1 && getarraysize($@Odin_aid) < .TeamCount) {
		setarray $@Odin_aid[getarraysize($@Odin_aid)], getcharid(3);
		setarray $@Odin_cid[getarraysize($@Odin_cid)], getcharid(0);
	} else if (.@s == 2 && getarraysize($@Freya_aid) < .TeamCount) {
		setarray $@Freya_aid[getarraysize($@Freya_aid)], getcharid(3);
		setarray $@Freya_cid[getarraysize($@Freya_cid)], getcharid(0);
	} else {
		mes .@npc_name$;
		mes .TeamName$[.@s]+" team is full.";
		close;
	}
	npctalk strcharinfo(0)+" has entered the round on "+.TamName$[.@s]+"'s Side.";
	callsub ReadyCheck, getarraysize($@Odin_aid), getarraysize($@Freya_aid);
	close;

RegisteredCheck:
	for (set .@i, 0; .@i < getarraysize($@Odin_aid); set .@i, .@i +1)
		if ($@Odin_aid[.@i] == getarg(0)) setarray .@Registered, 1, .@i;
	for (set .@i, 0; .@i < getarraysize($@Freya_aid); set .@i, .@i +1)
		if ($@Freya_aid[.@i] == getarg(0)) setarray .@Registered, 2, .@i;
	if (getarraysize(.@Registered)) {
		mes "You are already registered in the "+.TeamName$[.@Registered[0]]+" Team.";
		next;
		if (select("~ Transfer to "+((.@Registered[0] == 1)?"Freya":"Odin")+" Team:~ Leave event") == 1) {
			if (.@Registered[0] == 1) {
				if (getarraysize($@Freya_aid) >= .TeamCount) {
					mes .@npc_name$;
					mes "I'm sorry we can't transfer you to Odin team because it's full";
					close;
				}
				deletearray $@Odin_aid[0], .@Registered[1];
				deletearray $@Odin_cid[0], .@Registered[1];
				setarray $@Freya_aid[getarraysize($@Freya_aid)], getcharid(3);
				setarray $@Freya_cid[getarraysize($@Freya_cid)], getcharid(0);
			} else {
				if (getarraysize($@Odin_aid) >= .TeamCount) {
					mes .@npc_name$;
					mes "I'm sorry we can't transfer you to Freya team because it's full";
					close;
				}
				deletearray $@Freya_aid[0], .@Registered[1];
				deletearray $@Freya_cid[0], .@Registered[1];
				setarray $@Odin_aid[getarraysize($@Odin_aid)], getcharid(3);
				setarray $@Odin_cid[getarraysize($@Odin_cid)], getcharid(0);
			}
			mes .@npc_name$;
			mes "You have been transfered to "+((.@Registered[0] == 1)?"Freya":"Odin")+" Team.";
			close;
		}
		if (.@Registered[0] == 1) {
			deletearray $@Odin_aid[0], .@Registered[1];
			deletearray $@Odin_cid[0], .@Registered[1];
		} else {
			deletearray $@Freya_aid[0], .@Registered[1];
			deletearray $@Freya_cid[0], .@Registered[1];
		}
		mes .@npc_name$;
		mes "You are leaving the event";
		close;
	} else
		return;

ReadyCheck:
	if(getarg(0) >= .TeamCount && getarg(1) >= .TeamCount) {  
		stopnpctimer;
		callsub OnEventStart;
		close;
	}
	return;
	
OnEventStart:
	set .EventInit, 1;
	set $@OdinCount, .TeamCount; // Set team alive player counter
	set $@FreyaCount, .TeamCount; // Set team alive player counter
	npctalk "Both teams have been filled. All participants currently logged in will be transferred to the arena in ten seconds.";
	sleep 10000;
	//Warp all participants to the event place - guild_vs3
	for(set .@i,0; .@i < .TeamCount; set .@i, .@i++){
		if (isloggedin($@Odin_aid[.@i], $@Odin_cid[.@i])) setarray .Participant[getarraysize(.Participant)], getcharid(0);
		if (isloggedin($@Freya_aid[.@i], $@Freya_aid[.@i])) setarray .Participant[getarraysize(.Participant)], getcharid(0);
	}
	if (getarraysize(.Participant) < (.TeamCount*2)) callsub FailLack;
	for (set .@x, 0; .@x < .TeamCount; set .@x, .@x + 1) {
		warpchar "guild_vs3",18,50,$@Odin_cid[.@x];
		warpchar "guild_vs3",83,50,$@Freya_cid[.@x];
	}
	end;

OnTimer10000:
	npctalk "Ten seconds have passed. Entry to the round ends in 20 seconds.";
	end;

OnTimer20000:
	npctalk "Twenty seconds have passed. Entry to the round ends in 10 seconds.";
	end;

OnTimer30000:
	npctalk "Thirty seconds have passed and thus I have canceled the round.";
	stopnpctimer;
	callsub OnClear;
	end;

FailLack:
	announce .EventName$+" Event has been canceled due to a missing participant, Event has been reseted please register again.",0;
OnClear:
	set .EventInit, 0;
	if (.OnGMStart) set .OnGMStart, 0;
	deletearray $@Odin_aid;
	deletearray $@Odin_cid;
	deletearray $@Freya_aid; 
	deletearray $@Freya_cid;
	deletearray .Participant;
	end;
	
OnAtCommand:
	if (.@atcmd_parameters$[0] == "on") {
		if (.EventInit) {
			message strcharinfo(0), "Event is running";
			end;
		}
		initnpctimer;
		announce "A GM has started a "+.EventName$+" Event! Join now!",bc_all;
		set .OnGMStart, 1;
	} else if (.@atcmd_parameters$[0] == "off") {
		if (!.EventInit) {
			message strcharinfo(0), "Event isn't running";
			end;
		}
		stopnpctimer;
		announce "A GM has stopped a "+.EventName$+" Event!",bc_all;
		for (set .@x, 0; .@x < .TeamCount; set .@x, .@x + 1) { // warp all characters out if a session was on-going
			warpchar "prontera",156,191,$@Odin_cid[.@x];
			warpchar "prontera",156,191,$@Freya_cid[.@x];
		}
		callsub OnClear;
	}
	end;
	
OnPCLogOutEvent:
	for (set .@i, 0; .@i < getarraysize($@Odin_aid); set .@i, .@i +1)
		if ($@Odin_aid[.@i] == getarg(0)) setarray .@LogOutRemove, 1, .@i;
	for (set .@i, 0; .@i < getarraysize($@Freya_aid); set .@i, .@i +1)
		if ($@Freya_aid[.@i] == getarg(0)) setarray .@LogOutRemove, 2, .@i;
	if (!getarraysize(.@LogOutRemove)) end;
	if (.@LogOutRemove[0] == 1) {
		deletearray $@Odin_aid[0], .@Registered[1];
		deletearray $@Odin_cid[0], .@Registered[1];
	} else {
		deletearray $@Freya_aid[0], .@Registered[1];
		deletearray $@Freya_cid[0], .@Registered[1];
	}
	end;
	
OnInit:
	getmapxy .@map$, .@x, .@y, 1;
	if ( .@map$ == "" ) {
		bindatcmd "4v4", strnpcinfo(0)+"::OnAtCommand";
		set .OnGMStart, 0;
		set .TeamCount, 3; // Set how many player on either team to start, ex: if 3 vs 3 set to 3
		set .EventName$, "PvP ["+.TeamCount+"vs"+.TeamCount+"]";
		setarray .TeamName$[1], "Odin", "Freya";
	} else {
		announce "Sorry for the inconvenience, the administrator reloaded the script event",0; 
		deletearray $@Odin_aid;
		deletearray $@Odin_cid;
		deletearray $@Freya_aid; 
		deletearray $@Freya_cid;
		deletearray .Participant;
		mapwarp "guild_vs3", "prontera", 156, 191;
	}
	end;
	
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

 

i think the order of script is confused,

 

1. event session runing should be check when player begin to talk to the npc, instead checking if there is player on the map i think it better to set variable when event is starting

2. after event session checked then script should be checking either team has registered participant, if there... script will check if the player that talking to npc is in the either team or not and give menu to transfer to other team or leave the event

3. the script isn't using battle ground system, so it posible player killing his/her member team, what if this happen ? the current script not checking the killer and killed is the same member or not

 

 

this is the script i re-write from yours, not included kill check

// ------------------------------------------------------------------------------------------
// ------ rAthena Script Release
// Title: PvP [4v4] Rewrite
// Author: jezznar
// Version: 1.0 Jezznar
// Search for "getitem" to change rewards and their quantity
// ------------------------------------------------------------------------------------------
prontera,145,186,6	script	Party Battle Recruiter	416,{
	set .@npc_name$, "[^FF0000Party Battle Recruiter^000000]";
	mes .@npc_name$;
	if (.EventInit) { // Check if there is an on-going session
		mes .@npc_name$; 
		mes "There appears to be a match currently in session. Check back momentarily."; 
		close; 
	}
	// Check if the player have been registered and give menu to transfer to other team or leave the event
	if (getarraysize($@Odin_aid) || getarraysize($@Freya_aid)) 
		callsub RegisteredCheck, getcharid(3), getcharid(0);
	mes "Would you like to register for a 4 versus 4 Party Battle?";
	next;
	if (select("Yes:No") == 2) {
		mes .@npc_name$;
		mes callfunc("F_Bye");
		close;
	}
	mes .@npc_name$;
	mes "Which side are you going to play for?";
	next;
	// Odin = 1, Freya = 2
	set .@s, select("Odin ("+(getarraysize($@Odin_aid))+"/"+.TeamCount+"):Freya ("+(getarraysize($@Freya_aid))+"/"+.TeamCount+")");
	if (!$@Odin_aid && !$@Freya_aid && !.OnGMStart) {
		announce "The "+.EventName$+" Event has been triggered by "+strcharinfo(0)+"! Join now!",bc_all;
		initnpctimer;
	}
	if (.@s == 1 && getarraysize($@Odin_aid) < .TeamCount) {
		setarray $@Odin_aid[getarraysize($@Odin_aid)], getcharid(3);
		setarray $@Odin_cid[getarraysize($@Odin_cid)], getcharid(0);
	} else if (.@s == 2 && getarraysize($@Freya_aid) < .TeamCount) {
		setarray $@Freya_aid[getarraysize($@Freya_aid)], getcharid(3);
		setarray $@Freya_cid[getarraysize($@Freya_cid)], getcharid(0);
	} else {
		mes .@npc_name$;
		mes .TeamName$[.@s]+" team is full.";
		close;
	}
	npctalk strcharinfo(0)+" has entered the round on "+.TamName$[.@s]+"'s Side.";
	callsub ReadyCheck, getarraysize($@Odin_aid), getarraysize($@Freya_aid);
	close;

RegisteredCheck:
	for (set .@i, 0; .@i < getarraysize($@Odin_aid); set .@i, .@i +1)
		if ($@Odin_aid[.@i] == getarg(0)) setarray .@Registered, 1, .@i;
	for (set .@i, 0; .@i < getarraysize($@Freya_aid); set .@i, .@i +1)
		if ($@Freya_aid[.@i] == getarg(0)) setarray .@Registered, 2, .@i;
	if (getarraysize(.@Registered)) {
		mes "You are already registered in the "+.TeamName$[.@Registered[0]]+" Team.";
		next;
		if (select("~ Transfer to "+((.@Registered[0] == 1)?"Freya":"Odin")+" Team:~ Leave event") == 1) {
			if (.@Registered[0] == 1) {
				if (getarraysize($@Freya_aid) >= .TeamCount) {
					mes .@npc_name$;
					mes "I'm sorry we can't transfer you to Odin team because it's full";
					close;
				}
				deletearray $@Odin_aid[0], .@Registered[1];
				deletearray $@Odin_cid[0], .@Registered[1];
				setarray $@Freya_aid[getarraysize($@Freya_aid)], getcharid(3);
				setarray $@Freya_cid[getarraysize($@Freya_cid)], getcharid(0);
			} else {
				if (getarraysize($@Odin_aid) >= .TeamCount) {
					mes .@npc_name$;
					mes "I'm sorry we can't transfer you to Freya team because it's full";
					close;
				}
				deletearray $@Freya_aid[0], .@Registered[1];
				deletearray $@Freya_cid[0], .@Registered[1];
				setarray $@Odin_aid[getarraysize($@Odin_aid)], getcharid(3);
				setarray $@Odin_cid[getarraysize($@Odin_cid)], getcharid(0);
			}
			mes .@npc_name$;
			mes "You have been transfered to "+((.@Registered[0] == 1)?"Freya":"Odin")+" Team.";
			close;
		}
		if (.@Registered[0] == 1) {
			deletearray $@Odin_aid[0], .@Registered[1];
			deletearray $@Odin_cid[0], .@Registered[1];
		} else {
			deletearray $@Freya_aid[0], .@Registered[1];
			deletearray $@Freya_cid[0], .@Registered[1];
		}
		mes .@npc_name$;
		mes "You are leaving the event";
		close;
	} else
		return;

ReadyCheck:
	if(getarg(0) >= .TeamCount && getarg(1) >= .TeamCount) {  
		stopnpctimer;
		callsub OnEventStart;
		close;
	}
	return;
	
OnEventStart:
	set .EventInit, 1;
	set $@OdinCount, .TeamCount; // Set team alive player counter
	set $@FreyaCount, .TeamCount; // Set team alive player counter
	npctalk "Both teams have been filled. All participants currently logged in will be transferred to the arena in ten seconds.";
	sleep 10000;
	//Warp all participants to the event place - guild_vs3
	for(set .@i,0; .@i < .TeamCount; set .@i, .@i++){
		if (isloggedin($@Odin_aid[.@i], $@Odin_cid[.@i])) setarray .Participant[getarraysize(.Participant)], getcharid(0);
		if (isloggedin($@Freya_aid[.@i], $@Freya_aid[.@i])) setarray .Participant[getarraysize(.Participant)], getcharid(0);
	}
	if (getarraysize(.Participant) < (.TeamCount*2)) callsub FailLack;
	for (set .@x, 0; .@x < .TeamCount; set .@x, .@x + 1) {
		warpchar "guild_vs3",18,50,$@Odin_cid[.@x];
		warpchar "guild_vs3",83,50,$@Freya_cid[.@x];
	}
	end;

OnTimer10000:
	npctalk "Ten seconds have passed. Entry to the round ends in 20 seconds.";
	end;

OnTimer20000:
	npctalk "Twenty seconds have passed. Entry to the round ends in 10 seconds.";
	end;

OnTimer30000:
	npctalk "Thirty seconds have passed and thus I have canceled the round.";
	stopnpctimer;
	callsub OnClear;
	end;

FailLack:
	announce .EventName$+" Event has been canceled due to a missing participant, Event has been reseted please register again.",0;
OnClear:
	set .EventInit, 0;
	if (.OnGMStart) set .OnGMStart, 0;
	deletearray $@Odin_aid;
	deletearray $@Odin_cid;
	deletearray $@Freya_aid; 
	deletearray $@Freya_cid;
	deletearray .Participant;
	end;
	
OnAtCommand:
	if (.@atcmd_parameters$[0] == "on") {
		if (.EventInit) {
			message strcharinfo(0), "Event is running";
			end;
		}
		initnpctimer;
		announce "A GM has started a "+.EventName$+" Event! Join now!",bc_all;
		set .OnGMStart, 1;
	} else if (.@atcmd_parameters$[0] == "off") {
		if (!.EventInit) {
			message strcharinfo(0), "Event isn't running";
			end;
		}
		stopnpctimer;
		announce "A GM has stopped a "+.EventName$+" Event!",bc_all;
		for (set .@x, 0; .@x < .TeamCount; set .@x, .@x + 1) { // warp all characters out if a session was on-going
			warpchar "prontera",156,191,$@Odin_cid[.@x];
			warpchar "prontera",156,191,$@Freya_cid[.@x];
		}
		callsub OnClear;
	}
	end;
	
OnPCLogOutEvent:
	for (set .@i, 0; .@i < getarraysize($@Odin_aid); set .@i, .@i +1)
		if ($@Odin_aid[.@i] == getarg(0)) setarray .@LogOutRemove, 1, .@i;
	for (set .@i, 0; .@i < getarraysize($@Freya_aid); set .@i, .@i +1)
		if ($@Freya_aid[.@i] == getarg(0)) setarray .@LogOutRemove, 2, .@i;
	if (!getarraysize(.@LogOutRemove)) end;
	if (.@LogOutRemove[0] == 1) {
		deletearray $@Odin_aid[0], .@Registered[1];
		deletearray $@Odin_cid[0], .@Registered[1];
	} else {
		deletearray $@Freya_aid[0], .@Registered[1];
		deletearray $@Freya_cid[0], .@Registered[1];
	}
	end;
	
OnInit:
	getmapxy .@map$, .@x, .@y, 1;
	if ( .@map$ == "" ) {
		bindatcmd "4v4", strnpcinfo(0)+"::OnAtCommand";
		set .OnGMStart, 0;
		set .TeamCount, 3; // Set how many player on either team to start, ex: if 3 vs 3 set to 3
		set .EventName$, "PvP ["+.TeamCount+"vs"+.TeamCount+"]";
		setarray .TeamName$[1], "Odin", "Freya";
	} else {
		announce "Sorry for the inconvenience, the administrator reloaded the script event",0; 
		deletearray $@Odin_aid;
		deletearray $@Odin_cid;
		deletearray $@Freya_aid; 
		deletearray $@Freya_cid;
		deletearray .Participant;
		mapwarp "guild_vs3", "prontera", 156, 191;
	}
	end;
	
}

 

Thanks for that, I was actually fixing it up before I read yours and adapted your idea #1. :)

and by the way, I used cleararray instead of deletearray. 

 

updated to v1.2

please see the first post :)

Edited by jezznar
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

maybe you want to add safe fail check on the atcommand, to prevent they typed twice the command, could init twice npc timer and what about accidentally killing member of the same team ?

OnAtCommand:
	if (.@atcmd_parameters$[0] == "on"){
		initnpctimer;
		announce "A GM has started a PvP["+.NumPlayers+"v"+.NumPlayers+"] Event! Join now!",bc_all;
		set .OnGMStart, 1;
	} else if (.@atcmd_parameters$[0] == "off"){
		stopnpctimer;
		announce "A GM has stopped a PvP["+.NumPlayers+"v"+.NumPlayers+"] Event!",bc_all;
		for (set .@x, 0; .@x < 1; set .@x, .@x + 1) { // warp all characters out if a session was on-going
			warpchar "prontera",156,191,$Odin[.@x];
			warpchar "prontera",156,191,$Freya[.@x];
		}	
		callsub OnClear;
		set .OnGMStart, 0;
	}
end;
Edited by Litro Endemic
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

maybe you want to add safe fail check on the atcommand, to prevent they typed twice the command, could init twice npc timer and what about accidentally killing member of the same team ?

OnAtCommand:
	if (.@atcmd_parameters$[0] == "on"){
		initnpctimer;
		announce "A GM has started a PvP["+.NumPlayers+"v"+.NumPlayers+"] Event! Join now!",bc_all;
		set .OnGMStart, 1;
	} else if (.@atcmd_parameters$[0] == "off"){
		stopnpctimer;
		announce "A GM has stopped a PvP["+.NumPlayers+"v"+.NumPlayers+"] Event!",bc_all;
		for (set .@x, 0; .@x < 1; set .@x, .@x + 1) { // warp all characters out if a session was on-going
			warpchar "prontera",156,191,$Odin[.@x];
			warpchar "prontera",156,191,$Freya[.@x];
		}	
		callsub OnClear;
		set .OnGMStart, 0;
	}
end;

 

Added to Currently Working At list, Thanks :)

4. Player will not be able to kill a player on the same team [Suggested by Litro Endemic]
5. Safe failcheck OnAtCommand [Suggested by Litro Endemic]

v1.3 Released

- Quick fix for event not being able to function correctly because of mishandled variables

- Optimized OnEventStart algorithm

- Optimized and Improved Logged in/Logged Off Checking [suggested by PandaLovesHamster]

- Takes off logged off players from the roster instead of resetting the whole recruitment process [Response to the question of PandaLovesHamster]

- Took off OnFailLack

- Added OnPCLoginEvent and OnPCLogoutEvent

- Added GM OnAtCommand Safe failcheck [suggested by Litro Endemic]

Changelog:

v1.4 by Me

- Will be tagged as stable if noone complains about any bug
- Thoroughly fixed a lot of logical and semantic errors
- Optimized a lot of codes
- Fixed a lot of exploits and bugs
- Made it functionally working 
- Demo video uploaded
Edited by jezznar
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.02
  • Content Count:  452
  • Reputation:   33
  • Joined:  12/18/14
  • Last Seen:  

It might just be me, but I get a bunch of errors when it fails to start due to a missing participant.

http://prntscr.com/8n4mv1

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

It might just be me, but I get a bunch of errors when it fails to start due to a missing participant.

http://prntscr.com/8n4mv1

I think that is because.of the algorithm used for checking online/offline participants which is through attachrid/detachrid. I'll try to fix it when I get home later. You can comment out that portion of the code and still make it work but the cons is that it will start with ot without checking if both sides have all their players online

//edit

Take off all the 'detachrid' in the code. That should fix it.

Edited by jezznar
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

Did you do what I said from the previous post? :)

 

// edit

v1.5 Released

- Will be tagged as stable if noone complains about any bug
- Fixed the "fatal error: player not attached problem" caused by @MyTeam
- Participant will be taken as a casualty if he logs out when the session is on-going
- Added mapflags and can be modified through .@mapflags
- Tested and results were without errors, bugs, and exploits.
Edited by jezznar
Link to comment
Share on other sites

  • 1 year later...

  • Group:  Members
  • Topic Count:  64
  • Topics Per Day:  0.02
  • Content Count:  148
  • Reputation:   0
  • Joined:  03/06/15
  • Last Seen:  

up for friendlyfire? 

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
Reply to this topic...

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