Trouble with my PHP code

mafia mmorpg attack script

Page 1 of 1

7 Replies - 1240 Views - Last Post: 28 October 2010 - 08:41 PM Rate Topic: -----

#1 edu2004eu  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 81
  • Joined: 27-August 07

Trouble with my PHP code

Posted 26 October 2010 - 06:12 AM

Alright, so I know these kind of questions are frowned upon, but I'm not like the others, so please hear me out.

I'm making a mafia web-based game and I'm stuck on the attack page. I've made an algorithm which almost works. This means: it works if both the attacking and the defending player have thugs,bodyguards and hitmen. If one of these variables are 0, then the function I use to get how many men the attacker and defender have lost, returns me some irrelevant values. I will attach the existing script, so you can't say I asked for something when I've got nothing.
Also if you want the real working complete script, go to http://mafia-fights.co.cc/ and log in with user administrator and password admin and attack the player named GothBoy, and see for yourself what numbers are shown.

This question is more directed at the people who actually coded such a game, as they know the principles used, but others are welcomed to state their opinion.

Thank you.

This post has been edited by edu2004eu: 28 October 2010 - 02:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Trouble with my PHP code

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,273
  • Joined: 27-December 08

Re: Trouble with my PHP code

Posted 26 October 2010 - 06:16 AM

Moved to PHP.

Please post your code in the body of your post using code tags. :)
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: Trouble with my PHP code

Posted 26 October 2010 - 06:18 AM

Have you read the set of tutorials on this very topic? Here's part 1.
Was This Post Helpful? 0
  • +
  • -

#4 edu2004eu  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 81
  • Joined: 27-August 07

Re: Trouble with my PHP code

Posted 26 October 2010 - 06:22 AM

View Postmacosxnerd101, on 26 October 2010 - 05:16 AM, said:

Moved to PHP.

Please post your code in the body of your post using code tags. :)

Sorry, saw that other posted on the same topic in the web dev section, and figured I could do same.

View PostJackOfAllTrades, on 26 October 2010 - 05:18 AM, said:

Have you read the set of tutorials on this very topic? Here's part 1.

I subscribed to all topics which are about making web-based games and practically know them from A-Z, but that still doesn't help me in this particular matter.

This post has been edited by edu2004eu: 28 October 2010 - 02:54 PM

Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3099
  • View blog
  • Posts: 10,887
  • Joined: 08-August 08

Re: Trouble with my PHP code

Posted 26 October 2010 - 06:35 AM

Your code looks like a string of instructions. Repetitive instructions. My guess is that about 80%+ of it belongs in a loop, but I just can't force my eyes to stare at it long enough to make sense of it. Fix that. Then you can worry about your function results, which will probably be much simpler to fix.
Was This Post Helpful? 0
  • +
  • -

#6 C. Bundgaard  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 13-September 10

Re: Trouble with my PHP code

Posted 26 October 2010 - 12:46 PM

Can't you just say:

if($thugs == 0) {
    // do something
}


Was This Post Helpful? 0
  • +
  • -

#7 edu2004eu  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 81
  • Joined: 27-August 07

Re: Trouble with my PHP code

Posted 28 October 2010 - 02:53 PM

View PostC. Bundgaard, on 26 October 2010 - 11:46 AM, said:

Can't you just say:

if($thugs == 0) {
    // do something
}


LOL no :)

umm this topic can be closed, i've resolved this problem in a way i normally don't do: copied someone else's work. ty.
Was This Post Helpful? 0
  • +
  • -

#8 visicod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 05-October 10

Re: Trouble with my PHP code

Posted 28 October 2010 - 08:41 PM

next time try to paste the code please
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1