Advertisement
Guest User

2KNOS - Build 1

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