Advertisement
2ky

2KNOS - Build 1

2ky
Jan 17th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.04 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define     PRESSED(%0) \
  4.                 (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  5.                
  6. #define     HOLDING(%0) \
  7.                 ((newkeys & (%0)) == (%0))
  8.                
  9. #define     USE_MY_PRETTY_TEXTDRAWS     0
  10.  
  11. #define     CHOOSE_YOUR_OWN_KEY         KEY_SUBMISSION
  12.  
  13. new
  14.     Text:TwoKNOSLabel,
  15.     Text:TwoKNOSON,
  16.     Text:TwoKNOSOFF
  17. ;
  18.  
  19. new
  20.     p_UsingNos[MAX_PLAYERS] = 0
  21. ;
  22.  
  23. public OnFilterScriptInit()
  24. {
  25.     for(new u = 0; u < MAX_PLAYERS; u++) { //You can now safely load/reload the filterscript while the gamemode is already running.
  26.         p_UsingNos[u] = -1;
  27.     }
  28.     print("[2K-NOS] : Build 1 - Loaded");
  29.    
  30.     TwoKNOSLabel = TextDrawCreate(488.000000, 102.000000, "~b~~h~~h~(2KNOS)~n~~n~");
  31.     TextDrawBackgroundColor(TwoKNOSLabel, 255);
  32.     TextDrawFont(TwoKNOSLabel, 2);
  33.     TextDrawLetterSize(TwoKNOSLabel, 0.270000, 1.300000);
  34.     TextDrawColor(TwoKNOSLabel, -1);
  35.     TextDrawSetOutline(TwoKNOSLabel, 1);
  36.     TextDrawSetProportional(TwoKNOSLabel, 1);
  37.     TextDrawUseBox(TwoKNOSLabel, 1);
  38.     TextDrawBoxColor(TwoKNOSLabel, 70);
  39.     TextDrawTextSize(TwoKNOSLabel, 620.000000, 0.000000);
  40.    
  41.     TwoKNOSON = TextDrawCreate(492.000000, 117.000000, "~b~~h~~h~NOS ~w~has been toggled ~g~ON!");
  42.     TextDrawBackgroundColor(TwoKNOSON, 255);
  43.     TextDrawFont(TwoKNOSON, 3);
  44.     TextDrawLetterSize(TwoKNOSON, 0.270000, 1.300000);
  45.     TextDrawColor(TwoKNOSON, -1);
  46.     TextDrawSetOutline(TwoKNOSON, 1);
  47.     TextDrawSetProportional(TwoKNOSON, 1);
  48.    
  49.     TwoKNOSOFF = TextDrawCreate(492.000000, 117.000000, "~b~~h~~h~NOS ~w~has been toggled ~r~OFF!");
  50.     TextDrawBackgroundColor(TwoKNOSOFF, 255);
  51.     TextDrawFont(TwoKNOSOFF, 3);
  52.     TextDrawLetterSize(TwoKNOSOFF, 0.270000, 1.300000);
  53.     TextDrawColor(TwoKNOSOFF, -1);
  54.     TextDrawSetOutline(TwoKNOSOFF, 1);
  55.     TextDrawSetProportional(TwoKNOSOFF, 1);
  56.     return 1;
  57. }
  58.  
  59. public OnFilterScriptExit()
  60. {
  61.     for(new u = 0; u < MAX_PLAYERS; u++)
  62.     {
  63.         p_UsingNos[u] = -1;
  64.         print("[2K-NOS] - Unloaded.");
  65.     }
  66.     return 1;
  67. }
  68.  
  69. public OnPlayerConnect(playerid)
  70. {
  71.     p_UsingNos[playerid] = -1;
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerCommandText(playerid, cmdtext[])
  76. {
  77.     if (strcmp("/nos", cmdtext, true, 4) == 0)
  78.     {
  79.         #if defined USE_MY_PRETTY_TEXTDRAWS
  80.        
  81.             if(p_UsingNos[playerid] == -1) {
  82.                 p_UsingNos[playerid] = 1;
  83.                
  84.                 TextDrawShowForPlayer(playerid, Text:TwoKNOSLabel);
  85.                 TextDrawShowForPlayer(playerid, Text:TwoKNOSON);
  86.                 return SetTimerEx("HideTD", 3000, 0, "i", playerid);
  87.                
  88.             }  
  89.            
  90.             else if(p_UsingNos[playerid] == 1) {
  91.                 p_UsingNos[playerid] = -1;
  92.                
  93.                 TextDrawShowForPlayer(playerid, Text:TwoKNOSLabel);
  94.                 TextDrawShowForPlayer(playerid, Text:TwoKNOSOFF);
  95.                 return SetTimerEx("HideTD", 3000, 0, "i", playerid);
  96.                
  97.             }
  98.                
  99.            
  100.         #else
  101.            
  102.             if(p_UsingNos[playerid] == -1) {
  103.  
  104.                 new
  105.                     kstring[128] //I didn't count this; you could gain extra efficiency by counting the amount of characters!
  106.                 ;
  107.            
  108.                 p_UsingNos[playerid] = 1;
  109.                
  110.                 SendClientMessage(playerid, -1, "{0CA4F0}[2KNOS] NOS {FFFFFF}has been turned {138C03}on!");
  111.                 format(kstring, sizeof(kstring), "{0CA4F0}HINT: {FFFFFF}Press ~k~~CHOOSE_YOUR_OWN_KEY~ to stock/restock your NOS!");
  112.                 SendClientMessage(playerid, -1, kstring);
  113.                 return SendClientMessage(playerid, -1, "{FFFFFF}Type {0CA4F0}/nos {FFFFFF}again to turn it {BF0808}off!");
  114.            
  115.             }
  116.             else {
  117.            
  118.                 p_UsingNos[playerid] = -1;
  119.                
  120.                 SendClientMessage(playerid, -1, "{0CA4F0}[2KNOS] NOS {FFFFFF}has been turned {BF0808}off!");
  121.                 return SendClientMessage(playerid, -1, "{FFFFFF}Type {0CA4F0}/nos {FFFFFF}again to turn it {138C03}on!");
  122.            
  123.             }
  124.         #endif
  125.         return 1;
  126.     }
  127.     return 0;
  128. }
  129.  
  130. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  131. {
  132.     if(PRESSED(CHOOSE_YOUR_OWN_KEY)) //Press RMB
  133.     {
  134.         if(IsPlayerInAnyVehicle(playerid)) {
  135.        
  136.             if(p_UsingNos[playerid] == 1) { //If they have 2KNOS toggled on..
  137.                
  138.                 if(IsACar(GetPlayerVehicleID(playerid))) {
  139.                    
  140.                     AddVehicleComponent(GetPlayerVehicleID(playerid), 1010); //10x NOS
  141.                    
  142.                 }
  143.                 else return 0; //This vehicle would spam exceptions and crash players!
  144.                
  145.             }
  146.            
  147.         }
  148.     }
  149.     return 1;
  150. }
  151.  
  152. stock IsACar( vehicleid ) //SmiT
  153. {
  154.     new
  155.         _vmodel = GetVehicleModel( vehicleid )
  156.     ;
  157.     switch ( _vmodel )
  158.     {
  159.         case 401, 402, 404 .. 409, 410 .. 412, 415, 416, 418 .. 421, 423, 426 .. 429, 431 .. 434, 436 .. 439, 442, 445, 449, 451: return true;
  160.         case 457 .. 459, 466, 467, 474 .. 477, 479, 480, 483, 485, 486, 488, 490 .. 492, 494, 496, 504, 506 .. 508, 514 .. 518: return true;
  161.         case 525 .. 530, 532 .. 542, 544 .. 547, 549 .. 551, 55, 558 .. 562, 565 .. 567, 571, 572, 574 .. 576, 583, 585: return true;
  162.         case 587 .. 589, 596 .. 599, 601, 602, 603, 604: return true;
  163.     }
  164.     return false;
  165. }
  166.  
  167. forward HideTD(playerid);
  168. public HideTD(playerid)
  169. {
  170.     if(p_UsingNos[playerid] == 1) { //If it's already on..
  171.         TextDrawHideForPlayer(playerid, Text:TwoKNOSLabel);
  172.         return TextDrawHideForPlayer(playerid, Text:TwoKNOSON);
  173.     }
  174.     else if(p_UsingNos[playerid] == -1) {
  175.         TextDrawHideForPlayer(playerid, Text:TwoKNOSLabel);
  176.         return TextDrawHideForPlayer(playerid, Text:TwoKNOSOFF);
  177.     }
  178.     return 1;
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement