[PHP] Ogame

Results 1 to 7 of 7
  1. #1
    Grand Master passie is offline
    Grand MasterRank
    Jan 2005 Join Date
    The NetherlandsLocation
    710Posts

    [PHP] Ogame

    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 Code:
    // 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.


  2. #2
    Learning. lordvladek is offline
    Grand MasterRank
    Mar 2006 Join Date
    872Posts

    Re: [PHP] Ogame

    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 by lordvladek; 08-11-09 at 10:13 PM.

  3. #3
    Grand Master passie is offline
    Grand MasterRank
    Jan 2005 Join Date
    The NetherlandsLocation
    710Posts

    Re: [PHP] Ogame

    Quote Originally Posted by lordvladek View Post
    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 by passie; 08-11-09 at 10:56 PM.

  4. #4
    Learning. lordvladek is offline
    Grand MasterRank
    Mar 2006 Join Date
    872Posts

    Re: [PHP] Ogame

    Uhmm try this?
    I'm still a little confused.... But this should work...
    PHP Code:
            $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";     
            } 

  5. #5
    Grand Master passie is offline
    Grand MasterRank
    Jan 2005 Join Date
    The NetherlandsLocation
    710Posts

    Re: [PHP] Ogame

    Quote Originally Posted by lordvladek View Post
    Uhmm try this?
    I'm still a little confused.... But this should work...
    PHP Code:
            $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.

  6. #6
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,097Posts

    Re: [PHP] Ogame

    We don't know your user account data..? Consult the Ogame manual. (Or somebody who develops for "Ogame")

  7. #7
    Grand Master Masius is offline
    Grand MasterRank
    Dec 2007 Join Date
    1,580Posts

    Re: [PHP] Ogame

    errrr, just do a simple query?
    PHP Code:

    // 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 by Masius; 09-11-09 at 08:20 PM.



Advertisement