pvp
-
pretender5552
- Posts: 127
- Joined: Mon Jan 03, 2011 5:38 am
pvp
I want to set it up for pvp I want to set it up so it choices randomly of players of the same level.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: pvp
You will have to give a lot more info on how you want it to work for us to point you in the right direction. Programming is all about specifics, right down to and including micro-management.
The indelible lord of tl;dr
Re: pvp
This is something Hall's showed me awhile back
You can either see how to modify it to work within a level range - or if you can't, you need to slow down and work on the basics anyway.
Also if there is no player who qualifies, it'll return nothing, which you can check with a !isset
You can either see how to modify it to work within a level range - or if you can't, you need to slow down and work on the basics anyway.
Code: Select all
$opponentinfo1="SELECT * from players where brawl<='$brawltoprange' AND id <> '$playerid' order by rand() limit 1";Code: Select all
if(!isset($opponentinfo3['name']))Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
-
pretender5552
- Posts: 127
- Joined: Mon Jan 03, 2011 5:38 am
Re: pvp
Not sure how more specific I can be its a basic fighting system the same that halls has in his tutorial the only help I need is making it so they have a list of five names that come up, and these name are of the same level as them.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: pvp
Well, a system like Halls' will not exactly work for PvP. This is because PHP is one-way only, from the server. For example, say you have player A standing in an area. Then player B sees them and wants to fight, so they click a link to attack them. Without some creative design using AJAX, player A will not know that player B wants to fight them until they do something to refresh their own page, possibly leaving player B either waiting for minutes or hours for player A to come back and acknowledge the attack, or allowing player B to kill player A without player A ever knowing they were attacked. Both solutions are not really acceptable game design.
Because of this, PvP has to be done creatively in PBBGs. A simple design of "just let player B attack player A" doesn't really work. Some games do more of a "PvP by mail" system where players can trade attacks over long periods of time, but this is not what a lot of people are interested in doing. Probably one of the easiest ways to create a "real" PvP system is by polling for attacks with AJAX, but that has its cons as well since AJAX polling can be costly on bandwidth since the game will continuously make connections to the server, even if the player is away from their computer.
That is why I was asking how you wanted to implement PvP, since there really is no default way of doing it.
Because of this, PvP has to be done creatively in PBBGs. A simple design of "just let player B attack player A" doesn't really work. Some games do more of a "PvP by mail" system where players can trade attacks over long periods of time, but this is not what a lot of people are interested in doing. Probably one of the easiest ways to create a "real" PvP system is by polling for attacks with AJAX, but that has its cons as well since AJAX polling can be costly on bandwidth since the game will continuously make connections to the server, even if the player is away from their computer.
That is why I was asking how you wanted to implement PvP, since there really is no default way of doing it.
The indelible lord of tl;dr
-
pretender5552
- Posts: 127
- Joined: Mon Jan 03, 2011 5:38 am
Re: pvp
It isn't really going to work that way pvp in this case is simply another way of gaining experience and money, the two parts get one attack in and the one with the higher damage wins, gaining the experience and money.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: pvp
But are the two players going to have to interact to fight, or is it just one player doing all of the action? If both players have to interact to fight (i.e., they both choose what moves they want to make), then you will have the issues outlined above. However, if it is more like a single-player battle against the stats of another player, than it will work fine.
The indelible lord of tl;dr
-
pretender5552
- Posts: 127
- Joined: Mon Jan 03, 2011 5:38 am
Re: pvp
It just the one person interacting, later I am going to set it up so that they will receive a notice and have the option to attack the player back.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: pvp
Oh ok, then that is not so difficult. Just pull up the enemy player's stats using something like (like what Callen said above):
Code: Select all
//assumes you have the player's level saved in a variable called "$playerLevel"
//subtract 5 from the player's level to get a lower bound to pull
$playerLowLevel = $playerLevel - 5;
//add 5 to get the upper bound (this would be to pull enemy players within 5 levels of the player
$playerHighLevel = $playerLEvel + 5;
//the query to fetch 1 enemy player who is within 5 levels of the player
$sql = "SELECT * FROM players WHERE level >= $playerLowLevel AND level <= $playerHighLevel ORDER BY RAND() LIMIT 1";
//run the query and use pulled stats to set up battleThe indelible lord of tl;dr
Re: pvp
Yeah, I assumed it was just one player, since it's a good solid foundation to start from and interaction is more complex.
One thing you can do is players can have a number of options to do with combat. They set them as they will and that's recorded in the database - now when any other player fights them, the options are used in combat. It's not in the instant interaction, but its more player Vs player interaction than pure stat comparison is, but without the hassles of syncing players.
One thing you can do is players can have a number of options to do with combat. They set them as they will and that's recorded in the database - now when any other player fights them, the options are used in combat. It's not in the instant interaction, but its more player Vs player interaction than pure stat comparison is, but without the hassles of syncing players.
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog