Tutorial:
GoTo: /HabboHotel/Misc/CharCommandHandler.cs
Search for:
Add above it:PHP Code:case "ha":
Goto: /Messages/Requests/Users.csPHP Code:#region startpoll
case "startpoll":
{
if (Session.GetHabbo().HasFuse("fuse_sysadmin"))
{
try
{
int PollID = 0;
string PollMsg = "";
using (Storage.DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
PollID = dbClient.ReadInt32("SELECT id FROM room_poll WHERE room = '" + Session.GetHabbo().CurrentRoomId + "' LIMIT 1");
PollMsg = dbClient.ReadString("SELECT message FROM room_poll WHERE room = '" + Session.GetHabbo().CurrentRoomId + "' LIMIT 1");
}
ServerMessage NewPoll = new ServerMessage(316);
NewPoll.AppendInt32(PollID);
NewPoll.AppendStringWithBreak(PollMsg);
Session.GetHabbo().CurrentRoom.SendMessage(NewPoll);
}
catch (NullReferenceException)
{
Session.SendNotif("Sorry, this room doesn't have any poll's yet!");
return false;
}
}
}
return false;
#endregion
Search for:
Add above it:PHP Code:public void RegisterUsers()
Search for:PHP Code:private void RoomPollSystem()
{
DataTable Data = null;
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
Data = dbClient.ReadDataTable("SELECT * FROM room_poll WHERE room = '" + Session.GetHabbo().CurrentRoomId + "' LIMIT 1");
}
if (Data == null)
{
return;
}
foreach (DataRow Row in Data.Rows)
{
GetResponse().Init(317);
GetResponse().AppendInt32((int)Row["id"]);
GetResponse().AppendStringWithBreak((string)Row["question"]);
GetResponse().AppendStringWithBreak("Thank you for your participation!");
GetResponse().AppendInt32(1);
GetResponse().AppendInt32(5383);
GetResponse().AppendInt32(1);
GetResponse().AppendInt32(1);
GetResponse().AppendStringWithBreak((string)Row["description"]);
GetResponse().AppendInt32(9);
GetResponse().AppendInt32(1);
GetResponse().AppendInt32(9);
GetResponse().AppendStringWithBreak((string)Row["question1"]);
GetResponse().AppendStringWithBreak((string)Row["question2"]);
GetResponse().AppendStringWithBreak((string)Row["question3"]);
GetResponse().AppendStringWithBreak((string)Row["question4"]);
GetResponse().AppendStringWithBreak((string)Row["question5"]);
GetResponse().AppendStringWithBreak((string)Row["question6"]);
GetResponse().AppendStringWithBreak((string)Row["question7"]);
GetResponse().AppendStringWithBreak((string)Row["question8"]);
GetResponse().AppendStringWithBreak((string)Row["question9"]);
SendResponse();
}
}
public void RoomPollVote()
{
int Answer = int.Parse(Request.ToString().Substring(Request.ToString().Length - 1));
int PollId = Request.PopWiredInt32();
if (Answer != 0)
{
using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient())
{
dbClient.ExecuteQuery("UPDATE room_poll SET vote" + Answer + " = vote" + Answer + " + 1");
}
}
}
Add under it:PHP Code:RequestHandlers[3000] = new RequestHandler(GetPetsInventory);
Sql:PHP Code:RequestHandlers[234] = new RequestHandler(RoomPollSystem);
RequestHandlers[236] = new RequestHandler(RoomPollVote);
How to use?!:PHP Code:-- --------------------------------------------------------
--
-- Tabelstructuur voor tabel `room_poll`
--
CREATE TABLE IF NOT EXISTS `room_poll` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`room` int(11) NOT NULL,
`message` text NOT NULL,
`question` text NOT NULL,
`description` text NOT NULL,
`question1` varchar(255) NOT NULL,
`question2` varchar(255) NOT NULL,
`question3` varchar(255) NOT NULL,
`question4` varchar(255) NOT NULL,
`question5` varchar(255) NOT NULL,
`question6` varchar(255) NOT NULL,
`question7` varchar(255) NOT NULL,
`question8` varchar(255) NOT NULL,
`question9` varchar(255) NOT NULL,
`vote1` int(11) NOT NULL DEFAULT '0',
`vote2` int(11) NOT NULL DEFAULT '0',
`vote3` int(11) NOT NULL DEFAULT '0',
`vote4` int(11) NOT NULL DEFAULT '0',
`vote5` int(11) NOT NULL DEFAULT '0',
`vote6` int(11) NOT NULL DEFAULT '0',
`vote7` int(11) NOT NULL DEFAULT '0',
`vote8` int(11) NOT NULL DEFAULT '0',
`vote9` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Gegevens worden uitgevoerd voor tabel `room_poll`
--
INSERT INTO `room_poll` (`id`, `room`, `message`, `question`, `description`, `question1`, `question2`, `question3`, `question4`, `question5`, `question6`, `question7`, `question8`, `question9`, `vote1`, `vote2`, `vote3`, `vote4`, `vote5`, `vote6`, `vote7`, `vote8`, `vote9`) VALUES
(1, 7, 'Click on OK :D', 'How cool is TopErwin?!', 'Just tell me!!! :D', 'HE''S AMAZING!', 'HE''S F*CKING AMAZING!', 'HE''S AMAZING LIKE SAUSAGE!', 'HE''S TOO AMAZING!', 'HE''S INCREDIBLE AMAZING!', 'HE''S 100% NICE!!', 'HE''S 100% COOL!! :D', 'HE''S 292% AMAZING! :D', 'poor -,-', 0, 1, 0, 0, 0, 0, 0, 1, 0);
-> Look into your database for the id from the room where u wanted to start the poll,
-> Add into the sql the row (DONT FILLIN THE 'vote' ROWS!)
-> Go to the room where u have made the poll
-> Use the command ":startpoll" (without the "")
-> Won't work? -> check your sql!
Screenshots:
http://img209.imageshack.us/img209/4356/roompoll1.png
http://img228.imageshack.us/img228/4927/roompoll2.png
http://img560.imageshack.us/img560/6469/roompoll3.png
http://img820.imageshack.us/img820/3144/roompoll4.png
Credits:
-> TopErwin (coding this stuff)
-> =dj.matias= (logging the packets)
-> Meth0d (making UberEmu)


![[UberEmu] RoomPolls!!](http://ragezone.com/hyper728.png)


