Author Topic: Prediction - Guessing Item  (Read 14157 times)

Offline David

Re: Prediction - Guessing Item
« Reply #15 on: September 28, 2007, 02:00:59 am »
@ lelekins

 Just to see if I might be right...would you please be so kind as to supply us with your php version details? If it turns out to be php 5.x then we may have confirmed my earlier guess.

Offline lelekins

Re: Prediction - Guessing Item
« Reply #16 on: September 28, 2007, 02:02:20 am »
Aw sorry - mine is 4.4.7
=P

Offline David

Re: Prediction - Guessing Item
« Reply #17 on: September 28, 2007, 02:17:40 am »
We will have to wait for inkstains to give some guidance though it does look to be some sort of server configuration issue as I've had it work properly on other servers.

Offline inkstains

Re: Prediction - Guessing Item
« Reply #18 on: September 28, 2007, 03:59:50 am »
use this code instead fellas

Code: [Select]
<?php


class item_Prediction extends itemTemplate {

    function 
getItemDetails() {
        
$this->authorName 'Inkstains';
        
$this->authorWeb '';
        
$this->authorEmail 'inkstains@nurcharecords.com';
        
        
$this->name "Prediction";
        
$this->desc "Predict what you will roll with the dice";
        
$this->price 10;

        
$this->require_input true;
        
$this->can_use_item true;
        
$this->addInput_editable true;
    }

    function 
getAddInput()
{
global $item_info$db_prefix;
return '<br><b>You must assign a value to each</b><br>
                        Minimum amount of credits to give: <input type="text" name="info1" value="' 
$item_info[1] . '" /><br />
                        Maximum amount of credits to give: <input type="text" name="info2" value="' 
$item_info[2] . '" /><br />';
                }

    function 
getUseInput() {

        return 
'Select which number you think you will roll: <select name="dieside_" size="1" id="number">
        <option value="1">1</option>
<option value="2">2</option>
        <option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
  </select>'
;

    }



    function 
onUse() {

        global 
$db_prefix$ID_MEMBER$item_info$boardurl$txt$scripturl;

                
$value mt_rand(16);

                if (
$value == 1) {
                                     if (
$_REQUEST["dieside_"] ==  $value)
                          {          
$value1 mt_rand($item_info[1], $item_info[2]);
                                       
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
                               return "<img src='".$boardurl."/Sources/shop/item_images/Roll1.gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a 1 and got ".formatMoney($value1)."";
}
        else
        {return 
"You rolled a $value <br><br>The force is weak in this one";}
        }
                elseif (
$value == 2) {
                                     if (
$_REQUEST["dieside_"] ==  $value)
                          {          
$value1 mt_rand($item_info[1], $item_info[2]);
                                       
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
                                               return 
"<img src='".$boardurl."/Sources/shop/item_images/Roll2.gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a 2 and got ".formatMoney($value1)."";
}
        else
        {return 
"You rolled a $value <br><br>I don't think you'll be opening a psychic hotline any time soon :p";}
        }
        elseif (
$value == 3) {
                                     if (
$_REQUEST["dieside_"] ==  $value)
                          {          
$value1 mt_rand($item_info[1], $item_info[2]);
                                       
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
                                               return 
"<img src='".$boardurl."/Sources/shop/item_images/Roll3.gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a 3 and got ".formatMoney($value1)."";
}
        else
        {return 
"You rolled a $value <br><br>I predicted you would fail you must meditate and focus your mind";}
        }
        elseif (
$value == 4) {
                                     if (
$_REQUEST["dieside_"] ==  $value)
                          {          
$value1 mt_rand($item_info[1], $item_info[2]);
                                       
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
                                               return 
"<img src='".$boardurl."/Sources/shop/item_images/Roll4.gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a 4 and got ".formatMoney($value1)."";
}
        else
        {return 
"You rolled a $value <br><br>Duh!";}
        }
        elseif (
$value == 5) {
                                     if (
$_REQUEST["dieside_"] ==  $value)
                          {          
$value1 mt_rand($item_info[1], $item_info[2]);
                                       
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
                                               return 
"<img src='".$boardurl."/Sources/shop/item_images/Roll5.gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a 5 and got ".formatMoney($value1)."";
}
        else
        {return 
"You rolled a $value <br><br>I don't think you'll be opening a psychic hotline any time soon :p";}
        }
        elseif (
$value == 6) {
                                     if (
$_REQUEST["dieside_"] ==  $value)
                          {          
$value1 mt_rand($item_info[1], $item_info[2]);
                                       
$result db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__);
                                               return 
"<img src='".$boardurl."/Sources/shop/item_images/Roll6.gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a 6 and got ".formatMoney($value1)."";
}
        else
        {return 
"You rolled a $value <br><br>Try calling 1900-YOUR-NO-PSYCHIC for the answer :p";}
        }
    }



}



?>

also code updated in first post
« Last Edit: October 08, 2007, 05:29:53 pm by inkstains »

Offline David

Re: Prediction - Guessing Item
« Reply #19 on: September 28, 2007, 04:56:24 am »
Thanks! Tested and no errors found.

Offline inkstains

Re: Prediction - Guessing Item
« Reply #20 on: September 28, 2007, 02:46:42 pm »
 O0

Offline feeble

Re: Prediction - Guessing Item
« Reply #21 on: September 28, 2007, 09:53:02 pm »
nice work again with this item inkstain

small suggestion for your prediction item
Code: [Select]
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info, $boardurl;

$failedTextArray = array(
"You rolled a %s <br/><br/>The force is weak in this one",
"You rolled a %s <br/><br/>I don't think you'll be opening a psychic hotline any time soon :p");

srand(time());
$value = rand(1, 6);

if($value == $_REQUEST["dieside_"]){
$value1 = rand($item_info[1], $item_info[2]);
db_query("UPDATE {$db_prefix}members SET money = money + {$value1} WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return "<img src='".$boardurl."/Sources/shop/item_images/Roll".$value.".gif' align='texttop'/><br><br>Congratulations your prediction was right you rolled a ".$value." and got ".formatMoney($value1)."";
}else
return sprintf($failedTextArray[array_rand($failedTextArray)], $value);
}

Offline inkstains

Re: Prediction - Guessing Item
« Reply #22 on: September 28, 2007, 09:54:41 pm »
it's pretty old but cheers feeble O0


edit: when ya gonna finish that topic rating mod

me wants  ;D
« Last Edit: September 28, 2007, 10:01:44 pm by inkstains »

Offline lelekins

Re: Prediction - Guessing Item
« Reply #23 on: September 29, 2007, 04:04:11 am »
Aw fantastic! :D It's working fine now :)
Thank you!

Offline inkstains

Re: Prediction - Guessing Item
« Reply #24 on: October 08, 2007, 05:36:04 pm »
updated roll/item images in the first post as well as updated code.