Advertisement
EnzoMetlc

[Include] Numeric combinations.

Dec 10th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.16 KB | None | 0 0
  1. /* @combinations.inc - by Swedky (09/12/2016): http://forum.sa-mp.com/showthread.php?t=624081
  2.  
  3.     native SetCombination(&var, slot, value);
  4.     native GetCombination(var, slot);
  5. */
  6.  
  7. #if defined _combinations_included
  8.   #endinput
  9. #endif
  10. #define _combinations_included
  11.  
  12.  
  13. stock SetCombination(&var, slot, value) // ~0.0035 ms
  14. {
  15.     new comb[11];
  16.     format(comb, 11, "%010i", var);
  17.  
  18.     switch(value)
  19.     {
  20.         case 1: comb[9 - slot] = '1';
  21.         case 2: comb[9 - slot] = '2';
  22.         case 3: comb[9 - slot] = '3';
  23.         case 4: comb[9 - slot] = '4';
  24.         case 5: comb[9 - slot] = '5';
  25.         case 6: comb[9 - slot] = '6';
  26.         case 7: comb[9 - slot] = '7';
  27.         case 8: comb[9 - slot] = '8';
  28.         case 9: comb[9 - slot] = '9';
  29.         default: comb[9 - slot] = '0';
  30.     }
  31.  
  32.     var = strval(comb);
  33.     return 1;
  34. }
  35.  
  36. stock GetCombination(var, slot) // ~0.002 ms
  37. {
  38.     new comb[11];
  39.     format(comb, 11, "%010i", var);
  40.     switch(comb[9 - slot])
  41.     {
  42.         case '0': return 0;
  43.         case '1': return 1;
  44.         case '2': return 2;
  45.         case '3': return 3;
  46.         case '4': return 4;
  47.         case '5': return 5;
  48.         case '6': return 6;
  49.         case '7': return 7;
  50.         case '8': return 8;
  51.         case '9': return 9;
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement