Daisuke_aurora
-
Posts
13 -
Joined
-
Last visited
Never
Posts posted by Daisuke_aurora
-
-
Im trying to make a PHP battle script for my SMF site, but I have a few holdups:
-How do I make the script find info from the SMF DB?
-How do I make the script Change a person's membergroup when their HP reaches 0?
-How do I make the script give SMF shop items / Increase in posts to the winner?
-How do I make the script post as me in a thread?
Here's what I have so far (the variables are the stats from you or your opponent). I think it's right, and when I tested it with the variables I have set, it worked.
$A = 8; //Attacker's ATK
$D = 5; //Defender's DEF
$S = 8; //Attacker's SPD
$R = 7; //Defender's R. SPD
$HP = 50; //Defender's HP
$N1 = mt_rand(1, 10);
$N2 = mt_rand(1, 10);
$A1 = $N1 + $S;
$A2 = $A1 + $A;
$D1 = $N2 + $R;
$D2 = $D1 + $D;
//Defense v.s. attack?
If ($A - $D > 0)
{
$DA = $A-$D;
}
//Defense v.s. attack?
If ($A - $D < 0)
{
$DA = 0;
}
//Defense v.s. attack?
If ($A - $D = 0)
{
$DA = 0;
}
//Did we power-hit?
If ($A1 > $D2)
{
echo 'You smashed your opponent for ' .($A + $A). ' damage!';
SET $HP = ($HP - $A - $A)
}
else
//Did we hit?
If ($A2 > $D2)
{
echo 'You hit your opponent for ' .($A). ' damage!';
SET $HP = ($HP - $A)
}
else
//Did they dodge?
If ($A2 < $D1)
{
echo 'Your opponent dodged and took no damage!';
}
else
//Did they dodge?
If ($A2 = $D1)
{
echo 'Your opponent dodged and took no damage!';
}
else
//Did they block?
If ($A2 < $D2)
{
echo 'Your opponent blocked, taking only ' .($DA + 1). ' damage!';
SET $HP = ($HP - $DA - 1)
}
else
//Did they block?
If ($A2 = $D2)
{
echo 'Your opponent blocked, taking only ' .($DA + 1). ' damage!';
SET $HP = ($HP - $DA - 1)
}
That's just the PHP-box demo I made, to determine battle results. Now, I want to integrate it with SMF, but I am bad at PHP.
-
Looking for a member to join my site as a coding admin, to help with PHP coding for a mod and some items and what have you. If interested, sign up at Daisukesdojo.heliohost.org/forum and PM Daisuke_Aurora for details.
-
Ok. I run a forun where members can RP using a stat system (the custom profile field mod). Basically, members have a set atk power, def power, etc, displayed by the CP field mod. I recently took the Add to post count item and tweaked it to add to the CP fields, and got this:
<?php/**********************************************************************************
* SMFShop item *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum *
* =============================================================================== *
* Software Version: SMFShop 3.0 (Build 12) *
* $Date:: 2008-08-18 14:30:00 +1100 (Mon, 18 Aug 2008) $ *
* $Id:: IncreaseHP.php 79 2008-08-18 12:30:00Z Daisuke_aurora $ *
* Software by: Daisuke (http://www.daisukesdojo.heliohost.org/) *
* Copyright 2005-2007 by: Daisuke (http://www.daisukesdojo.heliohost.org/) *
* Support, News, Updates at: http://www.daisukesdojop.heliohost.org/ *
* *
* Forum software by: Simple Machines (http://www.simplemachines.org) *
* Copyright 2006-2007 by: Simple Machines LLC (http://www.simplemachines.org) *
* 2001-2006 by: Lewis Media (http://www.lewismedia.com) *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under *
* the terms of the provided license as published by Simple Machines LLC. *
* *
* This program is distributed in the hope that it is and will be useful, but *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* See the "license.txt" file for details of the Simple Machines license. *
* The latest version of the license can always be found at *
* http://www.simplemachines.org. *
**********************************************************************************/
if (!defined('SMF'))
die('Hacking attempt...');
class item_IncreaseHP extends itemTemplate
{
function getItemDetails()
{
$this->authorName = 'Daisuke';
$this->authorWeb = 'http://www.daisukesdojo.heliohost.org/';
$this->authorEmail = 'Daisuke_aurora@hotmail.com';
$this->name = 'Increase HP by xxx';
$this->desc = 'Increase your HP by xxx';
$this->price = 1000;
$this->require_input = false;
$this->can_use_item = true;
$this->addInput_editable = true;
}
// See 'AddToPostCount.php' for info on how this works
function getAddInput()
{
global $user_info;
if ($item_info[1] == 0) $item_info[1] = 10;
return 'Amount to increase HP by: <input type="text" name="info1" value="' . $item_info[1] . '" />';
}
function onUse()
{
global $db_prefix, $ID_MEMBER, $item_info;
db_query("
UPDATE {$db_prefix}themes
SET value = value + {$item_info[1]}
WHERE ID_MEMBER = {$ID_MEMBER}", __FILE__, __LINE__);
return 'Successfully increased your HP by ' . $item_info[1] . '!';
}
}
?>
However, there is one problem: The item cannot tell the difference between the 8 CP fields, so it increases ALL of them by 10, not just one. Can anyone tell me how to make it target only one of these fields?
-
-
*Bump once more*
Willing to pay for it if it works.
-
*Bump Again*
-
*...Bump...*
-
It's a Mod. I looked at the way the Increase Post Count item worked, but I can't get it to work for the CP field. And where should this be? (never mind, I can't move it lol.)
-
As much as I love multi-posting, Bump.
-
<Bump> Help please?</bump>
-
-
Or, more specifically, how do I go about making an item for SMF shop? I want to make an item like the "Increase Posts" item, but instead of increasing posts, I want it to increase the value of a Custom Profile Field. That way, I can use the CP Fields to track statistics for members, and allow them to buy items to increase their stats.
I can give a better explanation of exactly what I want if no one understands it. Thanks!
Little help making a script?
in PHP Coding Help
Posted
Bump.
And I replaced
With
It should work the same, right?