Jump to content
MakeWebGames

Leaderboard

Popular Content

Showing content with the highest reputation on 09/03/2021 in all areas

  1. I quite liked MCC's crime success chance calculation. I feel it was a little lacking on the modifiers side of it as default, but easy enough to extend. I'd suggest doing something similar to it, perhaps incrementally per level range or crime level (don't know what you're intending to do). Alternatively, keep it simple with an "easy", "medium", "hard" at varying integers and use an RNG? <?php // Example // Set array of difficulties with associated percentage of success $difficulties = [ 'easy' => 95, 'medium' => 50, 'hard' => 25, 'extreme' => 10, ]; // Assume $row is an array of crime data, assume "difficulty" is a valid column name with either "easy", "medium", "hard", or "extreme" set if ($difficulties[$row['difficulty']] >= mt_rand(0, 100)) { // success } else { // fail (maybe and/or jail?) } There are many ways to achieve your desired effect; experiment as see what works for you
    2 points
  2. i did find this script a while back but it didn't have support for brackets, i keep meaning to revisit it and add the support into it. <?php function evalAsMath($str) { $error = false; $div_mul = false; $add_sub = false; $result = 0; $str = preg_replace('/[^\d\.\+\-\*\/]/i','',$str); $str = rtrim(trim($str, '/*+'),'-'); if ((strpos($str, '/') !== false || strpos($str, '*') !== false)) { $div_mul = true; $operators = array('*','/'); while(!$error && $operators) { $operator = array_pop($operators); while($operator && strpos($str, $operator) !== false) { if ($error) { break; } $regex = '/([\d\.]+)\\'.$operator.'(\-?[\d\.]+)/'; preg_match($regex, $str, $matches); if (isset($matches[1]) && isset($matches[2])) { if ($operator=='+') $result = (float)$matches[1] + (float)$matches[2]; if ($operator=='-') $result = (float)$matches[1] - (float)$matches[2]; if ($operator=='*') $result = (float)$matches[1] * (float)$matches[2]; if ($operator=='/') { if ((float)$matches[2]) { $result = (float)$matches[1] / (float)$matches[2]; } else { $error = true; } } $str = preg_replace($regex, $result, $str, 1); $str = str_replace(array('++','--','-+','+-'), array('+','+','-','-'), $str); } else { $error = true; } } } } if (!$error && (strpos($str, '+') !== false || strpos($str, '-') !== false)) { $add_sub = true; preg_match_all('/([\d\.]+|[\+\-])/', $str, $matches); if (isset($matches[0])) { $result = 0; $operator = '+'; $tokens = $matches[0]; $count = count($tokens); for ($i=0; $i < $count; $i++) { if ($tokens[$i] == '+' || $tokens[$i] == '-') { $operator = $tokens[$i]; } else { $result = ($operator == '+') ? ($result + (float)$tokens[$i]) : ($result - (float)$tokens[$i]); } } } } if (!$error && !$div_mul && !$add_sub) { $result = (float)$str; } return $error ? 0 : $result; } echo evalAsMath("2+2*8"); // = 18
    1 point
  3. MC Codes crime formula was what allowed people to drop databases if they could get access to an admin account - or reverse engineer that privilidge. It passes via eval(), which allows you to execute drop table queries. Oh, the memories and good time 😄
    1 point
  4. I'm gonna lock this thread lol
    1 point
  5. There are still a lot of people who use mc-codes, so you can't really say it's completely dead.
    1 point
  6. its not finished i posponed the project & i dont have it online but i can show some screenshots.
    1 point
  7. I've gone ahead and created an invoice for your original purchase. You'll be able to access the code under Store > Manage Purchases 🙂 Yup we're back and better than ever! New owner, new hosting, new domain (hopefully we'll get the old domain back at some point, but we shall see!)
    1 point
×
×
  • Create New...