[PHP] Ogame

Skilled Illusionist
Joined
Jan 14, 2005
Messages
395
Reaction score
2
Hello,

i am working on a script to trade in officer points but now i got following problem :
it use decimal numbers like : 5772.79888904
and the resource is 1772 but how i can just remove 5000 of the number ?

on the check i use xplode by "." like :

PHP:
// Metal
		$metal = explode(".", $infos2["metal"]);
		
		// Crystal
		$crystal = explode(".", $infos2["crystal"]);
		
		// Deuterium
		$deuterium = explode(".", $infos2["deuterium"]);
		
		if($metal[0] >= 5000 AND $crystal[0] >= 5000 AND $deuterium[0] >= 5000){
			echo "Enough";	
		} else {
			echo "Not enough";	
		}

Thanks,
Passie.
 
You want the 5772 gone...?
Use $metal[1]. $crytal[1], $deuterium[1]....
misread your post...
Save them in a int? then - 5000... I'm kinda lost on what your needing help with...
 
Last edited:
You want the 5772 gone...?
Use $metal[1]. $crytal[1], $deuterium[1]....
misread your post...
Save them in a int? then - 5000... I'm kinda lost on what your needing help with...

well the field type is : double(1 2 3 , 8) (without whitespace)

and i want to give 1 officer point in trade for 5000 of each resource but i tried a few things myself but just can't work it out...

so for example 1 point is :
5.000 crystal
5.000 metal
5.000 deuterium

which need to removed from the player his resources ofcourse afther you bought 1..
 
Last edited:
Uhmm try this?
I'm still a little confused.... But this should work...
PHP:
        $metal = explode(".", $infos2["metal"]); 
         
        // Crystal 
        $crystal = explode(".", $infos2["crystal"]); 
         
        // Deuterium 
        $deuterium = explode(".", $infos2["deuterium"]); 
         //Changed AND into OR.
         //On a side note, proper use of and is &&, || is or
         //You don't want to see if they have 5000 of all resources for one point, just 5000 of one type.
         //If you want to see if they have all change the || to &&. Your choice.
        if($metal[0] >= 5000 || $crystal[0] >= 5000 || $deuterium[0] >= 5000){ 
            echo "Enough";     
        } else { 
            echo "Not enough";     
        }
 
Uhmm try this?
I'm still a little confused.... But this should work...
PHP:
        $metal = explode(".", $infos2["metal"]); 
         
        // Crystal 
        $crystal = explode(".", $infos2["crystal"]); 
         
        // Deuterium 
        $deuterium = explode(".", $infos2["deuterium"]); 
         //Changed AND into OR.
         //On a side note, proper use of and is &&, || is or
         //You don't want to see if they have 5000 of all resources for one point, just 5000 of one type.
         //If you want to see if they have all change the || to &&. Your choice.
        if($metal[0] >= 5000 || $crystal[0] >= 5000 || $deuterium[0] >= 5000){ 
            echo "Enough";     
        } else { 
            echo "Not enough";     
        }
The check is already working but the withdraw of the sources @ th e users account aint...

i dunno how to withdraw that.

help on that on please.
 
errrr, just do a simple query?
PHP:
// if has enough resources
$do = mysql_query("UPDATE resources_table SET metal = metal - 5000, crystal = crystal - 5000, deuterium = deuterium - 5000, officer_points = officer_points + 1");

edit it with the right table and rows, I just did it with the information you gave out lol
that should do it..
 
Last edited:
Back