Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
- //======================== MOVING TEXTDRAW MOTD R3 BY AiRaLoKa =========================//
- //////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
- //==================================== CREDITS =========================================//
- // PLEASE DO NOT REMOVE THE CREDITS //
- // SA-MP Teams - Wihout they all, this all will never exitst //
- // AiRaLoKa - For the whole script //
- // Y_Less - For the sscanf2 //
- // Zeex - For the zcmd //
- // BlueG - For the MySQL Plugin //
- //////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////
- //============================== INCLUDE ===============================================//
- //////////////////////////////////////////////////////////////////////////////////////////
- #include <a_samp>
- #include <a_mysql>
- #include <sscanf>
- #include <zcmd>
- //////////////////////////////////////////////////////////////////////////////////////////
- //============================== DEFINES ===============================================//
- //////////////////////////////////////////////////////////////////////////////////////////
- #define FILTERSCRIPT
- #define MAX_MOTD 5
- #define SQL_HOST "127.0.0.1" //Your MySQL database
- #define SQL_USER "root" //Your MySQL user
- #define SQL_PASS "" //Your MySQL Password
- #define SQL_DB "Server" //Your Database name
- //////////////////////////////////////////////////////////////////////////////////////////
- //============================== FORWARDS ==============================================//
- //////////////////////////////////////////////////////////////////////////////////////////
- forward MoveText(playerid);
- //////////////////////////////////////////////////////////////////////////////////////////
- //============================== NEWS ==================================================//
- //////////////////////////////////////////////////////////////////////////////////////////
- new dbHandle;
- new Text:MOTDBack;
- new Text:MOTD;
- new MOTDMovingTimer;
- new Float:Pos = 640.000000;
- new MOTDText[MAX_MOTD][128];
- new CurrentMOTD;
- //////////////////////////////////////////////////////////////////////////////////////////
- //============================== PUBLICS ===============================================//
- //////////////////////////////////////////////////////////////////////////////////////////
- public OnFilterScriptInit()
- {
- new rows, fields, savestr[128];
- mysql_log(LOG_ERROR | LOG_WARNING);
- dbHandle = mysql_connect(SQL_HOST,SQL_USER,SQL_DB,SQL_PASS);
- if (!mysql_errno())
- {
- print("[SERVER SUCCESS]: Connection to database succcessfully establishied.");
- }
- else
- {
- print("[CRITICAL SERVER ERROR]: Connection to database could not pass. Gamemode wont work.");
- SendRconCommand("exit");
- }
- mysql_tquery(dbHandle, "CREATE TABLE IF NOT EXISTS `MOTD` ( \
- `Text` varchar(24) COLLATE utf8_unicode_ci NOT NULL, \
- `ID` bigint(21) unsigned NOT NULL AUTO_INCREMENT, \
- PRIMARY KEY (`id`), \
- UNIQUE KEY `id` (`id`) \
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1189", "", "");
- mysql_tquery(dbHandle, "SELECT * FROM `MOTD`", "", "");
- cache_get_data(rows, fields);
- if(rows)
- {
- for(new i; i < MAX_MOTD; i++)
- {
- cache_get_field_content(i, "Text", savestr);
- format(MOTDText[i], 128, savestr);
- }
- }
- else if(!rows)
- {
- new query[128];
- for(new i; i < MAX_MOTD; i++)
- {
- format(MOTDText[i], 128, "Null");
- mysql_format(dbHandle, query, sizeof(query),"INSERT INTO `MOTD` (`ID`,`Text`) VALUES ('%d','Null')",i);
- mysql_tquery(dbHandle, query, "", "");
- }
- }
- MOTDBack = TextDrawCreate(1270.000000, 433.750000, "usebox");
- TextDrawLetterSize(MOTDBack, 0.000000, 3.431018);
- TextDrawTextSize(MOTDBack, -2.100000, 0.000000);
- TextDrawAlignment(MOTDBack, 1);
- TextDrawColor(MOTDBack, 0);
- TextDrawUseBox(MOTDBack, true);
- TextDrawBoxColor(MOTDBack, 102);
- TextDrawSetShadow(MOTDBack, 0);
- TextDrawSetOutline(MOTDBack, 0);
- TextDrawFont(MOTDBack, 0);
- MOTD = TextDrawCreate(640.000000, 434.000000, MOTDText[0]);
- TextDrawLetterSize(MOTD, 0.449999, 1.600000);
- TextDrawAlignment(MOTD, 1);
- TextDrawColor(MOTD, -1);
- TextDrawSetShadow(MOTD, 0);
- TextDrawSetOutline(MOTD, 1);
- TextDrawBackgroundColor(MOTD, 51);
- TextDrawFont(MOTD, 1);
- TextDrawSetProportional(MOTD, 1);
- MOTDMovingTimer = SetTimer("MoveText", 10, true);
- print("\n/////////////////////////////////////////////////////////");
- print("//==== Moving TextDraw MOTD R3 By AiRaLoKa Loaded! ====//");
- print("/////////////////////////////////////////////////////////\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(MOTDMovingTimer);
- TextDrawDestroy(MOTD);
- TextDrawDestroy(MOTDBack);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- TextDrawShowForPlayer(playerid, Text:MOTDBack);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- public MoveText()
- {
- if(Pos > -1300.000000)
- {
- Pos -= 0.5;
- TextDrawDestroy(Text:MOTD);
- MOTD = TextDrawCreate(Pos, 434.000000, MOTDText[CurrentMOTD]);
- TextDrawLetterSize(MOTD, 0.449999, 1.600000);
- TextDrawAlignment(MOTD, 1);
- TextDrawColor(MOTD, -1);
- TextDrawSetShadow(MOTD, 0);
- TextDrawSetOutline(MOTD, 1);
- TextDrawBackgroundColor(MOTD, 51);
- TextDrawFont(MOTD, 1);
- TextDrawSetProportional(MOTD, 1);
- TextDrawShowForAll(Text:MOTD);
- }
- else
- {
- KillTimer(MOTDMovingTimer);
- Pos = 640.000000;
- CurrentMOTD ++;
- if(CurrentMOTD > MAX_MOTD)
- {
- CurrentMOTD = 0;
- }
- MOTDMovingTimer = SetTimer("MoveText", 10, true);
- }
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////////////////
- //============================== COMMANDS ==============================================//
- //////////////////////////////////////////////////////////////////////////////////////////
- CMD:setmotd(playerid, params[])
- {
- new num;
- new newmotd[128];
- new query[200];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: You need to be RCon Administrator to use this command!");
- if(sscanf(params, "is[128]", num, newmotd)) return SendClientMessage(playerid, 0xFF0000FF, "[SYNTAX]: /setmotd [MOTD ID] [New MOTD]");
- if(num > MAX_MOTD || num < 0)
- {
- new str[128];
- format(str, sizeof(str), "[ERROR]: The MOTD Range is only from 0 to %d", MAX_MOTD);
- return SendClientMessage(playerid, 0xFF0000FF, str);
- }
- format(MOTDText[num], 128, newmotd);
- mysql_format(dbHandle, query, sizeof(query), "UPDATE `MOTD` SET `Text` = '%s' WHERE `ID` = '%d'", MOTDText[num], num);
- mysql_tquery(dbHandle, query, "", "");
- return 1;
- }
- //////////////////////////////////////////////////////////////////////////////////////////
- //========================== END OF MOVING TEXTDRAW MOTD R3 ============================//
- //////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement