Hi, I was wondering if someone with PHP talent could help me make a PVP script for my game? If you are familiar with PHP, please help!

I want something simple, but i don't know how to code this.. like a battle arena where it displays a list of users and then:


player 1 attacks player 2 for X damage (HP left)
player 2 attacks player 1 for X damage (HP left)

player 1 attacks player 2 for X2 damage (HP left)
player 2 attacks player 1 for X2 damage (HP left)

until one player reaches 0 hp.

Member Avatar for diafol

You want to do this with PHP?? If so, I'd imagine that you'd need to use Ajax, or better still, Comet. See the APE project for comet.

Yes, just PHP and MySQL. How would I apply ajax or comet to my game?

Member Avatar for diafol

Ok, if you want real time updates - you'll need js (probably in the form of Ajax/Comet). A chat room app would provide a similar implementation.

If you don't need this just php/mysql should be fine. It's just that php isn't well known for creating games. I'm not saying it can't be done - just that there may be better languages/technologies out there.

It's mainly a text based game, where it selects 1 players 'attack' from the table minus the other players 'defense'. I would like something similar to the above example or something similar to the game 'Torn City', where there is a profile link where you can click "Attack."

and then:

Turn 1:
player 1 attacks player 2 for X damage (HP left)
player 2 attacks player 1 for X damage (HP left)

[Attack Again]

player 1 attacks player 2 for X2 damage (HP left)
player 2 attacks player 1 for X2 damage (HP left)

[Attack Again]

until one player reaches 0 hp.


I'm not sure how to code this, but I can supply information. Do you think you can code this?

Member Avatar for diafol

Yeah well, the whole issue here is how does Player 2 get to know that he's been royally anally-invaded by Player 1? Player2's page will have to poll the server every second or so to see if anything has happened (Ajax). Either that or data will have to be pushed to Player 2's page (Comet -see http://www.ape-project.org/).

I imagine that you will need JS whatever you decide to do.

@ardav:
The "purple" must taken over your mind. You are now playing Anal Invaders? LOL
I'll pass!

@ ardav

same way as the game Torn City, when the player dies his HP is 0 then theyll know they are dead.

for each attack there'd be a query that updates player 2's current hp

Check out
http://torncity.com's PVP system

Member Avatar for diafol

> Check out
http://torncity.com's PVP system

No thanks, you need to sign up.

> when the player dies his HP is 0 then theyll know they are dead.
for each attack there'd be a query that updates player 2's current hp

The whole point of what I'm trying to say - updating your own actions (say you're player 1) etc is straightforward. But letting Player 2 know what's happened is more complicated. What if Player2 doesn't refresh his page - how will he know that he's just been fragged by you?

This is what I mean by using Ajax/Comet. Simply using php/Mysql will not work unless players are constantly pressing refresh/reload page to find the latest info update.

Well it doesn't matter if a player refreshes or not, as long as the table is updated then he'll know once he plays again.

I sent you a message regarding the code.

There are a lot of mmorpgs out there that use just PHP/MySQL for their pvp system, so I wanted something similar to that.

Member Avatar for diafol

Sorry, I don't respond to PMs - everything must be placed in the forum. If I'm not able to help, somebody else could. MMORPG - have you seen the APE project example?

griffith, please keep in mind that this forum is for getting help with PHP issues - not getting someone to produce code for you.

If you are needing someone to produce an entire script for you, then you should post in Looking To Hire (and expect to pay for the work) or perhaps Project Partners wanted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.