Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
talkietalkie - MySQLi based chat
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Macemore" data-source="post: 273682" data-attributes="member: 6113"><p>in post.php there's two commands already in there (Current released version).</p><p>What I do is I copy one already made, the version I have on my pc has more commands, I'll link that in the bottom.</p><p>[PHP]</p><p> if (substr($message, 0, 1) == '/' && substr($message, 1) == 'clear') {</p><p> if ($rank == 1) {</p><p> $mysqli->query("TRUNCATE TABLE messages");</p><p> } else {</p><p> return false;</p><p> }</p><p> }</p><p>[/PHP]</p><p>That's your standard clear command</p><p>if you don't understand php very well I'm not going to make a tutorial for that too, lrn2php on google.</p><p>$message is the message the user tried to send, the if statement gets $message's first character (a b ? etc.) and checks</p><p>if it's a "/", standard for commands but you can use anything you want. I suggest you learn substr for more advanced commands (ones with more variables).</p><p></p><p>The ban command I made basically changed the users rank to 2, in the database rank value can be 0, or a 1, 1 being admin. I changed the table so that 2 is banned (it would be better to have 0 as banned 1 as user and 2 as admin).</p><p>[PHP]</p><p> if (substr($message, 0, 1) == '/' && substr($message, 1, 3) == 'ban') {</p><p> if ($rank == 1) {</p><p> $variables = explode(" ", $message);</p><p> $username = substr($variables[1], 0);</p><p> $username1 = 'Server';</p><p> $thepost = "{$username} has been banned";</p><p></p><p> $mysqli->query("UPDATE `users` SET rank='2' WHERE username = '{$username}'");</p><p> $mysqli->query("INSERT INTO `messages` (user, message, timestamp) VALUES ('$username1', '$thepost', '$time')");</p><p> } else {</p><p> return false;</p><p> }</p><p> }</p><p> </p><p> //unban (literally the opposite of the obove)</p><p> if (substr($message, 0, 1) == '/' && substr($message, 1, 5) == 'unban') {</p><p> if ($rank == 1) {</p><p> $variables = explode(" ", $message);</p><p> $username = substr($variables[1], 0);</p><p> $username1 = 'Server';</p><p> $thepost = "{$username} has been unbanned";</p><p></p><p> $mysqli->query("UPDATE `users` SET rank='0' WHERE username = '{$username}'");</p><p> $mysqli->query("INSERT INTO `messages` (user, message, timestamp) VALUES ('$username1', '$thepost', '$time')");</p><p> } else {</p><p> return false;</p><p> }</p><p> }</p><p>[/PHP]</p><p>Here's the current running version on gamma.mace.pw:</p><p><a href="http://sharefa.st/view/uwYTG2PzzPO0" target="_blank">http://sharefa.st/view/uwYTG2PzzPO0</a></p><p></p><p>Here's an example configuration for /commands to list all commands</p><p>[PHP]</p><p> if (substr($message, 0, 1) == '/' && substr($message, 1, 8) == 'commands') {</p><p> $nm = "Available commands:\n</p><p> +1 [user] - adds one to a user\n</p><p> -1 [user] - removes one from a user\n</p><p> /op [user] - makes a user admin \n</p><p> /clear - removes all messages\n</p><p> /color [user] #[color] - changes a user's color\n</p><p> /mfw [link to image] [words] - does 4chan style mfw\n</p><p> >[words] - 4chan green text\n";</p><p> $user = 'Server';</p><p> $mysqli->query("INSERT INTO `messages` (user, message, timestamp) VALUES ('$user', '$message', '$time')");</p><p> }</p><p>[/PHP]</p><p>inside the quotes from "Available" to "green text\n" you can add any commands you've made yourself using \n to make a new line.</p><p>I haven't tested this.</p></blockquote><p></p>
[QUOTE="Macemore, post: 273682, member: 6113"] in post.php there's two commands already in there (Current released version). What I do is I copy one already made, the version I have on my pc has more commands, I'll link that in the bottom. [PHP] if (substr($message, 0, 1) == '/' && substr($message, 1) == 'clear') { if ($rank == 1) { $mysqli->query("TRUNCATE TABLE messages"); } else { return false; } } [/PHP] That's your standard clear command if you don't understand php very well I'm not going to make a tutorial for that too, lrn2php on google. $message is the message the user tried to send, the if statement gets $message's first character (a b ? etc.) and checks if it's a "/", standard for commands but you can use anything you want. I suggest you learn substr for more advanced commands (ones with more variables). The ban command I made basically changed the users rank to 2, in the database rank value can be 0, or a 1, 1 being admin. I changed the table so that 2 is banned (it would be better to have 0 as banned 1 as user and 2 as admin). [PHP] if (substr($message, 0, 1) == '/' && substr($message, 1, 3) == 'ban') { if ($rank == 1) { $variables = explode(" ", $message); $username = substr($variables[1], 0); $username1 = 'Server'; $thepost = "{$username} has been banned"; $mysqli->query("UPDATE `users` SET rank='2' WHERE username = '{$username}'"); $mysqli->query("INSERT INTO `messages` (user, message, timestamp) VALUES ('$username1', '$thepost', '$time')"); } else { return false; } } //unban (literally the opposite of the obove) if (substr($message, 0, 1) == '/' && substr($message, 1, 5) == 'unban') { if ($rank == 1) { $variables = explode(" ", $message); $username = substr($variables[1], 0); $username1 = 'Server'; $thepost = "{$username} has been unbanned"; $mysqli->query("UPDATE `users` SET rank='0' WHERE username = '{$username}'"); $mysqli->query("INSERT INTO `messages` (user, message, timestamp) VALUES ('$username1', '$thepost', '$time')"); } else { return false; } } [/PHP] Here's the current running version on gamma.mace.pw: [url]http://sharefa.st/view/uwYTG2PzzPO0[/url] Here's an example configuration for /commands to list all commands [PHP] if (substr($message, 0, 1) == '/' && substr($message, 1, 8) == 'commands') { $nm = "Available commands:\n +1 [user] - adds one to a user\n -1 [user] - removes one from a user\n /op [user] - makes a user admin \n /clear - removes all messages\n /color [user] #[color] - changes a user's color\n /mfw [link to image] [words] - does 4chan style mfw\n >[words] - 4chan green text\n"; $user = 'Server'; $mysqli->query("INSERT INTO `messages` (user, message, timestamp) VALUES ('$user', '$message', '$time')"); } [/PHP] inside the quotes from "Available" to "green text\n" you can add any commands you've made yourself using \n to make a new line. I haven't tested this. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
talkietalkie - MySQLi based chat
Top