+ Reply to Thread
Results 1 to 8 of 8

Thread: [REQ] 500 credits for php help

  1. #1
    fierce's Avatar
    fierce is offline x10 Sophmore fierce is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Macedonia
    Posts
    222

    [REQ] 500 credits for php help

    I need some1 that will help me with a php problem i got on my game(site) .
    Those that are interested reply this thread or add my msn im fierce@inbox.com .

    Thx In Advance

    -fierce .
    If my post has helped ya or ya like my jokes hit the +REP button ;)
    http://www.eraoferadication.co.cc

    HTML Code:
    http://forums.x10hosting.com/marketplace/85707-req-1000-credits-4-exchange.html

  2. #2
    compwhizii is offline Banned compwhizii is an unknown quantity at this point
    Join Date
    May 2008
    Location
    The Moon
    Posts
    779

    Re: [REQ] 500 credits for php help

    It would help if you at least gave us some background on the problem...

  3. #3
    NaHoW is offline x10 Sophmore NaHoW is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    244

    Re: [REQ] 500 credits for php help

    What exactly is the problem?

  4. #4
    fierce's Avatar
    fierce is offline x10 Sophmore fierce is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Macedonia
    Posts
    222

    Re: [REQ] 500 credits for php help

    Generates land, ranging 3% - 6% of your total current land (but never above 12,000 acres), at a cost of 1% - 6% magic users, 1% - 8% grains, 1% - 5% gold, and 12 points of health (though you gain back 2 points for the taken turns). You cannot cast this spell until you have a total of at least 10,000 acres. - This is what the spell should do.
    This is the code I use
    Code:
    function SpellEmminentDomain ()
    
    {
    
    	global $users, $urace, $lratio, $config;
    
    	if ($lratio >= 3)
    
    	{
    
    $trandland1 = ceil($users[freeland] * .06);
    $trandland2 = $trandland1 + 1;
    $trandland3 = ceil($trandland2);
    $trandland4 = mt_rand(0, $trandland3);
    $randland = ceil($trandland4);
    
    		if ($randland < ($users[land] * .03)) { $randland = ceil($users[land] * .03); }
    
    		if ($randland > ($users[land] * .06)) { $randland = ceil($users[land] * .06); }
    
    		$newland=$randland;
    
    		if ($newland > $config[edcap]) {$newland=$config[edcap];}
    
    		$mageloss= (100-($newland/250))/100;
    
    		if ($mageloss < .94) {$mageloss=.94;}
    
    		$foodloss= (100-($newland/150))/100;
    
    		if ($foodloss < .92) {$foodloss=.92;}
    
    		$cashloss= (100-($newland/750))/100;
    
    		if ($cashloss < .95) {$cashloss=.95;}
    
    
    
    		$land = $newland;
    
    
    
    		$users[land] = $users[land] + $land;
    
    		$users[freeland] = $users[freeland] + $land;
    
          $users[health] -= 12;
    
          $users[wizards]=round($users[wizards]*$mageloss);
    
          $users[food]=round($users[food]*$foodloss);
    
          $users[cash]=round($users[cash]*$cashloss);
    
    
    
    		$cashloss = ceil($cashloss);
    
    		$foodloss = ceil($foodloss);
    
    		$mageloss = ceil($mageloss);
    
    		$cashloss = commas($cashloss);
    
    		$foodloss = commas($foodloss);
    
    		$mageloss = commas($mageloss);
    
    
    
    
    
    		SpellSucceed($land." acres was made by your Wizards, however the magic that surrounded the area made you lose many wizards, cash and grain in the process!");
    
    		saveUserData($users,"health land freeland cash food wizards");
    	}
    
    	else	SpellFail2();
    	taketurns(2,attack);
    }
    This is the result i get =lose of 10% of health which is ok,no mana,no cash,no grain lose ,no land increase .
    Edit:
    [quote=fierce;486892]Generates land, ranging 3% - 6% of your total current land (but never above 12,000 acres), at a cost of 1% - 6% magic users, 1% - 8% grains, 1% - 5% gold, and 12 points of health (though you gain back 2 points for the taken turns). You cannot cast this spell until you have a total of at least 10,000 acres. - This is what the spell should do.
    This is the code I use
    Code:
    function SpellEmminentDomain ()
    
    {
    
        global $users, $urace, $lratio, $config;
    
        if ($lratio >= 3)
    
        {
    
    $trandland1 = ceil($users[freeland] * .06);
    $trandland2 = $trandland1 + 1;
    $trandland3 = ceil($trandland2);
    $trandland4 = mt_rand(0, $trandland3);
    $randland = ceil($trandland4);
    
            if ($randland < ($users[land] * .03)) { $randland = ceil($users[land] * .03); }
    
            if ($randland > ($users[land] * .06)) { $randland = ceil($users[land] * .06); }
    
            $newland=$randland;
    
            if ($newland > $config[edcap]) {$newland=$config[edcap];}
    
            $mageloss= (100-($newland/250))/100;
    
            if ($mageloss < .94) {$mageloss=.94;}
    
            $foodloss= (100-($newland/150))/100;
    
            if ($foodloss < .92) {$foodloss=.92;}
    
            $cashloss= (100-($newland/750))/100;
    
            if ($cashloss < .95) {$cashloss=.95;}
    
    
    
            $land = $newland;
    
    
    
            $users[land] = $users[land] + $land;
    
            $users[freeland] = $users[freeland] + $land;
    
          $users[health] -= 12;
    
          $users[wizards]=round($users[wizards]*$mageloss);
    
          $users[food]=round($users[food]*$foodloss);
    
          $users[cash]=round($users[cash]*$cashloss);
    
    
    
            $cashloss = ceil($cashloss);
    
            $foodloss = ceil($foodloss);
    
            $mageloss = ceil($mageloss);
    
            $cashloss = commas($cashloss);
    
            $foodloss = commas($foodloss);
    
            $mageloss = commas($mageloss);
    
    
    
    
    
            SpellSucceed($land." acres was made by your Wizards, however the magic that surrounded the area made you lose many wizards, cash and grain in the process!");
    
            saveUserData($users,"health land freeland cash food wizards");
        }
    
        else    SpellFail2();
        taketurns(2,attack);
    }
    This is the result i get =lose of 10% of health which is ok,no mana,no cash,no grain lose ,no land increase .
    EDIT : A friend of mine suggested me to do this :
    Check the function "saveUserData" in you main functions include file. Try adding some OR EXIT() statements to make sure various calls are not silentlly failing. Also, var_dump() is very handy. Just be sure to wrap it in a <pre></pre> html block for readability.
    Still I don't know how to do this ..if you know I will add you ftp user to my site so you fix that ..
    Last edited by fierce; 11-16-2008 at 12:06 PM. Reason: Automerged Doublepost
    If my post has helped ya or ya like my jokes hit the +REP button ;)
    http://www.eraoferadication.co.cc

    HTML Code:
    http://forums.x10hosting.com/marketplace/85707-req-1000-credits-4-exchange.html

  5. #5
    cased's Avatar
    cased is offline x10Hosting Member cased is an unknown quantity at this point
    Join Date
    Oct 2008
    Location
    Ohio
    Posts
    43

    Re: [REQ] 500 credits for php help

    Are you sure it's this function that's acting up? You are using globals which means anything anywhere could be changing the values after this function is called. Why are you using globals? Call by value functions are much safer. I would suggest you start by testing this function:

    $users[land] = $users[land] + $land;

    $users[freeland] = $users[freeland] + $land;

    $users[health] -= 12;

    $users[wizards]=round($users[wizards]*$mageloss);

    $users[food]=round($users[food]*$foodloss);

    $users[cash]=round($users[cash]*$cashloss);

    //Add some echo statements here that will print the values of $users to see
    //if they are being set right.


    $cashloss = ceil($cashloss);

    $foodloss = ceil($foodloss);

    $mageloss = ceil($mageloss);

    $cashloss = commas($cashloss);

    $foodloss = commas($foodloss);

    $mageloss = commas($mageloss);

    //What is the purpose of this block of code?





    SpellSucceed($land." acres was made by your Wizards, however the magic that surrounded the area made you lose many wizards, cash and grain in the process!");

    saveUserData($users,"health land freeland cash food wizards");
    }

    else SpellFail2();
    taketurns(2,attack);

    Finally, what is it about exit() and vardump() you don't understand? Did you read the entries on php.net?

  6. #6
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: [REQ] 500 credits for php help

    hey, i fixed it earlier today... where's my 500 creds at? :P

    just for everyone's general knowledge, the variable $config[edcap] wasn't set, thus ($newland > '') which made $newland = '';

    i always ask this, but it seems like you do it alot... did you add this code into the game or was it there from the start? you seem to add code from other versions of this game, so i was just wondering

    oh, and on a side note, i think you can compress
    PHP Code:
    $trandland1 ceil($users[freeland] * .06);
    $trandland2 $trandland1 1;
    $trandland3 ceil($trandland2);
    $trandland4 mt_rand(0$trandland3);
    $randland ceil($trandland4);

    // into

    $randland mt_rand(0ceil($users[freeland] * .06)+1); //mt_rand should never make a fraction or decimal number 
    it may seem confusing, but it should have the same effect as the 5 lines above, just in one command :D
    Last edited by xPlozion; 11-19-2008 at 12:38 AM.

  7. #7
    cased's Avatar
    cased is offline x10Hosting Member cased is an unknown quantity at this point
    Join Date
    Oct 2008
    Location
    Ohio
    Posts
    43

    Re: [REQ] 500 credits for php help

    Well I was right about it not being the function's fault anyway.

  8. #8
    NaHoW is offline x10 Sophmore NaHoW is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    244

    Re: [REQ] 500 credits for php help

    Perhaps you can send me an URL of your site where I can see the problem live?

+ Reply to Thread

Similar Threads

  1. [REQ] 1000 credits 4 $ exchange !
    By fierce in forum The Marketplace
    Replies: 8
    Last Post: 01-23-2009, 11:42 PM
  2. Replies: 5
    Last Post: 11-16-2008, 03:59 PM
  3. [REQ] Beep - 300 Credits
    By supajason in forum The Marketplace
    Replies: 6
    Last Post: 10-09-2008, 02:33 AM
  4. Need Advertising - Will pay in Credits
    By Loneua Technologies in forum Advertising
    Replies: 52
    Last Post: 03-16-2008, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers