Jump to content
MakeWebGames

Newbie

Members
  • Posts

    289
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Newbie

  1. i did have get id secured but i had a flaw in the code and pasted another copy and forgot to secure it again thanks for pointing that out will update code now and then add the check
  2. never mind fixed the bug now and updated org post :)
  3. Another freebie for yous guys/girls nothing special ok lets stat with the sql first CREATE TABLE IF NOT EXISTS `npc_bots` ( `id` int(20) NOT NULL AUTO_INCREMENT, `npc_name` varchar(30) COLLATE latin1_general_ci NOT NULL, `level` int(11) NOT NULL DEFAULT '0', `strength` int(11) NOT NULL DEFAULT '0', `defense` int(11) NOT NULL DEFAULT '0', `speed` int(11) NOT NULL DEFAULT '0', `hosp` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;   npc.php <?php include(__DIR__.'/header.php'); function display($id) { $check = mysql_query("SELECT `hosp` FROM `npc_bots` WHERE `id` = ".$id); $true = mysql_fetch_array($check); if($true['hosp'] > 0) { return "<span style='color:red'>Dead</span>"; } else { return "<span style='color:green'>Alive</span>"; } } function displaystats($id) { $check = mysql_query("SELECT `strength`,`speed`,`defense` FROM `npc_bots` WHERE `id` = ".$id); $true = mysql_fetch_array($check); $total = $true['strength'] + $true['defense'] + $true['speed']; return number_format($total); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(intval($_GET['ID'])) : null; if(isset($_GET['attack'])) { $res = mysql_query("SELECT `hosp`,`strength`,`speed`,`defense`,`npc_name` FROM `npc_bots` WHERE `id` = ".$_GET['ID']); $num = mysql_num_rows($res); $row = mysql_fetch_array($res); if($row['hosp'] > 0) { echo Message('You can not attack this npc as he is already dead.'); include(__DIR__.'/footer.php'); exit; } if($num < 1) { echo Message('Invalid ID'); include(__DIR__.'/footer.php'); exit; } if($user_class->energypercent < 25) { echo Message('You need to have atleast 25% energy to attack a npc'); include(__DIR__.'/footer.php'); exit; } $newenergy = $user_class->energy - floor($user_class->energy * .25); if($user_class->energypercent > 25) { if($user_class->strength > $row['strength'] && $user_class->defense > $row['defense']) { echo Message('You take a shot at '.$row['npc_name'].' and hit him in the head You killed the npc.'); mysql_query("UPDATE `npc_bots` SET `hosp` = '20' WHERE `id` = ".$_GET['ID']); mysql_query("UPDATE `grpgusers` SET `money` = `money` + '500', `energy` = ".$newenergy." WHERE `id` = ".$_SESSION['id']); } if($user_class->strength < $row['strength'] && $user_class->defense < $row['defense']) { echo Message('You hit '.$row['npc_name'].' in the leg as he was falling to the ground he fired 1 last bullet and killed you.'); mysql_query("UPDATE `grpgusers` SET `hospital` = '1200', `energy` = ".$newenergy." WHERE `id` = ".$_SESSION['id']); } } } ?> <tr><td class="contenthead">NPC Page</td></tr> <tr><td class="contentcontent"> <table width="75%"> <tr style='background:gray'> <th>NPC</th> <th>Level</th> <th>Total Stats</th> <th>Alive/Dead</th> <th>Time Left</th> <th> </th> </tr> <?php $res = mysql_query("SELECT * FROM `npc_bots` ORDER BY `id`"); while($row = mysql_fetch_array($res)) { echo "<tr style='background:#181818'> <td>{$row['npc_name']}</td> <td>{$row['level']}</td> <td>".displaystats($row['id'])."</td> <td>".display($row['id'])."</td> <td>{$row['hosp']} minutes</td> <td><a href='npc.php?attack&ID={$row['id']}'>Attack NPC</a></td> </tr>"; } ?> </table> </td></tr> <?php include(__DIR__.'/footer.php'); ?>   staff_npc.php <?php include(__DIR__.'/header.php'); $_POST['name'] = isset($_POST['name']) && strlen($_POST['name']) > 0 ? mysql_real_escape_string($_POST['name']) : null; $_POST['level'] = isset($_POST['level']) && ctype_digit($_POST['level']) ? abs(intval($_POST['level'])) : null; $_POST['strength'] = isset($_POST['strength']) && ctype_digit($_POST['strength']) ? abs(intval($_POST['strength'])) : null; $_POST['defense'] = isset($_POST['defense']) && ctype_digit($_POST['defense']) ? abs(intval($_POST['defense'])) : null; $_POST['speed'] = isset($_POST['speed']) && ctype_digit($_POST['speed']) ? abs(intval($_POST['speed'])) : null; if(!$user_class->admin) { echo Message('Admins Only.'); include(__DIR__.'/footer.php'); exit; } if(isset($_POST['create'])) { $res = mysql_query("SELECT * FROM `npc_bots`"); $row = mysql_fetch_array($res); if(empty($_POST['name'])) { echo Message('Invalid Name.'); include(__DIR__.'/footer.php'); exit; } if(empty($_POST['level'])) { echo Message('Invalid Level.'); include(__DIR__.'/footer.php'); exit; } if(empty($_POST['strength'])) { echo Message('Invalid Strength.'); include(__DIR__.'/footer.php'); exit; } if(empty($_POST['defense'])) { echo Message('Invalid Defense.'); include(__DIR__.'/footer.php'); exit; } if(empty($_POST['speed'])) { echo Message('Invalid Speed.'); include(__DIR__.'/footer.php'); exit; } if(!is_numeric($_POST['level'])) { echo Message('Level Must be a number.'); include(__DIR__.'/footer.php'); exit; } if(!is_numeric($_POST['strength'])) { echo Message('Strength Must be a number.'); include(__DIR__.'/footer.php'); exit; } if($_POST['name'] != $row['npc_name']) { echo Message('Npc character created.'); mysql_query("INSERT INTO `npc_bots` VALUES(NULL,'".$_POST['name']."', '".$_POST['level']."','".$_POST['strength']."',".$_POST['defense'].",".$_POST['speed'].",'0')"); } else { echo Message('You already have a npc with this name.'); include(__DIR__.'/footer.php'); exit; } } ?> <tr><td class="contenthead">NPC Creator</td></tr> <tr><td class="contentcontent"> <table width="75%"> <form method="post"> <tr> <td>NPC Name: <input type="text" name="name" /></td> </tr> <tr> <td>Level: <input type="text" name="level" /></td> </tr> <tr> <td>Strength: <input type="text" name="strength" /></td> </tr> <tr> <td>Defense: <input type="text" name="defense" /></td> </tr> <tr> <td>Speed: <input type="text" name="speed" /></td> </tr> <tr> <td><input type="submit" name="create" value="Create NPC" /></td> </tr> </form> </table> </td></tr>   open up updates.php and add this into the min cron   mysql_query("UPDATE `npc_bots` SET `hosp` = `hosp` - 1 WHERE `hosp` > 0");
  4. the sp header is the same as the header.php but instead of showing the menu links it shows the staff links kinda useless
  5. i use grpg not got a project open yet but would like some free mods tbh there are not a lot of people who develop for it for free
  6. kinda reminds me of a tv show i watch Revolution accept they were not hit my a emp
  7. no but its on my list of mods to do if i ever get to it
  8. is it going to be free or paid work more info would help :)
  9. yeh session seems better but well done and thanks for the mod :P
  10. ah well use already took care of that now he has one for admins too :P
  11. Newbie

    Wise Crime

    lol all them people owned wise crime ?
  12. thank you guest for pointing that out. I have updated original post so you have used the code then please update new code
  13. might of read original post wrong but if i have then owell lol   if(isset($_GET['admin']) == "prison") { if($user_class->admin == 1 ) { if($user_class->jail == 0) { echo Message("You're not in prison."); } else { $result = mysql_query("UPDATE `grpgusers` SET `jail` = '0' WHERE `id`='".$_SESSION['id']."'"); echo Message("You used your corruption powers to get out of prison."); } } }   <a href='spendpoints.php?admin=prison'>Get Out of Prison</a><br />
  14. add this into classes $this->announcement = $worked['announcement'];   and add this where you want it to show   <?php if($user_class->announcement > 0) { ?> <a class="leftmenu" href="announcement.php">Announcement [<?php echo $user_class->announcement; ?>]</a> <?php } else { ?> <a class="leftmenu" href="announcement.php">Announcement [0]</a> <?php } ?>   sql CREATE TABLE IF NOT EXISTS `announcements` ( `id` int(11) NOT NULL AUTO_INCREMENT, `poster` int(11) NOT NULL DEFAULT '0', `message` varchar(255) NOT NULL DEFAULT '', `postime` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;   announcement.php <?php include(__DIR__.'/header.php'); if(isset($_POST['newannounce'])) { $_POST['newmessage'] = isset($_POST['newmessage']) && strlen($_POST['newmessage']) > 0 ? mysql_real_escape_string($_POST['newmessage']) : null; if(empty($_POST['newmessage'])) { echo Message('You did not enter a valid announcement.'); include(__DIR__.'/footer.php'); exit; } else { echo Message('You have posted your announcement.'); mysql_query("INSERT INTO `announcements` (`id`, `poster`, `message`, `postime`)"." VALUES (NULL, '$user_class->id', '".$_POST['newmessage']."', '".time()."')"); mysql_query("UPDATE `grpgusers` SET `announcement` = `announcement` + 1"); } } ?> <tr><td class='contenthead'>Announcements</td></tr> <tr><td class='contentcontent'> <table width=100% cellspacing='1'> <tr style='background:gray'> <th>Poster</th> <th>Message</th> <th>time</th> </tr> <?php if($user_class->announcement > 0) { $update = mysql_query("UPDATE `grpgusers` SET `announcement` = 0 WHERE `id` = '".$user_class->id."'"); } $res = mysql_query("SELECT * FROM `announcements` ORDER BY `postime`"); while($row = mysql_fetch_array($res)) { $poster = new User($row['poster']); echo "<tr> <td>".$poster->formattedname."</td> <td width='50%'>".$row['message']."</td> <td>".date('H:i:s d/m/Y', $row['postime'])."</td> </tr>"; } echo "</table>"; ?> </td></tr> <?php if($user_class->admin) { ?> <tr><td class='contenthead'>Add Announcement</td></tr> <tr><td class='contentcontent'> <form method='post'> <table width='100%'> <tr> <th>Message</th> <td><textarea name='newmessage' rows='10' cols='60'></textarea></td> </tr> <tr> <td><input type='submit' name='newannounce' value='Post' /></td> </tr> </table> </form> </td></tr> <?php } include(__DIR__.'/footer.php'); ?>
  15. np glad to help there is a bunch of free mods in the grpg freebies section.
  16. try   <?php include('dbcon.php'); $result = mysql_query("SELECT * FROM grpgusers ORDER BY hourlyattacks DESC LIMIT 1"); $fetch = mysql_fetch_array($result); $usr = new User($fetch['id']); $newpoints = $usr->points + 10; Send_Event($usr->id, "You won mobster of the hour with ".$fetch['hourlyattacks'].""); $result = mysql_query("UPDATE grpgusers SET points = ".$newpoints." WHERE id = '".$usr->id."'"); $reset = mysql_query("UPDATE grpgusers SET hourlyattacks = '0'"); } ?>
  17. UPDATED but not tested   <?php include('dbcon.php'); $result = mysql_query("SELECT id, hourlyattacks FROM grpgusers WHERE hourlyattacks > 0 DESC LIMIT 1"); $fetch = mysql_fetch_array($result); $usr = new User($fetch['id']); $newpoints = $usr->points + 10; Send_Event($usr->id, "You won mobster of the hour with ".$fetch['hourlyattacks'].""); $result = mysql_query("UPDATE grpgusers SET points = ".$newpoints." WHERE id = '".$usr->id."'"); $reset = mysql_query("UPDATE grpgusers SET hourlyattacks = '0'"); } ?>
  18. i was having problem with the script check wouldnt load the image and when i did get it to load the image just kept saying invalid code so i just disabled it for now untill i got time to look at it :)
  19. ok demo is up http://nonstopcoding.x10.mx/
  20. Newbie

    Paint!

    pretty nice good job :)
  21. i must admit you way does seem better :P but i can only post what i know :P coming to think of it i don't think iv ever used the % operator before
  22. haha ok will do :P
  23. i did not know how to do that :P
  24. this is how i would do it $res = $db->query("SELECT * FROM `grpgusers` WHERE `gdays` > 0"); $row = $db->fetch_row($res); $gangdays = array( '50', '100', '150' ); $gdays = $row['gdays']; if($row['gdays'] == in_array($gdays,$gangdays)) { echo 'True'; event_add($row['userid'], "You have reached ".$row['gdays']." days in a gang well done"); } else { echo 'false'; }   just remove the echo statements and the else statement used it for testing :) also you could remove $gdays = $row['gdays']; and change if($row['gdays'] == in_array($gdays,$gangdays)) { to if($row['gdays'] == in_array($row['gdays'],$gangdays)) {   i have a bad habit of creating variables when not needed xD
  25. hey here is some stuff that might help you. http://makewebgames.io/showthread.php/40869-MySQLi-Easy-class http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
×
×
  • Create New...