Welcome
Welcome to the Official<strong>World of Phaos</strong>Forums.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining the World of Phaos community for free, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join the World of Phaos community today</a>!

PVP script

Updated or created a new script or part of WoP and you think the world should know, post it here and you may well see it in the next release of Phaos.
(Remember to keep all code clean and readable)

Moderators: zeke, Aradan

PVP script

Postby Amrac » Tue Aug 12, 2008 12:11 pm

Hi,
I change a little the script and now we can pvp, sombebody want the script?
Amrac
Level 1
 
Posts: 19
Joined: Thu Aug 07, 2008 11:53 pm

Postby Altfuture » Tue Aug 12, 2008 6:17 pm

I want it !!!

:P

Can you message me or email me please

tmcdonnell at email.com


Thanks
Altfuture
Level 2
 
Posts: 27
Joined: Fri Feb 29, 2008 9:00 pm

Postby Amrac » Wed Aug 13, 2008 1:25 am

Its not a big deal (<- we can say that in English?)

I cant send you my script directly because i did some other change and it will not work on the standard version of World of Phaos.

So, I will explain you what you need to change.
Find this: (Line 190 in combat.php)
Code: Select all
if (!count($list)) {


replace by:
Code: Select all
if (!count($list) && !isset($_GET['attaquer']) && $_SESSION['attaquePlayer'] == 0) {


Find this: (around line 199)
Code: Select all
    if(!@$_SESSION['opponent_id']){
        $_SESSION['opponent_id']= $list[0];
    }


Replace by:
Code: Select all
    if(!@$_SESSION['opponent_id']){
   
   if(isset($_GET['attaquer']))
      {
      $_SESSION['attaquePlayer'] = $_GET['attaquer'];
      $list[0]=$_GET['attaquer'];
      }
   else
           $_SESSION['opponent_id']= $list[0];
    }

    if($_SESSION['attaquePlayer'] == $_SESSION['opponent_id'])
   $list[0] = $_SESSION['opponent_id'];


In class_character.php find this:
Code: Select all
   function kill_characterid(){
            $query = "DELETE FROM phaos_characters WHERE id = '".$this->id."'";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

      // FIXME: DBS - this should be changed so items are dropped at location
            $query = "DELETE FROM phaos_char_inventory WHERE username = '".$this->user."'";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
            return 1;
    }


Replace by:
Code: Select all
function kill_characterid(){
   if($this->user == "phaos_npc")
            {
            $query = "DELETE FROM phaos_characters WHERE id = '".$this->id."'";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

      // FIXME: DBS - this should be changed so items are dropped at location
            $query = "DELETE FROM phaos_char_inventory WHERE username = '".$this->user."'";
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
            return 1;
     }
   else   // when dead, go to Gornath (easy city of undead) to start over
      {
      $query = "UPDATE phaos_characters set location='4072'  WHERE id = '".$this->id."'";
      $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
      }
            return 1;
       }


In town.php find: (line 110)
Code: Select all
<tr>
   <td align="left">
      <br><br>
      <b><? echo $lang_town["ot_on"]; ?></b><br>
<? echo who_is_online($char_loc) ?>
      <br><br>
      <b><? echo $lang_town["ot_of"]?></b><br>
<? echo who_is_offline($char_loc) ?>
   </td>
</tr>


Replace by:
Code: Select all
<tr>
   <td align="left">
      <br><br>
      <b><? echo $lang_town["ot_on"]; ?></b><br>
<? echo who_is_online($char_loc,true) ?>
      <br><br>
      <b><? echo $lang_town["ot_of"]?></b><br>
<? echo who_is_offline($char_loc,true) ?>
   </td>
</tr>


In global.php find the 2 fonctions who_is_online and who_is_offline (line 50):
Code: Select all
function who_is_online($location = '') {
   global $PHP_PHAOS_USER;
   global $lang_glo;
   
   if ($location != '') { $loc = 'location = ' . $location . ' AND '; }
   $current_time = time();
   
   $active_min = $current_time-300;
   $active_max = $current_time+300;
   
   $result = mysql_query("SELECT * FROM phaos_characters WHERE $loc regen_time >= '$active_min' AND regen_time <= '$active_max' AND username != 'phaos_npc' AND username != 'phaos_npc_arena' ORDER by name ASC");
   
   $html='';
   if (mysql_num_rows($result) != 0) {
      while ($row = mysql_fetch_assoc($result)) {
         $html .=  '<font color="#009900">|</font><a href="player_info.php?player_name='. $row['username'] . '" target="_blank">' . $row['name'] .  '</a>';
      }
   } else {
      $html = "<font color=#009900>|</font>".$lang_glo["n_else"];
   }
   return $html . '<font color="#009900">|</font>';
}

function who_is_offline($location = '') {
   global $PHP_PHAOS_USER;
   if ($location != '') { $loc = 'location = ' . $location . ' AND '; }
   $current_time = time();

   $active_min = $current_time-300;
   $active_max = $current_time+300;
   
   $result = mysql_query("SELECT * FROM phaos_characters WHERE $loc regen_time < '$active_min' AND username != 'phaos_npc%' AND username != 'phaos_npc_arena' ORDER by name ASC");
   echo mysql_error();
   
   $html='';
   if (mysql_num_rows($result) != 0) {
      while ($row = mysql_fetch_assoc($result)) {
         $html = '<font color="#009900">|</font><a href="player_info.php?player_name='. $row['username'] . '" target="_blank" style="color=#FFFFFF">' . $row['name'] .  '</a>';
      }
   }
   return $html . '<font color="#009900">|</font>';
}


Replace by:
Code: Select all
function who_is_online($location = '',$attack = false) {
   global $PHP_PHAOS_USER;
   global $lang_glo;
   
   if ($location != '') { $loc = 'location = ' . $location . ' AND '; }
   $current_time = time();
   
   $active_min = $current_time-300;
   $active_max = $current_time+300;
   
   $result = mysql_query("SELECT * FROM phaos_characters WHERE $loc regen_time >= '$active_min' AND regen_time <= '$active_max' AND username != 'phaos_npc' AND username != 'phaos_npc_arena' ORDER by name ASC");
   
   $html='';
   if (mysql_num_rows($result) != 0) {
      while ($row = mysql_fetch_assoc($result)) {
         $html .=  '<font color="#009900">|</font><a href="player_info.php?player_name='. $row['username'] . '" target="_blank">' . $row['name'] .  '</a>';
         if($attack) $html .= ' (<a href="combat.php?attaquer='. $row['id'] . '">Attaquer</a>)';
      }
   } else {
      $html = "<font color=#009900>|</font>".$lang_glo["n_else"];
   }
   return $html . '<font color="#009900">|</font>';
}

function who_is_offline($location = '',$attack = false) {
   global $PHP_PHAOS_USER;
   if ($location != '') { $loc = 'location = ' . $location . ' AND '; }
   $current_time = time();

   $active_min = $current_time-300;
   $active_max = $current_time+300;
   
   $result = mysql_query("SELECT * FROM phaos_characters WHERE $loc regen_time < '$active_min' AND username != 'phaos_npc%' AND username != 'phaos_npc_arena' ORDER by name ASC");
   echo mysql_error();
   
   $html='';
   if (mysql_num_rows($result) != 0) {
      while ($row = mysql_fetch_assoc($result)) {
         $html = '<font color="#009900">|</font><a href="player_info.php?player_name='. $row['username'] . '" target="_blank" style="color=#FFFFFF">' . $row['name'] .  '</a>';
         if($attack) $html.= ' (<a href="combat.php?attaquer='. $row['id'] . '">Attaquer</a>)';
      }
   }
   return $html . '<font color="#009900">|</font>';
}


With this, when a player click on 'Explore' he can attack other player like if they was a mob.

But I must make 3 warnings:
-On my game, i dont use Arena so they cant fight in Arena.
-On my game, i dont use potion/magic attack, so i dont know if it change anything (just try it)
-A player can abuse by camping the respawn

I add a little Historic for my (futur) players, then if they connect and they see somebody killed them, they have the historic who said "At 9AM, [Name] attack you and hit you for [Number] "
If you want, i can explain you how add the historic, its something like 2 little find/replace and one table SQL to inject in the database.

Ps: I'm really sorry for my poor English, you can launch me some tomatoes :oops:
Amrac
Level 1
 
Posts: 19
Joined: Thu Aug 07, 2008 11:53 pm

Postby Aradan » Wed Aug 27, 2008 4:48 am

**Moved here in Scripts.

Many thanks Amrac. :)
Cheers,
-Aradan
World of Phaos Developer
Aradan
WoP Forum Admin
 
Posts: 57
Joined: Thu Sep 27, 2007 12:59 am
Location: UK

Re: PVP script

Postby DrSwiss » Sun Sep 14, 2008 5:00 am

This is a great script! Only problem is that players can fight themselves and earn gold + exp off themselves, thus cheating the system. I tried altering it/adding code in to exempt you from seeing/fighting yourself but failed. If someone can post some code that eliminates you from seeing yourself in town.php or pervent you from fighting yourself in combat/php that would be greatly appreciated.

Cheers!

PS- It feels great being back on these forums after so so long.
User avatar
DrSwiss
Level 2
 
Posts: 20
Joined: Sun Sep 14, 2008 4:56 am

Re: PVP script

Postby DrSwiss » Sat Sep 27, 2008 4:02 pm

Well I fixed it so that you have no incentive to fight yourself anymore, which fixes the major problem with this script since it's easy to cheat. Instead of using it in town.php, however, I added it into player_info.php so that you can check the playerlist and attack any player from there. I did this because there's no point in keeping it location-based with the current scripting since it's still easy to cheat.

Example: You are on the same tile as another player and want to pvp. You enter town.php and see the attack link beside his name. It takes you to this: http://www.website.com/phaos/combat.php?attaquer="X" ("x" represents the player's ID). Now, this works fine, but if you edit the player's number at the end and reload the page you can attack anyone so this whole location thing is thrown out the window. Either the pvp scripting needs to be changed so that it doesn't show the player's ID in the actual link/adress bar or there needs to be an IF statement thrown in to make sure the player cannot attack the other player if they are not on the same location ID.

Just food for thought since this is a great script, just very easy to abuse at the moment.
User avatar
DrSwiss
Level 2
 
Posts: 20
Joined: Sun Sep 14, 2008 4:56 am

Re: PVP script

Postby Rebell » Mon Sep 29, 2008 5:59 am

Hello,

can you post or upload your scritp ?

CYA
... visit my RPG WEBSITE - but its still not finished !
User avatar
Rebell
Level 3
 
Posts: 62
Joined: Sat Aug 09, 2008 4:42 pm
Location: Germany

Re: PVP script

Postby DrSwiss » Mon Sep 29, 2008 8:08 pm

Rebell wrote:Hello,

can you post or upload your scritp ?

CYA


I just made a clone of combat.php that doesn't give out exp nor gold, then had the pvp link to that instead of combat.php. Lazy, yes, but very simple and it solves the problem of players gaining gold and exp from fighting themselves.
User avatar
DrSwiss
Level 2
 
Posts: 20
Joined: Sun Sep 14, 2008 4:56 am

Re: PVP script

Postby Rebell » Tue Sep 30, 2008 8:48 am

Please post your website :wink:
... visit my RPG WEBSITE - but its still not finished !
User avatar
Rebell
Level 3
 
Posts: 62
Joined: Sat Aug 09, 2008 4:42 pm
Location: Germany

Re: PVP script

Postby DrSwiss » Tue Sep 30, 2008 4:07 pm

Rebell wrote:Please post your website :wink:


Still in alpha :P , only development is playing. Been like this on/off for two years, just finally have the time to get it running. You won't get to try the beta until late Nov-Christmas.
User avatar
DrSwiss
Level 2
 
Posts: 20
Joined: Sun Sep 14, 2008 4:56 am

Re: PVP script

Postby Rebell » Wed Oct 01, 2008 1:20 pm

´cmon 8)
... visit my RPG WEBSITE - but its still not finished !
User avatar
Rebell
Level 3
 
