Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2013, 02:45 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default Save pvp state on zone in.

Hello everyone. I am having an issue trying to save the clients pvp state upon zone in so when they leave the zone it will revert them back to their pre-zone in pvp state.

So lets say. your pvp state is 0 or off. You zone into a pvp only zone, lets say ecommons. I need it to save their state of pvp 0, change them to pvp 1, then when they zone out reload the pvp 0. I figured I needed to use qglobals to store the intial pvp state but I cannot get it right. It either doesn't work other times crashes the zone.

Here is what I have so far.
Code:
sub EVENT_ENTERZONE {

if($client->GetPVP() == $client->GetPVP(1){ 
quest::setglobal("PvPState", $PvP, 2, "F");
}

$client->SetPVP(1);
$client->Message(15, "It's time for some Mischief, kill or be killed!");
}


sub EVENT_ZONE {

if $PvP == $client->GetPVP(0) {
$client->SetPVP(0);
}
 
}

Thanks guys!

Fig
__________________
Reply With Quote
  #2  
Old 06-14-2013, 03:29 PM
Dunge0nMastr
Hill Giant
 
Join Date: Oct 2002
Location: Rockville, MD
Posts: 124
Default

if($client->GetPVP() == $client->GetPVP(1)

think you need an extra )
if($client->GetPVP() == $client->GetPVP(1)) {
__________________
Bront -Server Admin/Owner and Lead Quest Dev for Kildrukaun's Prophecy
http://kpemu.com/
Reply With Quote
  #3  
Old 06-14-2013, 05:56 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Thank you for noticing that. changed it but its still not working. here is a newer try and even more a mess. I am sure im over complicating things but still learning lol.


Code:
sub EVENT_ENTERZONE {
my $on = $client->GetPVP(1);
my $off = $client->GetPVP(0);

if($client->GetPVP() == $client->GetPVP(1)){ 
quest::setglobal("PvPState", $PvP, 2, "F");
}
if($client->GetPVP() == $client->GetPVP(0)){ 
quest::setglobal("PvPState2", $PvP2, 2, "F");

$client->SetPVP(1);
$client->Message(15, "It's time for some Mischief, kill or be killed!");
}


sub EVENT_ZONE {

if ($PvP == $on) {
$client->SetPVP(1);
}

if ($PvP2 == $off) {
$client->SetPVP(0);
}

 
}
__________________
Reply With Quote
  #4  
Old 06-14-2013, 06:48 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Sir, from your code it doesn't look like you're assigning $PvP or $PvP2 to a value, also I don't believe it's necessary to do this 'if($client->GetPVP() == $client->GetPVP(0))' I believe you can do 'if($client->GetPVP() == 0)', you must pre-define $PvP and $PvP2 before you're capable of using them. you were Ymissing a curly to close sub EVENT_ENTERZONE, also, you must re-define each variable for a different event unless you define it globally outside of the sub event.
Reply With Quote
  #5  
Old 06-14-2013, 06:52 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

I had found the curly. Thank you. I agree with you, im not assigning the values right or something. K ill move the variables. That makes sense..
Will update.
__________________
Reply With Quote
  #6  
Old 06-15-2013, 12:52 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Fixed heh
Code:
sub EVENT_ENTERZONE {
	quest::setglobal("PvPState",$client->GetPVP(),5,"F");  #Adds their PVPstate to gloabl
	$client->SetPVP(1);
}

sub EVENT_ZONE {
	if(defined $qglobals{"PvPState"} && $qglobals{"PvPState"}==1)   
	{
		$client->SetPVP(1);   #Player was already PVP before entering zone will remain PVP on zone out
	}
	else
	{
		$client->SetPVP(0);  #This player was not PVP flagged when zoning in
	}

}


Here is the code I use for a PVP zone...

Limits the zone to a single character in the zone per IP

Requires that the zone is STATIC though

Code:
sub EVENT_ENTERZONE {
	my $playerip = $client->GetIP();
	@pvplist;
	if ( grep { $_ eq $playerip } @pvplist )
	{
		
		$client->Message(315,"YOU MAY ONLY HAVE ONE CHARACTER IN THIS ZONE!");
		push(@pvplist, "$playerip");
		$client->MovePC(348, 1.8, 1.6, -22.8, 187);
		return;
	}
	push(@pvplist, "$playerip");
	$client->SetPVP(1);
}

sub EVENT_ZONE {
	my $playerip = $client->GetIP();
	my $count = 0;
	foreach $pvp_player (@pvplist) 
	{
	next unless $pvp_player = $playerip;
	$count++;
	}

	if ($count >= 2)
	{
		@pvplist = grep {$_ ne $playerip} @pvplist;
		push(@pvplist, "$playerip");  #Add the IP back to list since there are 2 of the same IP
	}
	else
	{
		@pvplist = grep {$_ ne $playerip} @pvplist;
	}
	$client->SetPVP(0);
}

sub EVENT_DISCONNECT {
	my $playerip = $client->GetIP();
	my $count = 0;
	foreach $pvp_player (@pvplist) 
	{
	next unless $pvp_player = $playerip;
	$count++;
	}

	if ($count >= 2)
	{
		@pvplist = grep {$_ ne $playerip} @pvplist;
		push(@pvplist, "$playerip");  #Add the IP back to list since there are 2 of the same IP
	}
	else
	{
		@pvplist = grep {$_ ne $playerip} @pvplist;
	}
}
Reply With Quote
  #7  
Old 06-15-2013, 01:09 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Thank you for the input. I'm needing the player to return to the pvp state (derp just saw YOUR edit after my extensive editing lol) they were before they entered the contested zone. To paint the picture. I am having mischief be a pvp zone. upon entering you are forced pvp. now when you leave the zone I need it to return the player to their previous pvpstate, so if they were 0 then make them 0 but if they were state 1, leave them pvp. I was trying todo it in the player.pl in folder mischiefplane but due to not being able to share the global from EVENT ENTERZONE to EVENT ZONE, I believe it needs to be handled in global_player.

this is the current run after a few hours. it still doesn't initialize lol.
Oh c0ncrete I came across a post about perl -c filename.pl love it!

Code:
sub EVENT_ENTERZONE {

if(!defined $qglobals{PvPState}) {

if($client->GetPVP() == 1) {
quest::setglobal("PvPState", $PvP, 4, "F");
$client->Message(15, "pvp saved!");

	if($zonesn =~ /^mischiefplane$/) {
	$client->SetPVP(1);
	$client->Message(15, "It's time for some Mischief, kill or be killed");
	}

	elsif ($PvP == $client->GetPVP(1)) {
	$client->SetPVP(1);
	$client->Message(15, "pvp on!");
	}
	else {
	$client->SetPVP(0);
	$client->Message(15, "pvp off!");
	}

}

}

}
__________________
Reply With Quote
  #8  
Old 06-15-2013, 01:18 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

damn you can pull qglobals between different events

hmm im still crashing, gonna mess with it a few minutes!

Thanks a ton!
__________________
Reply With Quote
  #9  
Old 06-15-2013, 01:31 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Its mostly working besides when you zone out, its just turning pvp off, I turned pvp on, zoned into a pvp zone, then zoned out and went blue.
we almost got it though


Code:
sub EVENT_ENTERZONE {
	quest::setglobal("PvPState",$client->GetPVP(),5,"F");  #Adds their PVPstate to gloabl

	if($zonesn =~ /^mischiefplane$/) {
	$client->SetPVP(1);
	$client->Message(15, "It's time for some Mischief, kill or be killed");
	}

	
	
	}

sub EVENT_ZONE {
	if(defined $qglobals{"PvPState"} && $qglobals{"PvPState"}==1)   
	{
		$client->SetPVP(1);   #Player was already PVP before entering zone will remain PVP on zone out
	}
	else
	{
		$client->SetPVP(0);  #This player was not PVP flagged when zoning in
	}

}
__________________
Reply With Quote
  #10  
Old 06-15-2013, 01:51 AM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Code:
[06.15. - 01:47:06] Argument "" isn't numeric in numeric eq (==) at quests/templates/global_player.pl line 29.
Code:
	if(defined $qglobals{"PvPState"} && $qglobals{"PvPState"}==1)
Ill work on it some more tomorrow.
Thanks again for the help!
__________________
Reply With Quote
  #11  
Old 06-15-2013, 02:49 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Code:
sub EVENT_ENTERZONE {
	quest::setglobal("PvPState",$client->GetPVP(),5,"F");
	$client->SetPVP(1);
}

sub EVENT_ZONE {
	if(defined $qglobals{"PvPState"} && $qglobals{"PvPState"}==1)
	{
		$client->SetPVP(1);
	}
	else
	{
		$client->SetPVP(0);
	}
}


This works just fine for me .. hmmm
Reply With Quote
  #12  
Old 06-15-2013, 06:04 AM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,743
Default

If I had to guess I'd say the qglobal may have been set weird from previous attempts to get this working. You might try deleting it and see if it works better after that.
Reply With Quote
  #13  
Old 06-15-2013, 12:11 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

roger, on it. Will update after testing
Thanks Lerxst
__________________
Reply With Quote
  #14  
Old 06-15-2013, 12:47 PM
Figback65
Discordant
 
Join Date: Aug 2009
Location: 2131231231
Posts: 255
Default

Hmm I dunno what I am doing wrong then. These are my steps.

I deleted the qglobals for the quest in the table
#reloadpl
#pvp off
#zone ecommons
(PVP Turns on)
#zone nro
(PVP Stays On when intial was #pvp off)
#zone sro
(PVP Still on)
NateDogs Version
Code:
sub EVENT_ENTERZONE {
	quest::setglobal("PvPState",$client->GetPVP(),5,"F");
	$client->SetPVP(1);
}

sub EVENT_ZONE {
	if(defined $qglobals{"PvPState"} && $qglobals{"PvPState"}==1)
	{
		$client->SetPVP(1);
	}
	else
	{
		$client->SetPVP(0);
	}
}

Steps with my Version
I again clear Qglobals.
#reloadpl
#pvp off
#zone ecommons
(PVP Still off)
#zone nro
(pvp still off)
#zone mischiefplane
(PVP Turns on)
#zone ecommons
(PVP Turns Off) Seems to work but false)

Again Clear qglobals
#reloadpl
#pvp on
#zone ecommons
(PVP Turns off)

My Version
Code:
sub EVENT_ENTERZONE {
	quest::setglobal("PvPState",$client->GetPVP(),5,"F");  #Adds their PVPstate to gloabl

	if($zonesn =~ /^mischiefplane$/) {
	$client->SetPVP(1);
	$client->Message(15, "It's time for some Mischief, kill or be killed");
	}

	
	
	}

sub EVENT_ZONE {
	if(defined $qglobals{"PvPState"} && $qglobals{"PvPState"}==1)   
	{
		$client->SetPVP(1);   #Player was already PVP before entering zone will remain PVP on zone out
	}
	else
	{
		$client->SetPVP(0);  #This player was not PVP flagged when zoning in
	}

}

In Conclusion: My version is always pvpoff on zoneout, Nates is always pvpon with zonein.

If this makes sense lol
__________________
Reply With Quote
  #15  
Old 06-15-2013, 01:25 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

On yours..

If you clear globals ("PvPState" = 0) and use #pvp on, when will EVENT_ZONE ever catch $qglobals("PvPState") == 1?

Shouldn't you check $client to set $qglobals on the way out, instead of vica-versa?
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:52 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3