Jump to content
MakeWebGames

Noob Question


MafiaHeros

Recommended Posts

Hi there,

I'm currently working on a Badge/Milestone page,

So im listing with this code how many users are above level 5

$result = mysql_query("SELECT * FROM `grpgusers` WHERE `level` > '5'");
$resultmobsters = mysql_num_rows($result);

 

Now i'm trying to list the total mobsters that are below level 5 by using this code

$result1 = mysql_query("SELECT * FROM `grpgusers` WHERE `level` < '5'");
$howmany = ($result1);

 

But for that line I get this error,

Warning: strrev() expects parameter 1 to be string, resource given in /home/rjd/domains/mafiaheros.com/public_html/classes.php on line 51

Line 51 is my prettynum function:

function prettynum($num,$dollar="0") {
// Basic send a number or string to this and it will add commas. If you want a dollar sign added to the
// front and it is a number add a 1 for the 2nd variable.
// Example prettynum(123452838,1)  will return $123,452,838 take out the ,1 and it looses the dollar sign.
       $out=strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,' , strrev( $num ) ) );
	if ($dollar && is_numeric($num)){
		$out= "$".$out;
	}
return $out;
}

 

I'm echo'ing the ranks like this:

<td align="right"><i><? echo prettynum($resultmobsters) ?> mobsters have achieved this milestone, <? echo prettynum($howmany) ?> mobsters still need to!</i></td>

 

Would anyone know how I display the amount of grpgusers that are below level 5?

Much appreciated :)

Link to comment
Share on other sites

Actually.. that query might not work... grpg has no level field! :)

also

$result1 = mysql_query("SELECT * FROM `grpgusers` WHERE `level` < '5'");

 

could become

$result1 = mysql_query("SELECT COUNT(`id`) FROM `grpgusers` WHERE `exp` < 'limit_to_level_5_exp'");
Edited by Lithium
Link to comment
Share on other sites

Actually.. that query might not work... grpg has no level field! :)

also

$result1 = mysql_query("SELECT * FROM `grpgusers` WHERE `level` < '5'");

 

could become

$result1 = mysql_query("SELECT COUNT(`id`) FROM `grpgusers` WHERE `exp` < 'limit_to_level_5_exp'");

Whilst introducing AS, for associative arrays..

 

$result1 = mysql_query("SELECT COUNT(`id`) AS `totalUsers` FROM `grpgusers` WHERE `exp` < limit_to_level_5_exp_as_int");
Link to comment
Share on other sites

  • 2 months later...
By playing a game how do you know he had a mod to do something?

To me, it would apear as though it checks how much exp you have, and if you have more than (or equal to) say 100 and less than say 200, you are level 1 etc...

Because the exp/level system goes a bit like...

Exp needed = level * 378

(roughly, it seems to get progressively harder)

And I've seen this method used many times, in the classes file, there's a check to seem if current exp is greater than the exp needed and then updates the level field +1.

I could be wrong, but it seems to be this method he uses, and it most definitely isn't the basic grpg system

Link to comment
Share on other sites

Because the exp/level system goes a bit like...

Exp needed = level * 378

(roughly, it seems to get progressively harder)

And I've seen this method used many times, in the classes file, there's a check to seem if current exp is greater than the exp needed and then updates the level field +1.

I could be wrong, but it seems to be this method he uses, and it most definitely isn't the basic grpg system

Exactly...

 

//Leveling stuff

if ($this->exp >= $this->maxexp && $this->exp != 0 && $this->level < 501){



              $newlvl = $this->level + 1;

             $newnerve = $this->maxnerve + 1;

             $newenergy = $this->maxenergy + 1;

             $newhp = ($this->level+1) * 50;
      if($newlvl % 10 == 0 && $newlvl < 500){
	$newpoints = rand(2,50); $pts_message = "[+".$newpoints." Points]";
      } else { $newpoints = 0; }


		  $expleft = $this->exp - $this->maxexp;

             Send_Event ($this->id, "You have gained a level! [Level $newlvl] $pts_message", $this->id);
             RecentGameEvents($this->id, "[-_USERID_-] has gained a level.");



		  $number = isdiv($newlvl, 10);

		  if($number == 1) {

		  $newupgrades = $this->upgradetimes + 1;

		  $result162 = mysql_query("UPDATE `grpgusers` SET `upgradetimes` = '".$newupgrades."' WHERE `id` = '".$this->id."'");

		  }



             $result2345 = mysql_query("UPDATE `grpgusers` SET `level`='".$newlvl."', `hp`='".$newhp."', `energy`='".$newenergy."', `nerve`='".$newnerve."', 	`points`= points + ".$newpoints.", `exp` = '".$expleft."' WHERE `id`='".$this->id."'");





 }

//End
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...