Pitufo™
InfinityOT.com
Well, one guy requested this in support section and i did it:
Version: 1.0
Tested in: TFS 0.3.2
Credits: Me, Gesior and the idea man(Wat)!
Features:
*Select message type (Red, green, white, etc).
*Only accounts who has more than X "page_access" in his account logged may use this.
*More in future!
Create your php file into your webserver ("htdocs", "www", or w/e u are using) and paste this:
The lua file create it in data/globalevents/scripts and create a new file and name it broadcast.lua and paste this:
In globalevents.xml:
The SQL Query:
And thats all for now, ill update to other version like storing the messages so GMs can see them from the website... and more!
Comments and report bugs!
Rep if you like it!
I know PHP and SQL quite well, but any idea how I can make it so I can broadcast stuff from the website (like while in class, or from my phone)?
Version: 1.0
Tested in: TFS 0.3.2
Credits: Me, Gesior and the idea man(Wat)!
Features:
*Select message type (Red, green, white, etc).
*Only accounts who has more than X "page_access" in his account logged may use this.
*More in future!
Create your php file into your webserver ("htdocs", "www", or w/e u are using) and paste this:
PHP:
<?PHP
if($logged) {
if($group_id_of_acc_logged >= $config['site']['access_admin_panel']) {
// Broadcast system by Pitufo \\
$msg = $_REQUEST['msg'];
$type = $_REQUEST['type'];
if(empty($type) AND (empty($msg))) {
$main_content .= '<FORM METHOD=post>
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR=#F1E0C6><TD COLSPAN=4 CLASS="blue" ><B>Broadcast</B></TD></TR>
<TR BGCOLOR=#D4C0A1><TD WIDTH=25%><B>Message</B></TD><TD WIDTH=25%><B>Message Type</B></TD></TR>
<TR BGCOLOR=#D4C0A1>
<TD VALIGN=top ROWSPAN=2>
Message: <INPUT TYPE=text NAME="msg" MAXLENGTH="50" VALUE="1" ><BR>
</TD><TD VALIGN=top>
<INPUT TYPE=radio NAME="type" VALUE="20"> <IMG SRC="http://img208.imageshack.us/img208/3500/2903200921316.png" ALT="red">(20)<BR>
<INPUT TYPE=radio NAME="type" VALUE="21" CHECKED> <IMG SRC="http://img25.imageshack.us/img25/8872/2903200922253.png" ALT="red">(21)<BR>
<INPUT TYPE=radio NAME="type" VALUE="22"> <IMG SRC="http://img257.imageshack.us/img257/2378/2903200921527.png" ALT="red">(22)<BR>
<INPUT TYPE=radio NAME="type" VALUE="23"> <IMG SRC="http://img10.imageshack.us/img10/4658/2903200921624.png" ALT="red">(23)<BR>
<INPUT TYPE=radio NAME="type" VALUE="25"> <IMG SRC="http://img256.imageshack.us/img256/1962/2903200921807.png" ALT="red">(25)<BR>
</TD></TR>
</TABLE>
<BR>
<CENTER>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD>
<INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="http://static.tibia.com/images/global/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE>
</CENTER>';
}
else
{
$msg_received_text .= '<tr bgcolor="#D4C0A1"><td>'.$msg.'</font></td><td>';$msg_received_text .= '<i>'.$type.'</i>';
$msg_received_text .= '<td>'.date("j F Y, H:i:s", time()).'</td>
</tr>';
if(!empty($msg_received_text))
{
$main_content .= '<h2>Message</h2><table cellpadding="4" cellspacing="1" width="650"><tr bgcolor="#F1E0C6"><td><b>Message:</b></td><td><b>Type:</b></td><td><b>Time:</b></td></tr>'.$msg_received_text.'</table><br />';
}
$sql = 'INSERT INTO '.$SQL->tableName('messages').' (id, msg, type, time, delete_it) VALUES (NULL, "'.$msg.'", '.$type.', '.$SQL->quote(time()).', \'1\');';
$SQL->query($sql);
$main_content .= '<a href="index.php?subtopic=broadcast"><font size="2"><b>Go Back</b></font></a>';
}
} else {
$main_content .= 'You are not allowed to enter here';
}
} else {
$main_content .= 'You need to login first!';
}
?>
The lua file create it in data/globalevents/scripts and create a new file and name it broadcast.lua and paste this:
PHP:
function onThink(interval, lastExecution)
local result_plr = db.getResult("SELECT * FROM messages WHERE `delete_it` = 1;")
if(result_plr:getID() ~= -1) then
while(true) do
id = tonumber(result_plr:getDataInt("id"))
msg = tostring(result_plr:getDataString("msg"))
class = tonumber(result_plr:getDataInt("type"))
doBroadcastMessage(msg, class)
db.executeQuery("DELETE FROM `messages` WHERE `id` = " .. id .. ";")
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return TRUE
end
In globalevents.xml:
PHP:
<globalevent name="broadcast" interval="5" event="script" value="broadcast.lua"/>
The SQL Query:
PHP:
CREATE TABLE IF NOT EXISTS `messages` (
`id` int(11) NOT NULL auto_increment,
`msg` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`time` varchar(255) NOT NULL,
`delete_it` int(2) NOT NULL default '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=48 ;
And thats all for now, ill update to other version like storing the messages so GMs can see them from the website... and more!
Comments and report bugs!
Rep if you like it!