Jump to content
MakeWebGames

Analog

Members
  • Posts

    244
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Analog

  1. Re: fixed top and bottom set body margins/padding to 0px 0px
  2. Re: Help needed with prefrences! providing your registration is storing it with an md5 encryption then try this out.   function do_pass_change() { global $ir,$c,$userid,$h; if(md5($_POST['oldpw']) != $ir['userpass']) { print "The current password you entered was wrong. [url='preferences.php?action=passchange']> Back[/url]"; } else if($_POST['newpw'] !== $_POST['newpw2']) { print "The new passwords you entered did not match! [url='preferences.php?action=passchange']> Back[/url]"; } else { $newpass=md5($_POST['newpw']); mysql_query("UPDATE users SET userpass='$newpass' WHERE userid=$userid",$c); print "Password changed!"; } }
  3. Re: Free 2 - Gym Someone with access to v1 & v2 will have to correct the problem. I have never seen how v2 handles queries, or any part of v2 source other than what I've seen on here. I'm going to assume fetch_single is probably a custom function that is in v2 and that is why it does not work. As you are correct, mysql_fetch_single isn't correct, even searched it in the documentation.
  4. Re: Free 2 - Gym This should work for version 1...its not tested so let me know   <?php /* Original Code by Nyna Modified for version1 by TwiztedFake */ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); $macropage = "gym2.php"; if ($ir['hospital']) { echo " You cannot access the gym whilst in hospital</p>"; $h->endpage(); exit; } $prefs = isset($_SESSION['gymprefs']) ? $_SESSION['gymprefs'] : array('what' => "all", 'expend' => "100%"); $what = $prefs['what']; $expend = $prefs['expend']; $message = false; $sql = sprintf("SELECT us.strength, us.agility, us.guard, us.labour, u.energy, u.will, u.jail FROM users u LEFT JOIN userstats us ON (u.userid = us.userid) WHERE (u.userid = %u)", $userid); $row = mysql_fetch_row(mysql_query($sql)); $formID = preg_replace("`^([0-9A-F]{8})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{12})$`ms", "{\\1-\\2-\\3-\\4-\\5}", strtoupper(md5(serialize(array(session_id(), "Gym", null))))); if (isset($_POST['formID']) && is_string($_POST['formID']) && ($_POST['formID'] === $formID)) { $what = isset($_POST['what']) && is_string($_POST['what']) && preg_match("`^((all)|(strength)|(agility)|(guard)|(labour))$`ims", $_POST['what']) ? strtolower($_POST['what']) : $what; $expend = isset($_POST['expend']) && is_string($_POST['expend']) && preg_match("`^((100%)|(75%)|(50%)|(25%)|(value))$`ims", $_POST['expend']) ? strtolower($_POST['expend']) : $expend; $value = isset($_POST['value']) && is_string($_POST['value']) && preg_match("`^\d+$`ims", $_POST['value']) ? @intval($_POST['value']) : 0; $sql = sprintf("SELECT energy, will FROM users WHERE (userid = %u)", $userid); $rs = mysql_query($sql); $info = mysql_fetch_row($rs); $energy = $row['energy']; $will = $row['will']; switch ($expend) { case "100%": $value = $row['energy']; break; case "75%": $value = $row['energy'] * 0.75; break; case "50%": $value = $row['energy'] * 0.50; break; case "25%": $value = $row['energy'] * 0.25; break; default: break; } $value = floor($value); if ($value > $row['energy']) $message = "<span style='color:#C00;'>You don't have enough energy</span>"; else { $prefs = array('what' => $what, 'expend' => $expend); $gain = 0; $will = $row['will']; for ($i = 0; $i < $value; $i++) { $gain += mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150); $will = max(0, $will - mt_rand(1, 3)); } if ($row['jail']) $gain *= 0.5; $row['will'] = floor($will); $row['energy'] -= $value; switch ($what) { case "all": $message = sprintf("<span style='color:#070;'>You gain %s in each stat</span>", number_format($gain * 0.25, 2)); $row['strength'] += $gain * 0.25; $row['agility'] += $gain * 0.25; $row['guard'] += $gain * 0.25; $row['labour'] += $gain * 0.25; break; case "strength": $message = sprintf("<span style='color:#070;'>You gain %s in strength</span>", number_format($gain, 2)); $row['strength'] += $gain; break; case "agility": $message = sprintf("<span style='color:#070;'>You gain %s in agility</span>", number_format($gain, 2)); $row['agility'] += $gain; break; case "guard": $message = sprintf("<span style='color:#070;'>You gain %s in guard</span>", number_format($gain, 2)); $row['guard'] += $gain; break; case "labour": $message = sprintf("<span style='color:#070;'>You gain %s in labour</span>", number_format($gain, 2)); $row['labour'] += $gain; break; } $sql1 = sprintf("UPDATE userstats SET strength = %.6f, agility = %.6f, guard = %.6f, labour = %.6f WHERE (userid = %u)", $row['strength'], $row['agility'], $row['guard'], $row['labour'], $userid); $sql2 = sprintf("UPDATE users SET will = %u, energy = %d WHERE (userid = %u)", $row['will'], $row['energy'], $userid); mysql_query($sql1); mysql_query($sql2); } $_SESSION['gymprefs'] = $prefs; } $row['ranks'] = array ( 'strength' => mysql_fetch_single(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength > %.6f)", $row['strength']))) + 1, 'agility' => mysql_fetch_single(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (agility > %.6f)", $row['agility']))) + 1, 'guard' => mysql_fetch_single(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (guard > %.6f)", $row['guard']))) + 1, 'labour' => mysql_fetch_single(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (labour > %.6f)", $row['labour']))) + 1, 'total' => mysql_fetch_single(mysql_query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength + agility + guard + labour > %.6f)", $row['strength'] + $row['agility'] + $row['guard'] + $row['labour']))) + 1, ); echo "<style type='text/css'>"; echo "#gym { }"; echo "#gym h3, #gym p { }"; echo "#gym table { width:90%;border-collapse:collapse; }"; echo "#gym th { border:solid 1px #333;background:#F6F6F6 url(titlebg.gif);padding:3px;color:#333; }"; echo "#gym td { border:solid 1px #333;padding:3px;color:#333; }"; echo "#gym { }"; echo "</style>"; echo "<div id='gym'>"; echo sprintf("<h3>%sGym</h3>", $ir['jail'] ? "Jail " : ""); if ($message) echo sprintf(" %s</p>", $message); echo "<form name='train' id='train' action='gym2.php' method='post' style='padding:0;margin:0;'>"; echo sprintf("<input type='hidden' name='formID' value='%s' />", $formID); echo "<table cellpadding='0' cellspacing='0'>"; echo "<tr>"; echo "<th class='sub' style='width:50%;'>Train</th>"; echo "<th class='sub' style='width:50%;'>Expend</th>"; echo "</tr>"; echo "<tr>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='what' id='what0' value='all' %sstyle='vertical-align:middle;' /><label for='what0' style='cursor:pointer;'>All (25%% energy in each) [Rank #%s]</label> ", $what === "all" ? "checked='checked' " : "", number_format($row['ranks']['total'])); echo sprintf("<input type='radio' name='what' id='what1' value='strength' %sstyle='vertical-align:middle;' /><label for='what1' style='cursor:pointer;'>Strength (%s) [Rank #%s]</label> ", $what === "strength" ? "checked='checked' " : "", number_format($row['strength']), number_format($row['ranks']['strength'])); echo sprintf("<input type='radio' name='what' id='what2' value='agility' %sstyle='vertical-align:middle;' /><label for='what2' style='cursor:pointer;'>Agility (%s) [Rank #%s]</label> ", $what === "agility" ? "checked='checked' " : "", number_format($row['agility']), number_format($row['ranks']['agility'])); echo sprintf("<input type='radio' name='what' id='what3' value='guard' %sstyle='vertical-align:middle;' /><label for='what3' style='cursor:pointer;'>Guard (%s) [Rank #%s]</label> ", $what === "guard" ? "checked='checked' " : "", number_format($row['guard']), number_format($row['ranks']['guard'])); echo sprintf("<input type='radio' name='what' id='what4' value='labour' %sstyle='vertical-align:middle;' /><label for='what4' style='cursor:pointer;'>Labour (%s) [Rank #%s]</label> ", $what === "labour" ? "checked='checked' " : "", number_format($row['labour']), number_format($row['ranks']['labour'])); echo "</td>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='expend' id='expend0' value='100%%' %sstyle='vertical-align:middle;' /><label for='expend0' style='cursor:pointer;'>100%% Energy</label> ", $expend === "100%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend1' value='75%%' %sstyle='vertical-align:middle;' /><label for='expend1' style='cursor:pointer;'>75%% Energy</label> ", $expend === "75%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend2' value='50%%' %sstyle='vertical-align:middle;' /><label for='expend2' style='cursor:pointer;'>50%% Energy</label> ", $expend === "50%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend3' value='25%%' %sstyle='vertical-align:middle;' /><label for='expend3' style='cursor:pointer;'>25%% Energy</label> ", $expend === "25%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend4' value='value' %sstyle='vertical-align:middle;' onclick='document.train.value.focus();' /><label for='expend4' style='cursor:pointer;'><input type='text' id='value' name='value' value='{$row['energy']}' size='8' onfocus='this.select();' /> Energy</label> ", $expend === "value" ? "checked='checked' " : "");//(C)2008,Nyna echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' style='text-align:center;padding:6px;'>"; echo "<input type='submit' name='submit' value='Train' />"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</form>"; echo "</div>"; echo "<p style='color:#CCC;'>An open-source extension from [url='http://nyna.co.uk/']Nyna[/url]</p>"; $h->endpage(); ?>
  5. Re: help with something   function mass_give_item_sub() { global $db,$ir,$c; $id=mysql_query("SELECT * FROM items WHERE itmid = {$_POST['item']} LIMIT 1",$c) or die(mysql_error()); $item=mysql_fetch_array($id); $q=mysql_query("SELECT * FROM users WHERE fedjail=0",$c); while($r=mysql_fetch_array($q)) { item_add($r['userid'], $_POST['item'], $_POST['qty']); event_add($r['userid'],"The population has just been given {$_POST['item']} of {$item['itmname']}, Click [url='inventory.php']Here[/url] to check.",$c); print "Item Sent To {$r['username']}</br>"; } print " Mass item sending complete!</br> Theres no need to send a mass mail because they just got an event."; }   That should do what you want I think. Its not tested as I have no way to try it out. However like Nyna stated its going to create a mass amount of database entries. Might be better to do something like a single news entry for them instead.
  6. Re: Mccodes Version 1 Or 2 Never dealt with v2 so can't really say what I think is better.
  7. Re: +25% instead of +25 energy   Yup, missed that in my response. Thanks for the correction
  8. Re: STAFF RANKS Might be useful if you would provide what version of code you are running
  9. Re: Hall Of Fame Money Help (v1)   $q=mysql_query("SELECT * FROM users WHERE u.user_level != 0 ORDER BY money+bankmoney+cybermoney DESC,userid ASC LIMIT 20", $c);   *Removed the select from gang table as its not needed from what I can tell. No need to query info that isn't being used.
  10. Re: +25% instead of +25 energy energy=energy + (energy * 0.25)
  11. Re: Phone calls/Texts I'd go to a higher authority than the local police. I'm assuming you know who these people are so you could also file for restraining orders against them. In which case, continued calls/texts would violate and result in legal action being taken.
  12. Re: Need some help assuming ID is numerical you could also check like if(!is_numeric( $_GET['ID'] )) { die("error"); }
  13. Re: Need some help I'm assuming ID= is numerical....so just check it at the top of the file like after menuarea()
  14. Re: Need some help $_GET['ID'] = abs((int)$_GET['ID']);
  15. This is a version of jail busts using experience for v1 Start by running this sql to add the field to the user table: ALTER TABLE `users` ADD `jailEXP` DECIMAL( 11, 4 ) NOT NULL ;   The v1 file: bust.php <?php // Bust with EXP.....additional jail feature for your game // Coded by TwiztedFake ([email protected]) // This is a free mod, released on CE by TwiztedFake on 3/8/08 // Version 1.0 session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals'],''); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); //General settings used throughout the script, edit to suit your needs $base = 1.1; // General setting for use in the outcome equation, the higher this number is the harder it makes a successful outcome for a jail bust. $baseChance = 10; // This is the base percentage chance, if the equation yields a lower percentage this is used by default. $minEXP = 10; // To prevent any errors and give players a bit of exp if they don't have it lets set a minium EXP $bustCost = 10; // This is the brave needed to bust out, or bust someone else out $baseExpGain = 1.1357; // This is used for the EXP gain/loss from outcome, the higher the number...the more exp gained per bust...gain = level * baseExpGain $baseExpLost = 2; // This sets how much is loss on failure, it is lost = gain * baseExpLost $id = abs((int) $_GET['id']); //Get players Id //Lets check some necessary information before we continue on with the script $z=mysql_query("SELECT * FROM users WHERE userid = $id",$c) or die(mysql_error()); if(!mysql_num_rows($z)) // Make sure an id was selected { print "System Error: Either you didn't select an id or the system failed to pass the information along."; $h->endpage(); die(""); } $user = mysql_fetch_array($z); // Most have been an id defined if we got this far, so lets get there info if($ir['userid'] == $id AND !$ir['jail']) //Lets make sure the player is not trying to bribe/bust someone else while they themselves are in jail { print "Error: You can't bust yourself out, your not in jail."; $h->endpage(); die(""); } if(!$user['jail']) // Lets make sure the id in question is in jail { print "Error: The player you selected is not in jail."; $h->endpage(); die(""); } if($ir['userid'] != $id AND $ir['jail']) //Lets make sure the player is not trying to bust someone else while they themselves are in jail { print "Error: You can't bust someone else out while you are in jail"; $h->endpage(); die(""); } if($ir['brave'] < $bustCost) // Lets make sure the player has enough brave to bust { print "Error: You do not have enough brave to attempt a bust."; $h->endpage(); die(""); } // Do all the math stuff before we continue on $suc = (($ir['jailEXP'] + $minEXP) * $base) / ($user['level'] + 0.5); // Figure out the players percenatage of success $gain = $ir['level'] * $baseExpGain; // Figure out the jailEXP gained $lost = $gain * $baseExpLost; // Figure out the jailEXP lost // Lets check the success percentage against the base success if($suc < $baseChance) // if $suc is less than $baseChance, lets use $baseChance instead to improve the outcome { $suc = $baseChance; } // Now lets get on with it and see if the player is successful $chance = rand(1,100); // succeess random if($suc > $chance) // bust was succesful { mysql_query("UPDATE users SET jailEXP = jailEXP + $gain WHERE userid = $userid",$c) or die(mysql_error()); if($ir['userid'] != $id) // success outcome for busting another player out { mysql_query("UPDATE users SET jail = 0 WHERE userid = $id",$c) or die(mysql_error()); event_add($id,"[url='viewuser.php?u=$userid']{$ir['username']}[/url] busted you from jail.",$c); mysql_query("UPDATE users SET brave = brave - $bustCost WHERE userid = $userid",$c) or die(mysql_error()); print "You busted {$user['username']} out of jail."; $h->endpage(); die(""); } else // success outcome for busting yourself out { mysql_query("UPDATE users SET brave = brave - $bustCost, jail = 0 WHERE userid = $userid",$c) or die(mysql_error()); print "You busted out of jail."; $h->endpage(); die(""); } } else // bust failed { $length = rand(15,35); // Jail time length if caught $newEXP = $ir['jailEXP'] - $lost; if($newEXP < 0) { $newEXP = 0.0000; // Lets not let it ever go negative } mysql_query("UPDATE users SET brave = brave - $bustCost, jail = jail + $length, jailEXP = $newEXP WHERE userid = $userid",$c) or die(mysql_error()); if(!$ir['jail'] AND $ir['userid'] != $id) // failed outcome for busting another player out { $reason = "Caught trying to bust {$user['username']}"; mysql_query("UPDATE users SET jailreason='Caught trying to bust {$user['username']} out of jail' WHERE userid = $userid",$c) or die(mysql_error()); print "The guards caught you trying to bust {$user['username']} out of jail. Now you have been thrown in jail for $length minutes."; $h->endpage(); die(""); } else // failed outcome for busting yourself out { mysql_query("UPDATE users SET jailreason='Caught trying to bust out of jail' WHERE userid = $userid",$c) or die(mysql_error()); print "The guards caught you trying to bust out of jail, $length minutes was added to your stay."; $h->endpage(); die(""); } } $h->endpage(); ?>   link to use from jail: [url="bust.php?u={userid}"]Bust[/url] *replace userid with the variable your jail system uses for each players userid   I semi-tested on a lite version, but should run just fine on v1. *Yes, I like comments in my code....lol
  16. Re: Crime Formular   When you add a new crime, you have to add an equation for its success....correct? Most people use the same equation but change a single integer in it in order to make it easier/harder.... with what I posted you could simply set (i'll call it X) X to a number...ie 0.8 or 0.6 or 1.5 .....etc each time you inputed a different number, the outcome of the equation would be different. example database entry crime1 >>> crimePERCFORM is set to 0.8 crime2 >>> crimePERCFORM is set to 0.6 now lets say will = 100 and level = 5 crime1 (($ir['will']*$r['crimePERCFORM']/2.5)+($ir['level']/4) (100 * 0.8 / 2.5) + (5 / 4) = 33.25   crime2 (($ir['will']*$r['crimePERCFORM']/2.5)+($ir['level']/4) (100 * 0.6 / 2.5) + (5 / 4) = 25.25   See where i'm going this......its easier to add a single number than it is to add a whole equation each time you want to add a new crime. Unless you have crimePERCFORM set the same for every crime, the outcomes will be different when ran through the equation.
  17. Re: V2 cars mod If i remember correctly wasn't this a free mod? I'm not sure, as the owner of the game, gave it to me and said add it....
  18. Re: V2 cars mod It looks VERY similar to one I installed for someone else months ago.
  19. Re: anoying if he keeps changing ip's you are probably out of luck.....
  20. Re: hole page opacity. Using JS could be a problem though, as some people have it disabled in their browser options
  21. Re: Crime Formular To simplify it couldn't you replace $ec with something like this...   $ec = "\$sucrate="(($ir['will']*$r['crimePERCFORM']/2.5)+($ir['level']/4)"";   Rather then having to input an equation for each new crime, you could simply input something like 0.8 for example.... I did not TEST this, just an idea
×
×
  • Create New...