Posts: 62
Joined: Sat Aug 09, 2008 4:42 pm
Location: Germany

Re: PVP script

Postby Rebell » Wed Oct 22, 2008 3:36 pm

Hi,

can you show me now your website ?

cya
... visit my RPG WEBSITE - but its still not finished !
User avatar
Rebell
Level 3
 
Posts: 62
Joined: Sat Aug 09, 2008 4:42 pm
Location: Germany

Re: PVP script

Postby DrSwiss » Wed Oct 22, 2008 3:48 pm

Nope, still in alpha stages. Open beta comes in early December. :P
User avatar
DrSwiss
Level 2
 
Posts: 20
Joined: Sun Sep 14, 2008 4:56 am

Re: PVP script

Postby Amrac » Mon Dec 22, 2008 4:10 pm

This is a great script! Only problem is that players can fight themselves and earn gold + exp off themselves, thus cheating the system. I tried altering it/adding code in to exempt you from seeing/fighting yourself but failed. If someone can post some code that eliminates you from seeing yourself in town.php or pervent you from fighting yourself in combat/php that would be greatly appreciated.


I have an easier way to fix it, you just need to be sure that the id of the ennemy is different of the id of player's character

In global.php find
Code: Select all
if($attack)
(near line 113 AND 136) and replace by
Code: Select all
if($attack  && $GLOBALS['PHP_PHAOS_CHARID'] != $row['id'] )


