Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have errors in your coding or want something specific added to your game? Check out our paid support here.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Chat Ban [V2]  (Read 786 times)

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Chat Ban [V2]
« on: August 07, 2009, 06:48:50 AM »
For those who have chat room, you might want to add this, Because while your members are forum banned and mail banned they can still act a fool on chat.

This Is going to go Into pieces as It might not fit In one post!

First Off add the SQL
Code: [Select]
ALTER TABLE `users` ADD `chatban` int(11) NOT NULL default '2'

ALTER TABLE `users` ADD `chat_reason` varchar(255) collate latin1_general_ci NOT NULL default '',

open your staff_punit.php And find
Code: [Select]
case 'massjailip': mass_jail(); break;
Add Under
Code: [Select]
case 'chatform': chat_user_form(); break;
case 'chatsub': chat_user_submit(); break;
case 'unchatform': chatb_user_form(); break;
case 'unchatsub': unchat_user_submit(); break;

Then find
Code: [Select]
$h->endpage();
And above It add
Code: [Select]
function chat_user_form()
{
global $db,$ir,$c,$h,$userid;
print "<h3>Chat Banning User</h3>
The user will be banned from the chat room.<br />
<form action='staff_punit.php?action=chatsub' method='post'>
User: ".user_dropdown($c,'user',$_GET['ID'])."<br />
Days: <input type='text' name='days' /><br />
Reason: <input type='text' name='reason' /><br />
<input type='submit' value='Chat Ban User' /></form>";
}
function chat_user_submit()
{
global $db,$ir,$c,$h,$userid;
$_POST['reason']=$_POST['reason'];
$re=$db->query("UPDATE users SET chatban={$_POST['days']},chat_reason='{$_POST['reason']}' WHERE userid={$_POST['user']}");
event_add($_POST['user'],"You were banned from chat for {$_POST['days']} day(s) for the following reason: {$_POST['reason']}",$c);
print "User Chat Banned.";
stafflog_add("Chat Banned User ID {$_POST['user']} for {$_POST['days']} days");
}
function chatb_user_form()
{
global $db,$ir,$c,$h,$userid;
print "<h3>Un-Chat Banning User</h3>
The user will be taken out of chat ban.<br />
<form action='staff_punit.php?action=unchatsub' method='post'>
User: ".chatb_user_dropdown($c,'user')."<br />
<input type='submit' value='Un-Chat Ban User' /></form>";
}
function unchat_user_submit()
{
global $db,$ir,$c,$h,$userid;
$db->query("UPDATE users SET chatban=0 WHERE userid={$_POST['user']}");
print "User un-chat banned.";
event_add($_POST['user'], "You were unbanned from chat. You can now use it again.", $c);
stafflog_add("Un-chat banned user ID {$_POST['user']}");
}
Logged

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Re: Chat Ban [V2]
« Reply #1 on: August 07, 2009, 06:55:43 AM »
Then open smenu.php and add these links in the "punishments area"
Code: [Select]
&gt; <a href='staff_punit.php?action=chatform'>Chat Ban User</a><br />
&gt; <a href='staff_punit.php?action=unchatform'>Un-Chat Ban User</a><br />

Then open global_func.php and find
Code: [Select]
function forumb_user_dropdown($connection,$ddname="user",$selected=-1)
{
global $db;
$ret="<select name='$ddname' type='dropdown'>";
$q=$db->query("SELECT * FROM users WHERE forumban > 0 ORDER BY username ASC");
if($selected == -1) { $first=0; } else { $first=1; }
while($r=$db->fetch_row($q))
{
$ret.="\n<option value='{$r['userid']}'";
if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
$ret.= ">{$r['username']}</option>";
}
$ret.="\n</select>";
return $ret;
}

Under that add
Code: [Select]
function chatb_user_dropdown($connection,$ddname="user",$selected=-1)
{
global $db;
$ret="<select name='$ddname' type='dropdown'>";
$q=$db->query("SELECT * FROM users WHERE chatban > 0 ORDER BY username ASC");
if($selected == -1) { $first=0; } else { $first=1; }
while($r=$db->fetch_row($q))
{
$ret.="\n<option value='{$r['userid']}'";
if ($selected == $r['userid'] || $first == 0) { $ret.=" selected='selected'";$first=1; }
$ret.= ">{$r['username']}</option>";
}
$ret.="\n</select>";
return $ret;
}


Lastly Open Up your chat page and find
Code: [Select]
include "globals.php";
Under that add
Code: [Select]
if($ir['chatban'])
{
die("<font color=red><h3>! ERROR</h3>
You have been banned from chat for {$ir['chatban']} days.<br />
<br />
<b>Reason: {$ir['chat_reason']}</font></b>");
}


And thats It, If you have any improvements, comments or questions feel free to speak :D
Logged

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Re: Chat Ban [V2]
« Reply #2 on: August 07, 2009, 07:26:18 AM »
Screenies







Logged

Twist3d Fat3

  • Basic Member
  • *
  • Reputation Power: 52
  • Twist3d Fat3 has no influence.
  • Offline Offline
  • Posts: 42
    • View Profile
Re: Chat Ban [V2]
« Reply #3 on: August 08, 2009, 05:42:42 AM »
Sorry I forgot to add the Cron

Open cron_day.php and add

Code: [Select]
$db->query("UPDATE users SET chatban=chatban-1 WHERE chatban > 0");
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: Chat Ban [V2]
« Reply #4 on: August 09, 2009, 01:21:09 AM »
Very nice
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.
 


This forum is now closed and has moved to a new location! Click here to find out why.