ColdK Posted October 17, 2008 Posted October 17, 2008 i was thinking of a code so if you arnt blah levle to buy the house required level you cannot buy it i was thing of this code in estate.php if($ir['hLevel'] == $ir['level'] ) { print "You Are Not The Level Required Yet"; } else { $db->query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']} WHERE userid=$userid"); print "You Baught {$np['hNAME']} ."; } } if that would work i dont know and alter the houses tabe with a new row with hLevel Please comment me and update it if it needs it thanks Quote
Alex Riley Posted October 17, 2008 Posted October 17, 2008 Re: Buy A House With Level Requirements ! Nice Add-On ColdK, Makes The Game Worth Playing More. And Even If People Do SQL Inject At Least You Have To Be A Certain Level So It Sort Of Stops That Aswell +1 Nice Work Mate Quote
HITMAN 17 Posted October 17, 2008 Posted October 17, 2008 Re: Buy A House With Level Requirements ! i like it but you have not added the sql also you need to check the spelling 'baught' 'bought' Quote
radio_active Posted October 17, 2008 Posted October 17, 2008 Re: Buy A House With Level Requirements ! ALTER TABLE `houses` ADD `hLEVEL` INT(2) NOT NULL default '0' That should work for the SQL. When i get my laptop back from repair i will post the staff_houses.php edit so you can add the hLEVEL via the panel unless someone else posts. Until then you will have to edit via the phpmyadmin. Quote
Arkvoodle` Posted October 17, 2008 Posted October 17, 2008 Re: Buy A House With Level Requirements ! ALTER TABLE `houses` ADD `hLEVEL` INT(2) NOT NULL default '0' That should work for the SQL. When i get my laptop back from repair i will post the staff_houses.php edit so you can add the hLEVEL via the panel unless someone else posts. Until then you will have to edit via the phpmyadmin. FAAAAIIILLLL This would make the max level to buy a house only two digits long meaning the max level would be 99 of course. What if people want an `hLEVEL` to be 125?. I don't see the point in messing with things, should have just left it at int(11). Also I don't think it would need a default, but it works either way I guess. ALTER TABLE `houses` ADD `hLEVEL` INT(11) NOT NULL default '0' Thank you, and good night ! Quote
MrGi Posted October 17, 2008 Posted October 17, 2008 Re: Buy A House With Level Requirements ! Yeah, I agree, It should be left at int(11). Overall nice work mate. Keep it up Quote
Arkvoodle` Posted October 17, 2008 Posted October 17, 2008 Re: Buy A House With Level Requirements ! Btw that was actually constructive critisism, sorry if I sounded like I was beeing an ass, I was meaning it to be an 'FYI' sort of thing. lol. But yeah good work ;) Quote
ColdK Posted October 17, 2008 Author Posted October 17, 2008 Re: [mccode] Buy A House With Level Requirements ! thanks for your comments and help i will try and do the staff_houses Quote
shaved92bravada Posted October 17, 2008 Posted October 17, 2008 Re: [mccode] Buy A House With Level Requirements ! I will go ahead and post it anyway in here so its all together. This is the staff_houses edit that was needed replace this function addhouse() { global $db, $ir, $c, $h, $userid; $price=abs((int) $_POST['price']); $will=abs((int) $_POST['will']); $name=$_POST['name']; if($price and $will and $name) { $q=$db->query("SELECT * FROM houses WHERE hWILL={$will}"); if($db->num_rows($q)) { print "Sorry, you cannot have two houses with the same maximum will."; $h->endpage(); exit; } $db->query("INSERT INTO houses VALUES(NULL, '$name', '$price', '$will')"); print "House {$name} added to the game."; stafflog_add("Created House $name"); } else { print "<h3>Add House</h3><hr /> <form action='staff_houses.php?action=addhouse' method='post'> Name: <input type='text' name='name' /> Price: <input type='text' name='price' /> Max Will: <input type='text' name='will' /> <input type='submit' value='Add House' /></form>"; } } function edithouse() { global $db, $ir, $c, $h, $userid; switch($_POST['step']) { case "2": $price=abs((int) $_POST['price']); $will=abs((int) $_POST['will']); $q=$db->query("SELECT * FROM houses WHERE hWILL={$will} AND hID!={$_POST['id']}"); if($db->num_rows($q)) { print "Sorry, you cannot have two houses with the same maximum will."; $h->endpage(); exit; } $name=$_POST['name']; $q=$db->query("SELECT * FROM houses WHERE hID={$_POST['id']}"); $old=$db->fetch_row($q); if($old['hWILL'] == 100 && $old['hWILL'] != $will) { die("Sorry, this house's will bar cannot be edited."); } $db->query("UPDATE houses SET hWILL=$will, hPRICE=$price, hNAME='$name' WHERE hID={$_POST['id']}"); $db->query("UPDATE users SET maxwill=$will WHERE maxwill={$old['hWILL']}"); $db->query("UPDATE users SET will=maxwill WHERE will > maxwill"); print "House $name was edited successfully."; stafflog_add("Edited house $name"); break; case "1": $q=$db->query("SELECT * FROM houses WHERE hID={$_POST['house']}"); $old=$db->fetch_row($q); print "<h3>Editing a House</h3><hr /> <form action='staff_houses.php?action=edithouse' method='post'> <input type='hidden' name='step' value='2' /> <input type='hidden' name='id' value='{$_POST['house']}' /> Name: <input type='text' name='name' value='{$old['hNAME']}' /> Price: <input type='text' name='price' value='{$old['hPRICE']}' /> Max Will: <input type='text' name='will' value='{$old['hWILL']}' /> <input type='submit' value='Edit House' /></form>"; break; default: print "<h3>Editing a House</h3><hr /> <form action='staff_houses.php?action=edithouse' method='post'> <input type='hidden' name='step' value='1' /> House: ".house_dropdown($c, "house")." <input type='submit' value='Edit House' /></form>"; break; } } with this function addhouse() { global $db, $ir, $c, $h, $userid; $price=abs((int) $_POST['price']); $will=abs((int) $_POST['will']); $level=abs((int) $_POST['level']); $name=$_POST['name']; if($price and $will and $name) { $q=$db->query("SELECT * FROM houses WHERE hWILL={$will}"); if($db->num_rows($q)) { print "Sorry, you cannot have two houses with the same maximum will."; $h->endpage(); exit; } $db->query("INSERT INTO houses VALUES(NULL, '$name', '$price', '$will', '$level' )"); print "House {$name} added to the game."; stafflog_add("Created House $name"); } else { print "<h3>Add House</h3><hr /> <form action='staff_houses.php?action=addhouse' method='post'> Name: <input type='text' name='name' /> Price: <input type='text' name='price' /> Max Will: <input type='text' name='will' /> Required Level: <input type='text' name='level' /> <input type='submit' value='Add House' /></form>"; } } function edithouse() { global $db, $ir, $c, $h, $userid; switch($_POST['step']) { case "2": $price=abs((int) $_POST['price']); $will=abs((int) $_POST['will']); $level=abs((int) $_POST['level']); $q=$db->query("SELECT * FROM houses WHERE hWILL={$will} AND hID!={$_POST['id']}"); if($db->num_rows($q)) { print "Sorry, you cannot have two houses with the same maximum will."; $h->endpage(); exit; } $name=$_POST['name']; $q=$db->query("SELECT * FROM houses WHERE hID={$_POST['id']}"); $old=$db->fetch_row($q); if($old['hWILL'] == 100 && $old['hWILL'] != $will) { die("Sorry, this house's will bar cannot be edited."); } $db->query("UPDATE houses SET hLEVEL=$level, hWILL=$will, hPRICE=$price, hNAME='$name' WHERE hID={$_POST['id']}"); $db->query("UPDATE users SET maxwill=$will WHERE maxwill={$old['hWILL']}"); $db->query("UPDATE users SET will=maxwill WHERE will > maxwill"); print "House $name was edited successfully."; stafflog_add("Edited house $name"); break; case "1": $q=$db->query("SELECT * FROM houses WHERE hID={$_POST['house']}"); $old=$db->fetch_row($q); print "<h3>Editing a House</h3><hr /> <form action='staff_houses.php?action=edithouse' method='post'> <input type='hidden' name='step' value='2' /> <input type='hidden' name='id' value='{$_POST['house']}' /> Name: <input type='text' name='name' value='{$old['hNAME']}' /> Price: <input type='text' name='price' value='{$old['hPRICE']}' /> Max Will: <input type='text' name='will' value='{$old['hWILL']}' /> Required Level: <input type='text' name='level' value='{$old['hLEVEL']}' /> <input type='submit' value='Edit House' /></form>"; break; default: print "<h3>Editing a House</h3><hr /> <form action='staff_houses.php?action=edithouse' method='post'> <input type='hidden' name='step' value='1' /> House: ".house_dropdown($c, "house")." <input type='submit' value='Edit House' /></form>"; break; } } Quote
radio_active Posted October 18, 2008 Posted October 18, 2008 Re: Buy A House With Level Requirements ! ALTER TABLE `houses` ADD `hLEVEL` INT(2) NOT NULL default '0' That should work for the SQL. When i get my laptop back from repair i will post the staff_houses.php edit so you can add the hLEVEL via the panel unless someone else posts. Until then you will have to edit via the phpmyadmin. FAAAAIIILLLL This would make the max level to buy a house only two digits long meaning the max level would be 99 of course. What if people want an `hLEVEL` to be 125?. I don't see the point in messing with things, should have just left it at int(11). Also I don't think it would need a default, but it works either way I guess. ALTER TABLE `houses` ADD `hLEVEL` INT(11) NOT NULL default '0' Thank you, and good night ! The sql works perfectly and i set it at 2 for a reason, sure your going to need ( 11,000,000,000) as the default for a house number. I use INT(2) in my own game, sure change it if you need it but that is not a fail as it works perfectly. OF course it needs a default, if you add a new house and the level isnt set its going to bring an error without the default. Also i use INT(2) etc because everyone uses INT(11) because thats all they know. Why follow the others, be creaive and different. Quote
Alex Riley Posted October 18, 2008 Posted October 18, 2008 Re: [mccode] Buy A House With Level Requirements ! Radio Actives SQL Works I Tested It On A Site :), So Can We Have No More Copying What People Just Said It's Kind Of Annoying :) Thanks Radio_Active :) Quote
radio_active Posted October 18, 2008 Posted October 18, 2008 Re: [mccode] Buy A House With Level Requirements ! Radio Actives SQL Works I Tested It On A Site :), So Can We Have No More Copying What People Just Said It's Kind Of Annoying :) Thanks Radio_Active :) No problems :-) Quote
Arkvoodle` Posted October 18, 2008 Posted October 18, 2008 Re: Buy A House With Level Requirements ! ALTER TABLE `houses` ADD `hLEVEL` INT(2) NOT NULL default '0' That should work for the SQL. When i get my laptop back from repair i will post the staff_houses.php edit so you can add the hLEVEL via the panel unless someone else posts. Until then you will have to edit via the phpmyadmin. FAAAAIIILLLL This would make the max level to buy a house only two digits long meaning the max level would be 99 of course. What if people want an `hLEVEL` to be 125?. I don't see the point in messing with things, should have just left it at int(11). Also I don't think it would need a default, but it works either way I guess. ALTER TABLE `houses` ADD `hLEVEL` INT(11) NOT NULL default '0' Thank you, and good night ! The sql works perfectly and i set it at 2 for a reason, sure your going to need ( 11,000,000,000) as the default for a house number. I use INT(2) in my own game, sure change it if you need it but that is not a fail as it works perfectly. OF course it needs a default, if you add a new house and the level isnt set its going to bring an error without the default. Also i use INT(2) etc because everyone uses INT(11) because thats all they know. Why follow the others, be creaive and different. *cough* Jesus. Like I said before, That ony allows people to have an "hLEVEL" of max 99 and min 1. So what if someone wanted an "hLEVEL" of 100? (rhetorical) That is why it should just be left as it is. So what if everyone else has it that way? (also rhetorical) It actually amazes me at how ignorant people are these days... Quote
radio_active Posted October 18, 2008 Posted October 18, 2008 Re: [mccode] Buy A House With Level Requirements ! *Ignorant he says* Im finding that rather hypocrytical at the moment. You fail to understand that there are games that dont allow people over level 100, or they have slow level climbing ill call first to mind. TORN CITY - Highest level is maybe 70 and thats over 1400 days. If people want to have higher levels then put INT(11) its not that hard to comprehend dude. Ofcourse i dont use int(2) for everything but for things like this i do, whats the point as i say before for allowing levels such as (99,999,999,999) as max level for a house, i mean wtf? And you call me ignorant when your blatent to the point of this subject. I dont need your advice on what code i need for my forumlas on my game as i do not waste space, i choose the correct setting for each row in every table and if i used that, i would only need a 2. So do not reply to this because it will be just another post with no concept or idea, just trying to prove yourself when there is nothing to prove accept your wrong in the circumstances im in. Thats all Quote
zyziva Posted October 29, 2008 Posted October 29, 2008 Re: [mccode] Buy A House With Level Requirements ! Hey, hope this isn't a newb post, but I found the code to add to estate.php to work good with: else if($ir['hLevel'] < $ir['level'] ){ print "You Are Not The Level Required Yet.";} For some reason the other didn't work for me.. anyway, just posting this in case it is helpful. Quote
Guest Anonymous Posted October 29, 2008 Posted October 29, 2008 Re: [mccode] Buy A House With Level Requirements ! Lets just try a little test: DROP TABLE IF EXISTS `Sample`; CREATE TABLE IF NOT EXISTS `Sample` ( `id` int(10) unsigned NOT NULL, `value` int(2) unsigned NOT NULL ) ENGINE=MyISAM; INSERT INTO `Sample` (`id`, `value`) VALUES (456, 456), (123, 123); SELECT * FROM `Sample`; +-----+-------+ | id | value | +-----+-------+ | 456 | 456 | | 123 | 123 | +-----+-------+ Looks like restricting the field width with INT(2) just doesn't work anyway. How odd... Quote
-Matt- Posted October 31, 2008 Posted October 31, 2008 Re: [mccode] Buy A House With Level Requirements ! Lets just try a little test: DROP TABLE IF EXISTS `Sample`; CREATE TABLE IF NOT EXISTS `Sample` ( `id` int(10) unsigned NOT NULL, `value` int(2) unsigned NOT NULL ) ENGINE=MyISAM; INSERT INTO `Sample` (`id`, `value`) VALUES (456, 456), (123, 123); SELECT * FROM `Sample`; +-----+-------+ | id | value | +-----+-------+ | 456 | 456 | | 123 | 123 | +-----+-------+ Looks like restricting the field width with INT(2) just doesn't work anyway. How odd... Whats the point posting somthing hardly anyone understands. Quote
Blackdogg Posted November 14, 2008 Posted November 14, 2008 Re: [mccode] Buy A House With Level Requirements ! i love the idea but its just not working for me :( Also can you do the same kind of thing with weapons?? Quote
Guest Anonymous Posted November 14, 2008 Posted November 14, 2008 Re: [mccode] Buy A House With Level Requirements ! Hehe - It's is surprisingly basic stuff really. It's even in the manual! It's also a question that crops up from time to time here and in chat and people who actually try it and realize what the results mean usually end up having a better understanding of the language itself. Quote
Blackdogg Posted November 17, 2008 Posted November 17, 2008 Re: [mccode] Buy A House With Level Requirements ! The original mod still isnt working for me anyone got any ideas Quote
gurpreet Posted January 3, 2009 Posted January 3, 2009 Re: [mccode] Buy A House With Level Requirements ! Same here, I set the level to 50 for 1 house, and people under 50 can buy it. Quote
gurpreet Posted January 3, 2009 Posted January 3, 2009 Re: [mccode] Buy A House With Level Requirements ! WOWOWOWO is it just me or is this totally wrong? if($ir['hLevel'] == $ir['level'] ) { print "You Are Not The Level Required Yet"; } else { $db->query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']} WHERE userid=$userid"); print "You Baught {$np['hNAME']} ."; } } If the house level equals your level, you are NOT required level? I think you got it the wrong way round. Quote
gurpreet Posted January 3, 2009 Posted January 3, 2009 Re: [mccode] Buy A House With Level Requirements ! if($ir['hLevel'] > $ir['level'] ) { print "You Are Not The Level Required Yet"; } else { $db->query("UPDATE users SET money=money-{$np['hPRICE']},will=0,maxwill={$np['hWILL']} WHERE userid=$userid"); print "You Baught {$np['hNAME']} ."; } } Quote
Blackdogg Posted January 3, 2009 Posted January 3, 2009 Re: [mccode] Buy A House With Level Requirements ! this is still letting me buy houses above my users lvl :? Quote
POG1 Posted January 3, 2009 Posted January 3, 2009 Re: [mccode] Buy A House With Level Requirements ! Lets just try a little test: DROP TABLE IF EXISTS `Sample`; CREATE TABLE IF NOT EXISTS `Sample` ( `id` int(10) unsigned NOT NULL, `value` int(2) unsigned NOT NULL ) ENGINE=MyISAM; INSERT INTO `Sample` (`id`, `value`) VALUES (456, 456), (123, 123); SELECT * FROM `Sample`; +-----+-------+ | id | value | +-----+-------+ | 456 | 456 | | 123 | 123 | +-----+-------+ Looks like restricting the field width with INT(2) just doesn't work anyway. How odd... The answer is to use TINYINT right? A signed TINYINT can go from -127 to +127 which is more than enough needed. If i am correct the number in brackets (e.g INT(11)) or "display width" is for returning the value, therefore the display width wouldn't restrict data held in the field. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.