So, players wont see the link "Attaquer" on themselves

In combat.php find this:
Code: Select all
   if(isset($_GET['attaquer']))
      {
      $_SESSION['attaquePlayer'] = $_GET['attaquer'];
      $list[0]=$_GET['attaquer'];
      }

and replace by:
Code: Select all
   if(isset($_GET['attaquer']) && $GLOBALS['PHP_PHAOS_CHARID'] != $row['id'])
      {
         //FIXME: Serucity holl, we need to check if player location = opponent location
      //Player location $character->location
      $_SESSION['attaquePlayer'] = $_GET['attaquer'];
      $list[0]=$_GET['attaquer'];
      }


If somebody want fix the "FIXME" part, it will be great :)
In Holydays between the 16 and 30 august (so, not on the forum)
Amrac
Level 1
 
Posts: 19
Joined: Thu Aug 07, 2008 11:53 pm

Re: PVP script

Postby Rebell » Tue Dec 30, 2008 8:25 am

Thanx for that fix !

Keep it up - :D
... visit my RPG WEBSITE - but its still not finished !
User avatar
Rebell
Level 3
 
Posts: 62
Joined: Sat Aug 09, 2008 4:42 pm
Location: Germany

Next

Return to Scripts

Who is online

Users browsing this forum: No registered users and 0 guests

cron