Xethenic Posted January 16, 2013 Share Posted January 16, 2013 Hi mwg i have recently purchased nwe. i am not the best coder in the end i class myself a bit of a newbie. i am asking for help and i am struggling with the nwe code. I am trying to convert a McC v2 mod to work with nwe but my conversion attempt is pretty poor! I was just wondering if more conversion tutorials i have been using some bits of nw-engine.com - $userid => $userID - $ir["something"] => $userStats["something"]->value - removes the include of global.php - removes the $h->endpage - mysql_query("something") => $db->Execute("something") - $db->query("something") => $db->Execute("something") - mysql_insert_id => $db->LastId() - mysql_num_rows($q) => $q->NbRows - $db->num_rows($q) => $q->NbRows - item_add(...) => Item::InventoryAdd(...) - item_remove(...) => Item::InventoryRemove(...) - event_add(...) => SotrePersonalLog(...) - Adds the Translate function around the echo and print strings. But with others i am getting stuck Appreciate your time Thank you Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2013 Share Posted January 16, 2013 You may check this: http://makewebgames.io/showthread.php/42433-Free-V1-V2-MOD-Horse-Racing-ported-to-NWE It's a port of a McCode module to NWE... Not only port but nearly a re-write. If that's not enough you need to say exactly what are your problems and then we can dig into it. Quote Link to comment Share on other sites More sharing options...
Xethenic Posted January 16, 2013 Author Share Posted January 16, 2013 Thanks B for your reply I have been trying to follow horse racing actually Right i am having trouble with $_POST['bet']=strip_tags($_POST['bet']); after the hint " HINT: If you are accessing a GET or POST, make sure to use the isset function." I changed the line to $_POST['bet']=strip_tags(isset($_POST['bet']); now i get Error: syntax error, unexpected ';' HINT: Maybe you forget to put a ; sign at the end of a line. Not sure what is causing the error as i say i am not a strong coder but i like to try Thanks Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 16, 2013 Share Posted January 16, 2013 You are missing an ending ) on your line before the ; $_POST['bet']=strip_tags(isset($_POST['bet'])); Greg Quote Link to comment Share on other sites More sharing options...
Someone Posted January 16, 2013 Share Posted January 16, 2013 $userid is $userId (small id) in NWE This depends on how the query was made. - mysql_num_rows($q) => $q->NbRows - $db->num_rows($q) => $q->NbRows $db->Execute("SELECT username FROM users"); or if using a variable in the query $db->Execute("SELECT username FROM users WHERE id = ? LIMIT 1", $id); $db->Execute("UPDATE users SET email = ? WHERE id = ? LIMIT 1", $newemail, $id); post a snippet, or tell us an example of what you want done Quote Link to comment Share on other sites More sharing options...
Someone Posted January 16, 2013 Share Posted January 16, 2013 By default NWE will strip the tags for you, so you can remove the line. However this would have worked if( isset($_POST['bet'])) ){ $_POST['bet'] = strip_tags($_POST['bet']); } Quote Link to comment Share on other sites More sharing options...
Xethenic Posted January 16, 2013 Author Share Posted January 16, 2013 You are missing an ending ) on your line before the ; $_POST['bet']=strip_tags(isset($_POST['bet'])); Greg Yeah that work thanks greg but now i just have a blank page. (My crappy conversion) $userid is $userId (small id) in NWE This depends on how the query was made. - mysql_num_rows($q) => $q->NbRows - $db->num_rows($q) => $q->NbRows $db->Execute("SELECT username FROM users"); or if using a variable in the query $db->Execute("SELECT username FROM users WHERE id = ? LIMIT 1", $id); $db->Execute("UPDATE users SET email = ? WHERE id = ? LIMIT 1", $newemail, $id); post a snippet, or tell us an example of what you want done Oh god looking at your exmaple i have made a total shambles of my conversion! Not sure i want to show you what i have done lol i'm embarrassed Quote Link to comment Share on other sites More sharing options...
Someone Posted January 16, 2013 Share Posted January 16, 2013 First of I said small id, I meant small d. You'd learn more if you rebuilt the module step by step, instead of plain out converting line for line. Start out with making a module in the admin panel if you have not done so already, then make the look of the page in the created content.php And perhaps look at how other similar modules to what you are making work. If you dont manage to overcome the embarrassment you can PM me, and Ill try to help. Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 16, 2013 Share Posted January 16, 2013 Or just put what you are doing here. We are very helpful and will not embarrass you. I embarrass myself enough for everyone. Greg Quote Link to comment Share on other sites More sharing options...
JamesRage Posted January 16, 2013 Share Posted January 16, 2013 Hey guys, I don't have a NWE license or any of the codes for it, and I've used all the tips in this forum and another, and managed to create a Safe-cracker mod (originally made for MCCodes V2 but converted for NWE by me), I definitely know theres something wrong with it, but I'll leave it up-to you guys, please tell whats wrong and I'll try to adjust it, my first go at it. (: <?php if(isset($_POST['submit'])) { $three = rand(100,110); if($_POST['firstthree'] != $three) { ErrorMessage(Translate("Error, Wrong Combination!"); exit(0); } $two = rand(20,30); if($_POST['secondtwo'] != $two) { ErrorMessage(Translate("Error, Wrong Combination!"; exit(0); } $one = rand(1,9); if($_POST['lastone'] != $one) { ErrorMessage(Translate("Error, Wrong Combination!"); exit(0); } else if($_POST['firstthree'] == $three && $_POST['secondtwo'] == $two && $_POST['lastone'] == $one) { echo Translate("You press the numbers [{$_POST['firstthree']}][{$_POST['secondtwo']}][{$_POST['lastone']}]<br /> <font color='green' size='5'>Right Combination! Congratulations!</font>"); $muny=rand(10000,400000); $crys=rand(20,50); $db->Execute("UPDATE `users` SET !Currency=!Currency+{$muny},crystals=crystals+{$crys} WHERE userID=$userID"); } } else { echo "<form action='safecracker.php' method='post'> First Three: [<input type='text' name='firstthree' length='3' maxlength='3'>] <sup>Hint: 100 - 110</sup><br /> Second Two: [<input type='text' name='secondtwo' length='2' maxlength='2'>] <sup>Hint: 20 - 30</sup><br /> Last One: [<input type='text' name='lastone' length='1' maxlength='1'>] <sup>Hint: 1 - 9</sup><br /> <input type='submit' name='submit' value='Submit!'> </form>"; } Thanks! Quote Link to comment Share on other sites More sharing options...
Someone Posted January 16, 2013 Share Posted January 16, 2013 (edited) Hey guys, I don't have a NWE license or any of the codes for it, and I've used all the tips in this forum and another, and managed to create a Safe-cracker mod (originally made for MCCodes V2 but converted for NWE by me), I definitely know theres something wrong with it, but I'll leave it up-to you guys, please tell whats wrong and I'll try to adjust it, my first go at it. (: Thanks! if(isset($_POST['submit'])) { $three = rand(100,110); if($_POST['firstthree'] != $three) { ErrorMessage(Translate("Error, Wrong Combination!")); // Mising ) return; //Stop executing content.php } $two = rand(20,30); if($_POST['secondtwo'] != $two) { ErrorMessage(Translate("Error, Wrong Combination!")); // Mising ) return; } $one = rand(1,9); if($_POST['lastone'] != $one) { ErrorMessage(Translate("Error, Wrong Combination!")); // Mising ) return; } else if($_POST['firstthree'] == $three && $_POST['secondtwo'] == $two && $_POST['lastone'] == $one) { echo Translate("You press the numbers [{$_POST['firstthree']}][{$_POST['secondtwo']}][{$_POST['lastone']}] <font color='green' size='5'>Right Combination! Congratulations!</font>"); $muny=rand(10000,400000); $crys=rand(20,50); $userStats['!Currency']->value += $muny; $userStats['crystals']->value += $crys; //This assumes that a crystals stat has been made in the user_stat_types table // This will not work, stats are not stored that way in NWE //$db->Execute("UPDATE `users` SET !Currency=!Currency+{$muny},crystals=crystals+{$cr ys} WHERE userID=$userID"); } } else { echo "<form action='safecracker.php' method='post'> First Three: [<input type='text' name='firstthree' length='3' maxlength='3'>] <sup>Hint: 100 - 110</sup> Second Two: [<input type='text' name='secondtwo' length='2' maxlength='2'>] <sup>Hint: 20 - 30</sup> Last One: [<input type='text' name='lastone' length='1' maxlength='1'>] <sup>Hint: 1 - 9</sup> <input type='submit' name='submit' value='Submit!'> </form>"; } Should perhaps be its own thred, but here is my reply anyways. Added comments where there was problems EDit: I also see now that the form action points to safecracker.php Sould instead look into using http://www.nw-engine.com/wiki/index.php/SubmitButton Edited January 16, 2013 by Someone Quote Link to comment Share on other sites More sharing options...
Someone Posted January 16, 2013 Share Posted January 16, 2013 (edited) Here is a fully working version, although the html does not fit the default theme 100% print_r($_POST); //Remove or comment out when not testing if(isset($_POST['firstthree']) && isset($_POST['secondtwo']) && isset($_POST['lastone']) ) { $three = rand(100,110); if($_POST['firstthree'] != $three) { ErrorMessage(Translate("Error, Wrong Combination!")); // Mising ) return; //Stop executing content.php } $two = rand(20,30); if($_POST['secondtwo'] != $two) { ErrorMessage(Translate("Error, Wrong Combination!")); // Mising ) return; } $one = rand(1,9); if($_POST['lastone'] != $one) { ErrorMessage(Translate("Error, Wrong Combination!")); // Mising ) return; } else if($_POST['firstthree'] == $three && $_POST['secondtwo'] == $two && $_POST['lastone'] == $one) { echo Translate("You press the numbers [{$_POST['firstthree']}][{$_POST['secondtwo']}][{$_POST['lastone']}] <font color='green' size='5'>Right Combination! Congratulations!</font>"); $muny=rand(10000,400000); $crys=rand(20,50); $userStats['!Currency']->value += $muny; //$userStats['crystals']->value += $crys; //This assumes that a crystals stat has been made in the user_stat_types table // This will not work //$db->Execute("UPDATE `users` SET !Currency=!Currency+{$muny},crystals=crystals+{$cr ys} WHERE userID=$userID"); } } else { echo "<form method='post' name='crack'> First Three: [<input type='text' name='firstthree' length='3' maxlength='3' style='width: 50px;'>] <sup>Hint: 100 - 110</sup> Second Two: [<input type='text' name='secondtwo' length='2' maxlength='2' style='width: 50px;'>] <sup>Hint: 20 - 30</sup> Last One: [<input type='text' name='lastone' length='1' maxlength='1' style='width: 50px;'>] <sup>Hint: 1 - 9</sup> </form>"; SubmitButton('Crack It', 'crack'); } Cleaned up shorter version if(isset($_POST['firstthree']) && isset($_POST['secondtwo']) && isset($_POST['lastone']) ) { $one = rand(1,9); $two = rand(20,30); $three = rand(100,110); if($_POST['firstthree'] != $three || $_POST['secondtwo'] != $two || $_POST['lastone'] != $one){ ErrorMessage(Translate("Error, Wrong Combination!")); return; } else { $muny=rand(10000,400000); $crys=rand(20,50); echo Translate("You press the numbers [{$_POST['firstthree']}][{$_POST['secondtwo']}][{$_POST['lastone']}] <font color='green' size='5'>Right Combination! Congratulations!</font>"); $userStats['!Currency']->value += $muny; //$userStats['crystals']->value += $crys; //This assumes that a crystals stat has been made in the user_stat_types table return; } } else { echo "<form method='post' name='crack'> First Three: [<input type='text' name='firstthree' length='3' maxlength='3' style='width: 50px;'>] <sup>Hint: 100 - 110</sup> Second Two: [<input type='text' name='secondtwo' length='2' maxlength='2' style='width: 50px;'>] <sup>Hint: 20 - 30</sup> Last One: [<input type='text' name='lastone' length='1' maxlength='1' style='width: 50px;'>] <sup>Hint: 1 - 9</sup> </form>"; SubmitButton('Crack It', 'crack'); } Edited January 16, 2013 by Someone Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 16, 2013 Share Posted January 16, 2013 I would would use the engine features instead of printing out the links and such. Also you are quiet certainly missing a menu, and maybe a config.xml file ;) Why not download the free version of the engine and try it yourself? Quote Link to comment Share on other sites More sharing options...
JamesRage Posted January 16, 2013 Share Posted January 16, 2013 I would would use the engine features instead of printing out the links ans such. Also you are quiet certainly missing a menu, and maybe a config.xml file ;) Why not download the free version of the engine and try it yourself? Okay thanks Someone for fixing and releasing the working copy, another free mod for everyone who use NWE. (: And I'll definitely try to download a free copy of NWE later on in the day Alain. ;) Quote Link to comment Share on other sites More sharing options...
Xethenic Posted January 16, 2013 Author Share Posted January 16, 2013 Okay thanks Someone for fixing and releasing the working copy, another free mod for everyone who use NWE. (: And I'll definitely try to download a free copy of NWE later on in the day Alain. ;) Thanks JamesRage for your attempt on crack the safe Thanks to someone for fixing james good effort. The mod works well Glad to have nice people in the community Quote Link to comment Share on other sites More sharing options...
Someone Posted January 16, 2013 Share Posted January 16, 2013 I did not actually mean to release it, and its not, it still needs a config file perhaps with a min and max payout setting, and a menu entry. Get a dev/full license, and submit it to the marketplace. It will be forgotten when time buries it in this thread. Not that I edited my last thread with a shorter version. Quote Link to comment Share on other sites More sharing options...
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.