Advertisement
AiRaLoKa

Moving TextDraw MOTD R3 [MySQL R33]

Jun 23rd, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.04 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////////////////
  3. //======================== MOVING TEXTDRAW MOTD R3 BY AiRaLoKa =========================//
  4. //////////////////////////////////////////////////////////////////////////////////////////
  5. //////////////////////////////////////////////////////////////////////////////////////////
  6. //==================================== CREDITS =========================================//
  7. //                         PLEASE DO NOT REMOVE THE CREDITS                             //
  8. //                SA-MP Teams - Wihout they all, this all will never exitst             //
  9. //                          AiRaLoKa - For the whole script                             //
  10. //                             Y_Less - For the sscanf2                                 //
  11. //                               Zeex - For the zcmd                                    //
  12. //                          BlueG - For the MySQL Plugin                                //
  13. //////////////////////////////////////////////////////////////////////////////////////////
  14. //////////////////////////////////////////////////////////////////////////////////////////
  15.  
  16. //////////////////////////////////////////////////////////////////////////////////////////
  17. //============================== INCLUDE ===============================================//
  18. //////////////////////////////////////////////////////////////////////////////////////////
  19.  
  20. #include <a_samp>
  21. #include <a_mysql>
  22. #include <sscanf>
  23. #include <zcmd>
  24.  
  25. //////////////////////////////////////////////////////////////////////////////////////////
  26. //============================== DEFINES ===============================================//
  27. //////////////////////////////////////////////////////////////////////////////////////////
  28.  
  29. #define FILTERSCRIPT
  30. #define MAX_MOTD                            5
  31.  
  32. #define SQL_HOST                            "127.0.0.1" //Your MySQL database
  33. #define SQL_USER                            "root"      //Your MySQL user
  34. #define SQL_PASS                            ""          //Your MySQL Password
  35. #define SQL_DB                              "Server"    //Your Database name
  36.  
  37. //////////////////////////////////////////////////////////////////////////////////////////
  38. //============================== FORWARDS ==============================================//
  39. //////////////////////////////////////////////////////////////////////////////////////////
  40.  
  41. forward MoveText(playerid);
  42.  
  43. //////////////////////////////////////////////////////////////////////////////////////////
  44. //============================== NEWS ==================================================//
  45. //////////////////////////////////////////////////////////////////////////////////////////
  46.  
  47. new dbHandle;
  48. new Text:MOTDBack;
  49. new Text:MOTD;
  50. new MOTDMovingTimer;
  51. new Float:Pos = 640.000000;
  52. new MOTDText[MAX_MOTD][128];
  53. new CurrentMOTD;
  54.  
  55.  
  56. //////////////////////////////////////////////////////////////////////////////////////////
  57. //============================== PUBLICS ===============================================//
  58. //////////////////////////////////////////////////////////////////////////////////////////
  59.  
  60. public OnFilterScriptInit()
  61. {
  62.     new rows, fields, savestr[128];
  63.     mysql_log(LOG_ERROR | LOG_WARNING);
  64.     dbHandle = mysql_connect(SQL_HOST,SQL_USER,SQL_DB,SQL_PASS);
  65.     if (!mysql_errno())
  66.     {
  67.         print("[SERVER SUCCESS]: Connection to database succcessfully establishied.");
  68.     }
  69.     else
  70.     {
  71.         print("[CRITICAL SERVER ERROR]: Connection to database could not pass. Gamemode wont work.");
  72.         SendRconCommand("exit");
  73.     }
  74.     mysql_tquery(dbHandle, "CREATE TABLE IF NOT EXISTS `MOTD` ( \
  75.                             `Text` varchar(24) COLLATE utf8_unicode_ci NOT NULL, \
  76.                             `ID` bigint(21) unsigned NOT NULL AUTO_INCREMENT, \
  77.                             PRIMARY KEY (`id`), \
  78.                             UNIQUE KEY `id` (`id`) \
  79.                             ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1189", "", "");
  80.     mysql_tquery(dbHandle, "SELECT * FROM `MOTD`", "", "");
  81.     cache_get_data(rows, fields);
  82.     if(rows)
  83.     {
  84.         for(new i; i < MAX_MOTD; i++)
  85.         {
  86.             cache_get_field_content(i, "Text", savestr);
  87.             format(MOTDText[i], 128, savestr);
  88.         }
  89.     }
  90.     else if(!rows)
  91.     {
  92.         new query[128];
  93.         for(new i; i < MAX_MOTD; i++)
  94.         {
  95.             format(MOTDText[i], 128, "Null");
  96.             mysql_format(dbHandle, query, sizeof(query),"INSERT INTO `MOTD` (`ID`,`Text`) VALUES ('%d','Null')",i);
  97.             mysql_tquery(dbHandle, query, "", "");
  98.         }
  99.     }
  100.     MOTDBack = TextDrawCreate(1270.000000, 433.750000, "usebox");
  101.     TextDrawLetterSize(MOTDBack, 0.000000, 3.431018);
  102.     TextDrawTextSize(MOTDBack, -2.100000, 0.000000);
  103.     TextDrawAlignment(MOTDBack, 1);
  104.     TextDrawColor(MOTDBack, 0);
  105.     TextDrawUseBox(MOTDBack, true);
  106.     TextDrawBoxColor(MOTDBack, 102);
  107.     TextDrawSetShadow(MOTDBack, 0);
  108.     TextDrawSetOutline(MOTDBack, 0);
  109.     TextDrawFont(MOTDBack, 0);
  110.  
  111.     MOTD = TextDrawCreate(640.000000, 434.000000, MOTDText[0]);
  112.     TextDrawLetterSize(MOTD, 0.449999, 1.600000);
  113.     TextDrawAlignment(MOTD, 1);
  114.     TextDrawColor(MOTD, -1);
  115.     TextDrawSetShadow(MOTD, 0);
  116.     TextDrawSetOutline(MOTD, 1);
  117.     TextDrawBackgroundColor(MOTD, 51);
  118.     TextDrawFont(MOTD, 1);
  119.     TextDrawSetProportional(MOTD, 1);
  120.  
  121.     MOTDMovingTimer = SetTimer("MoveText", 10, true);
  122.    
  123.     print("\n/////////////////////////////////////////////////////////");
  124.     print("//==== Moving TextDraw MOTD R3 By AiRaLoKa Loaded! ====//");
  125.     print("/////////////////////////////////////////////////////////\n");
  126.     return 1;
  127. }
  128.  
  129. public OnFilterScriptExit()
  130. {
  131.     KillTimer(MOTDMovingTimer);
  132.     TextDrawDestroy(MOTD);
  133.     TextDrawDestroy(MOTDBack);
  134.     return 1;
  135. }
  136.  
  137. public OnPlayerRequestClass(playerid, classid)
  138. {
  139.     return 1;
  140. }
  141.  
  142. public OnPlayerConnect(playerid)
  143. {
  144.     TextDrawShowForPlayer(playerid, Text:MOTDBack);
  145.     return 1;
  146. }
  147.  
  148. public OnPlayerDisconnect(playerid, reason)
  149. {
  150.     return 1;
  151. }
  152.  
  153. public OnPlayerSpawn(playerid)
  154. {
  155.     return 1;
  156. }
  157.  
  158. public OnPlayerDeath(playerid, killerid, reason)
  159. {
  160.     return 1;
  161. }
  162.  
  163. public OnVehicleSpawn(vehicleid)
  164. {
  165.     return 1;
  166. }
  167.  
  168. public OnVehicleDeath(vehicleid, killerid)
  169. {
  170.     return 1;
  171. }
  172.  
  173. public OnPlayerText(playerid, text[])
  174. {
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerCommandText(playerid, cmdtext[])
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  184. {
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerExitVehicle(playerid, vehicleid)
  189. {
  190.     return 1;
  191. }
  192.  
  193. public OnPlayerStateChange(playerid, newstate, oldstate)
  194. {
  195.     return 1;
  196. }
  197.  
  198. public OnPlayerEnterCheckpoint(playerid)
  199. {
  200.     return 1;
  201. }
  202.  
  203. public OnPlayerLeaveCheckpoint(playerid)
  204. {
  205.     return 1;
  206. }
  207.  
  208. public OnPlayerEnterRaceCheckpoint(playerid)
  209. {
  210.     return 1;
  211. }
  212.  
  213. public OnPlayerLeaveRaceCheckpoint(playerid)
  214. {
  215.     return 1;
  216. }
  217.  
  218. public OnRconCommand(cmd[])
  219. {
  220.     return 1;
  221. }
  222.  
  223. public OnPlayerRequestSpawn(playerid)
  224. {
  225.     return 1;
  226. }
  227.  
  228. public OnObjectMoved(objectid)
  229. {
  230.     return 1;
  231. }
  232.  
  233. public OnPlayerObjectMoved(playerid, objectid)
  234. {
  235.     return 1;
  236. }
  237.  
  238. public OnPlayerPickUpPickup(playerid, pickupid)
  239. {
  240.     return 1;
  241. }
  242.  
  243. public OnVehicleMod(playerid, vehicleid, componentid)
  244. {
  245.     return 1;
  246. }
  247.  
  248. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  249. {
  250.     return 1;
  251. }
  252.  
  253. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  254. {
  255.     return 1;
  256. }
  257.  
  258. public OnPlayerSelectedMenuRow(playerid, row)
  259. {
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerExitedMenu(playerid)
  264. {
  265.     return 1;
  266. }
  267.  
  268. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  269. {
  270.     return 1;
  271. }
  272.  
  273. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  274. {
  275.     return 1;
  276. }
  277.  
  278. public OnRconLoginAttempt(ip[], password[], success)
  279. {
  280.     return 1;
  281. }
  282.  
  283. public OnPlayerUpdate(playerid)
  284. {
  285.     return 1;
  286. }
  287.  
  288. public OnPlayerStreamIn(playerid, forplayerid)
  289. {
  290.     return 1;
  291. }
  292.  
  293. public OnPlayerStreamOut(playerid, forplayerid)
  294. {
  295.     return 1;
  296. }
  297.  
  298. public OnVehicleStreamIn(vehicleid, forplayerid)
  299. {
  300.     return 1;
  301. }
  302.  
  303. public OnVehicleStreamOut(vehicleid, forplayerid)
  304. {
  305.     return 1;
  306. }
  307.  
  308. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  309. {
  310.     return 1;
  311. }
  312.  
  313. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  314. {
  315.     return 1;
  316. }
  317.  
  318. public MoveText()
  319. {
  320.     if(Pos > -1300.000000)
  321.     {
  322.         Pos -= 0.5;
  323.         TextDrawDestroy(Text:MOTD);
  324.         MOTD = TextDrawCreate(Pos, 434.000000, MOTDText[CurrentMOTD]);
  325.         TextDrawLetterSize(MOTD, 0.449999, 1.600000);
  326.         TextDrawAlignment(MOTD, 1);
  327.         TextDrawColor(MOTD, -1);
  328.         TextDrawSetShadow(MOTD, 0);
  329.         TextDrawSetOutline(MOTD, 1);
  330.         TextDrawBackgroundColor(MOTD, 51);
  331.         TextDrawFont(MOTD, 1);
  332.         TextDrawSetProportional(MOTD, 1);
  333.         TextDrawShowForAll(Text:MOTD);
  334.     }
  335.     else
  336.     {
  337.         KillTimer(MOTDMovingTimer);
  338.         Pos = 640.000000;
  339.         CurrentMOTD ++;
  340.         if(CurrentMOTD > MAX_MOTD)
  341.         {
  342.             CurrentMOTD = 0;
  343.         }
  344.         MOTDMovingTimer = SetTimer("MoveText", 10, true);
  345.     }
  346.     return 1;
  347. }
  348.  
  349. //////////////////////////////////////////////////////////////////////////////////////////
  350. //============================== COMMANDS ==============================================//
  351. //////////////////////////////////////////////////////////////////////////////////////////
  352.  
  353. CMD:setmotd(playerid, params[])
  354. {
  355.     new num;
  356.     new newmotd[128];
  357.     new query[200];
  358.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: You need to be RCon Administrator to use this command!");
  359.     if(sscanf(params, "is[128]", num, newmotd)) return SendClientMessage(playerid, 0xFF0000FF, "[SYNTAX]: /setmotd [MOTD ID] [New MOTD]");
  360.     if(num > MAX_MOTD || num < 0)
  361.     {
  362.         new str[128];
  363.         format(str, sizeof(str), "[ERROR]: The MOTD Range is only from 0 to %d", MAX_MOTD);
  364.         return SendClientMessage(playerid, 0xFF0000FF, str);
  365.     }
  366.     format(MOTDText[num], 128, newmotd);
  367.     mysql_format(dbHandle, query, sizeof(query), "UPDATE `MOTD` SET `Text` = '%s' WHERE `ID` = '%d'", MOTDText[num], num);
  368.     mysql_tquery(dbHandle, query, "", "");
  369.     return 1;
  370. }
  371.  
  372. //////////////////////////////////////////////////////////////////////////////////////////
  373. //========================== END OF MOVING TEXTDRAW MOTD R3 ============================//
  374. //////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement