ulbi1990

uClock

May 24th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.54 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4.  
  5. #define USEREALTIME false //true = Serverzeit wird genutzt (Real Time)||false = Custom Zeit wird genutzt
  6. #define time 10 //Alle wieviel Sekunden eine Ingame Minute verstreichen soll
  7.  
  8. #if USEREALTIME true
  9. new DoppelpunktShow,Text:Texture1,Text:Box,Text:Texture2,Text:Doppelpunkt,Text:Stunde,Text:Minute,Backgroundcolor,TextColor;
  10. #else
  11. new DoppelpunktShow,Text:Texture1,Text:Box,Text:Texture2,Text:Doppelpunkt,Text:Stunde,Text:Minute,HoursEllapsed,MinutesEllapsed,Clockup,Backgroundcolor,TextColor;
  12. #endif
  13.  
  14. stock HexToInt(string[])
  15. {
  16.     if (string[0]==0) return 0;
  17.     new i;
  18.     new cur=1;
  19.     new res=0;
  20.     for (i=strlen(string);i>0;i--)
  21.     {
  22.         if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
  23.         cur=cur*16;
  24.     }
  25.     return res;
  26. }
  27.  
  28. forward ClockUpdate(playerid);
  29.  
  30. public OnFilterScriptInit()
  31. {
  32.     print(" ");
  33.     print("\t\t|=============================|");
  34.     print("\t\t|        uClock v1.0 R1       |");
  35.     print("\t\t|     scriptet by ulbi1990    |");
  36.     print("\t\t|=============================|");
  37.     print(" ");
  38.  
  39.     Backgroundcolor=0xFFFFFFFF;
  40.     TextColor=0xFF0000FF;
  41.     Texture1 = TextDrawCreate(537.000000, 26.000000, "LD_BEAT:chit");
  42.     TextDrawBackgroundColor(Texture1,Backgroundcolor);
  43.     TextDrawFont(Texture1, 4);
  44.     TextDrawLetterSize(Texture1, 0.500000, 1.000000);
  45.     TextDrawColor(Texture1,Backgroundcolor);
  46.     TextDrawSetOutline(Texture1, 0);
  47.     TextDrawSetProportional(Texture1, 1);
  48.     TextDrawSetShadow(Texture1, 1);
  49.     TextDrawUseBox(Texture1, 1);
  50.     TextDrawBoxColor(Texture1,Backgroundcolor);
  51.     TextDrawTextSize(Texture1, 45.000000, 33.000000);
  52.     Texture2 = TextDrawCreate(566.000000, 26.000000, "LD_BEAT:chit");
  53.     TextDrawBackgroundColor(Texture2, Backgroundcolor);
  54.     TextDrawFont(Texture2, 4);
  55.     TextDrawLetterSize(Texture2, 0.500000, 1.000000);
  56.     TextDrawColor(Texture2,Backgroundcolor);
  57.     TextDrawSetOutline(Texture2, 0);
  58.     TextDrawSetProportional(Texture2, 1);
  59.     TextDrawSetShadow(Texture2, 1);
  60.     TextDrawUseBox(Texture2, 1);
  61.     TextDrawBoxColor(Texture2,Backgroundcolor);
  62.     TextDrawTextSize(Texture2, 45.000000, 33.000000);
  63.     Box = TextDrawCreate(594.000000, 34.000000, "_");
  64.     TextDrawBackgroundColor(Box,Backgroundcolor);
  65.     TextDrawFont(Box, 1);
  66.     TextDrawLetterSize(Box, 0.500000, 1.899999);
  67.     TextDrawColor(Box,Backgroundcolor);
  68.     TextDrawSetOutline(Box, 0);
  69.     TextDrawSetProportional(Box, 1);
  70.     TextDrawSetShadow(Box, 1);
  71.     TextDrawUseBox(Box, 1);
  72.     TextDrawBoxColor(Box,Backgroundcolor);
  73.     TextDrawTextSize(Box, 559.000000, 0.000000);
  74.     Stunde = TextDrawCreate(550.000000, 30.000000, "00");
  75.     TextDrawBackgroundColor(Stunde, 255);
  76.     TextDrawFont(Stunde, 1);
  77.     TextDrawLetterSize(Stunde, 0.430000, 2.399999);
  78.     TextDrawColor(Stunde,TextColor);
  79.     TextDrawSetOutline(Stunde, 0);
  80.     TextDrawSetProportional(Stunde, 1);
  81.     TextDrawSetShadow(Stunde, 1);
  82.     Minute = TextDrawCreate(577.000000, 30.000000, "00");
  83.     TextDrawBackgroundColor(Minute, 255);
  84.     TextDrawFont(Minute, 1);
  85.     TextDrawLetterSize(Minute, 0.430000, 2.399999);
  86.     TextDrawColor(Minute,TextColor);
  87.     TextDrawSetOutline(Minute, 0);
  88.     TextDrawSetProportional(Minute, 1);
  89.     TextDrawSetShadow(Minute, 1);
  90.     Doppelpunkt = TextDrawCreate(570.000000, 27.000000, ":");
  91.     TextDrawBackgroundColor(Doppelpunkt, 255);
  92.     TextDrawFont(Doppelpunkt, 1);
  93.     TextDrawLetterSize(Doppelpunkt, 0.500000, 2.699999);
  94.     TextDrawColor(Doppelpunkt, 16732415);
  95.     TextDrawSetOutline(Doppelpunkt, 0);
  96.     TextDrawSetProportional(Doppelpunkt, 1);
  97.     TextDrawSetShadow(Doppelpunkt, 1);
  98.     SetTimer("ClockUpdate",1000,1);
  99.     #if defined USEREALCLOCK false
  100.     Clockup=0;
  101.     #endif
  102.     return 1;
  103. }
  104.  
  105. public OnFilterScriptExit()
  106. {
  107.     return 1;
  108. }
  109.  
  110. public OnPlayerConnect(playerid)
  111. {
  112.     TogglePlayerClock(playerid,0);
  113.     SetPVarInt(playerid,"Spawned",0);
  114.     return 1;
  115. }
  116.  
  117. public OnPlayerSpawn(playerid)
  118. {
  119.     TextDrawShowForPlayer(playerid,Texture1);
  120.     TextDrawShowForPlayer(playerid,Texture2);
  121.     TextDrawShowForPlayer(playerid,Box);
  122.     TextDrawShowForPlayer(playerid,Stunde);
  123.     TextDrawShowForPlayer(playerid,Minute);
  124.     TextDrawShowForPlayer(playerid,Doppelpunkt);
  125.     SetPVarInt(playerid,"Spawned",1);
  126.     return 1;
  127. }
  128.  
  129. public ClockUpdate(playerid)
  130. {
  131.     if(GetPVarInt(playerid,"Spawned")==1)
  132.     {
  133.         new str[4],str2[4],worldtime[20];
  134.         #if USEREALTIME true
  135.         new hour,minute,second;
  136.         gettime(hour,minute,second);
  137.         if(minute<10)
  138.         {
  139.             format(str2,sizeof(str2),"%02d",minute);
  140.         }
  141.         else if(minute>9)
  142.         {
  143.             format(str2,sizeof(str2),"%d",minute);
  144.         }
  145.         TextDrawSetString(Minute,str2);
  146.         TextDrawShowForPlayer(playerid,Minute);
  147.         if(hour<10)
  148.         {
  149.             format(str,sizeof(str),"%02d",hour);
  150.         }
  151.         else if(hour>9)
  152.         {
  153.             format(str,sizeof(str),"%d",hour);
  154.         }
  155.         TextDrawSetString(Stunde,str);
  156.         TextDrawShowForPlayer(playerid,Stunde);
  157.         SetWorldTime(hour);
  158.         format(worldtime,sizeof(worldtime),"worldtime %02d:%02d",hour,minute);
  159.         SendRconCommand(worldtime);
  160.         #else
  161.         Clockup++;
  162.         if(Clockup==time)
  163.         {
  164.             Clockup=0;
  165.             if(MinutesEllapsed<60)
  166.             {
  167.                 if(MinutesEllapsed<10)
  168.                 {
  169.                     format(str2,sizeof(str2),"%02d",MinutesEllapsed);
  170.                 }
  171.                 else if(MinutesEllapsed>9)
  172.                 {
  173.                     format(str2,sizeof(str2),"%d",MinutesEllapsed);
  174.                 }
  175.                 MinutesEllapsed++;
  176.                 TextDrawSetString(Minute,str2);
  177.                 TextDrawShowForPlayer(playerid,Minute);
  178.             }
  179.             else if(MinutesEllapsed==60)
  180.             {
  181.                 MinutesEllapsed=0;
  182.                 if(HoursEllapsed<10)
  183.                 {
  184.                     format(str2,sizeof(str2),"00");
  185.                     format(str,sizeof(str),"%02d",HoursEllapsed);
  186.                 }
  187.                 else if(MinutesEllapsed>9)
  188.                 {
  189.                     format(str2,sizeof(str2),"00");
  190.                     format(str,sizeof(str),"%d",HoursEllapsed);
  191.                 }
  192.                 HoursEllapsed++;
  193.                 if(HoursEllapsed==24)
  194.                 {
  195.                     HoursEllapsed=0;
  196.                     {
  197.                         format(str,sizeof(str),"00");
  198.                     }
  199.                 }
  200.                 TextDrawSetString(Minute,str2);
  201.                 TextDrawShowForPlayer(playerid,Minute);
  202.                 TextDrawSetString(Stunde,str);
  203.                 TextDrawShowForPlayer(playerid,Minute);
  204.             }
  205.         }
  206.         SetWorldTime(HoursEllapsed);
  207.         format(worldtime,sizeof(worldtime),"worldtime %02d:%02d",HoursEllapsed,MinutesEllapsed);
  208.         SendRconCommand(worldtime);
  209.         #endif
  210.         if(DoppelpunktShow==0)
  211.         {
  212.             TextDrawHideForAll(Doppelpunkt);
  213.             DoppelpunktShow=1;
  214.         }
  215.         else if(DoppelpunktShow==1)
  216.         {
  217.             TextDrawShowForAll(Doppelpunkt);
  218.             DoppelpunktShow=0;
  219.         }
  220.     }
  221.     return 1;
  222. }
  223.  
  224. CMD:backgroundcolor(playerid,params[])
  225. {
  226.     new color[11];
  227.     if(IsPlayerAdmin(playerid))
  228.     {
  229.         if(sscanf(params,"x",color)) return SendClientMessage(playerid,-1,"[Nutzung]: /background [hex color]");
  230.         {
  231.             if(strlen(params)<10||strlen(params)>10)
  232.             {
  233.                 SendClientMessage(playerid,-1,"Bitte nur Hex Colors!");
  234.             }
  235.             else
  236.             {
  237.                 for(new i;i<MAX_PLAYERS;i++)
  238.                 {
  239.                     if(GetPVarInt(i,"Spawned")==1)
  240.                     {
  241.                         Backgroundcolor=HexToInt(params);
  242.                         TextDrawHideForAll(Texture1);
  243.                         TextDrawHideForAll(Texture2);
  244.                         TextDrawHideForAll(Box);
  245.                         TextDrawBackgroundColor(Texture1,Backgroundcolor);
  246.                         TextDrawColor(Texture1,Backgroundcolor);
  247.                         TextDrawBoxColor(Texture1,Backgroundcolor);
  248.                         TextDrawBackgroundColor(Texture2,Backgroundcolor);
  249.                         TextDrawColor(Texture2,Backgroundcolor);
  250.                         TextDrawBoxColor(Texture2,Backgroundcolor);
  251.                         TextDrawBackgroundColor(Box,Backgroundcolor);
  252.                         TextDrawColor(Box,Backgroundcolor);
  253.                         TextDrawBoxColor(Box,Backgroundcolor);
  254.                         TextDrawShowForPlayer(i,Texture1);
  255.                         TextDrawShowForPlayer(i,Texture2);
  256.                         TextDrawShowForPlayer(i,Box);
  257.                     }
  258.                 }
  259.             }
  260.         }
  261.     }
  262.     else
  263.     {
  264.         SendClientMessage(playerid,-1,"Nur Rcon Admins k�nnen die Farbe �ndern!");
  265.     }
  266.     return 1;
  267. }
  268.  
  269. CMD:textcolor(playerid,params[])
  270. {
  271.     new color[11];
  272.     if(IsPlayerAdmin(playerid))
  273.     {
  274.         if(sscanf(params,"x",color)) return SendClientMessage(playerid,-1,"[Nutzung]: /background [hex color]");
  275.         {
  276.             if(strlen(params)<10||strlen(params)>10)
  277.             {
  278.                 SendClientMessage(playerid,-1,"Bitte nur Hex Colors!");
  279.             }
  280.             else
  281.             {
  282.                 for(new i;i<MAX_PLAYERS;i++)
  283.                 {
  284.                     if(GetPVarInt(i,"Spawned")==1)
  285.                     {
  286.                         TextColor=HexToInt(params);
  287.                         TextDrawHideForAll(Stunde);
  288.                         TextDrawHideForAll(Minute);
  289.                         TextDrawColor(Stunde,TextColor);
  290.                         TextDrawColor(Minute,TextColor);
  291.                         TextDrawShowForPlayer(i,Stunde);
  292.                         TextDrawShowForPlayer(i,Minute);
  293.                     }
  294.                 }
  295.             }
  296.         }
  297.     }
  298.     else
  299.     {
  300.         SendClientMessage(playerid,-1,"Nur Rcon Admins k�nnen die Farbe �ndern!");
  301.     }
  302.     return 1;
  303. }
Advertisement
Add Comment
Please, Sign In to add comment