Advertisement
Guest User

scriptSignals.c

a guest
Apr 23rd, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.09 KB | None | 0 0
  1. #define PLAYERMAX   64
  2. #define SCRIPTSLOTS 10
  3.  
  4. #define SCRIPT_ACTIVE   0
  5. #define SCRIPT_NUMBER   1
  6. #define SCRIPT_ARG1     2
  7. #define SCRIPT_ARG2     3
  8. #define SCRIPT_ARG3     4
  9.  
  10. int ScriptSignals[PLAYERMAX][SCRIPTSLOTS][5];
  11.  
  12. /**
  13.  * Sends a script signal to the player given.
  14.  * Returns: 0 if script is added properly, 1 if script is not added.
  15.  **/
  16. function int SendSignal(int pln, int num, int arg1, int arg2, int arg3)
  17. {
  18.     if (pln < 0 || pln >= PLAYERMAX) { return; }
  19.     int i;
  20.  
  21.     for (i = 0; i < SCRIPTSLOTS; i++)
  22.     {
  23.         if (ScriptSignals[pln][i][SCRIPT_ACTIVE]) { continue; }
  24.  
  25.         ScriptSignals[pln][i][SCRIPT_ACTIVE] = 1;
  26.         ScriptSignals[pln][i][SCRIPT_NUMBER] = num;
  27.         ScriptSignals[pln][i][SCRIPT_ARG1]   = arg1;
  28.         ScriptSignals[pln][i][SCRIPT_ARG2]   = arg2;
  29.         ScriptSignals[pln][i][SCRIPT_ARG3]   = arg3;
  30.         return 0;
  31.     }
  32.  
  33.     return 1;
  34. }
  35.  
  36. /**
  37.  * Clears the given signal.
  38.  * Returns: nothing.
  39.  **/
  40. function void ClearSignals(int pln, int slot)
  41. {
  42.     if (pln  < 0 || pln  >= PLAYERMAX
  43.      || slot < 0 || slot >= SCRIPTSLOTS) { return; }
  44.  
  45.     int i, j;
  46.  
  47.     for (i = 0; i < 5; i++)
  48.     {
  49.         ScriptSignals[pln][slot][j] = 0;
  50.     }
  51. }
  52.  
  53. function void CatchSignals(int pln)
  54. {
  55.     __catchsignals__(pln, 0);
  56. }
  57.  
  58. function void __catchsignals__(int pln, int noclear)
  59. {
  60.     int i;
  61.     int snum, arg1, arg2, arg3;
  62.  
  63.     for (i = 0; i < SCRIPTSLOTS; i++)
  64.     {
  65.         if (ScriptSignals[pln][i][SCRIPT_ACTIVE])
  66.         {
  67.             snum = ScriptSignals[pln][i][SCRIPT_NUMBER];
  68.             arg1 = ScriptSignals[pln][i][SCRIPT_ARG1];
  69.             arg2 = ScriptSignals[pln][i][SCRIPT_ARG2];
  70.             arg3 = ScriptSignals[pln][i][SCRIPT_ARG3];
  71.  
  72.             ACS_ExecuteWithResult(snum, arg1, arg2, arg3);
  73.         }
  74.  
  75.         if (!noclear) { ClearSignal(pln, i); }
  76.     }
  77. }
  78.  
  79.  
  80. script 723 enter
  81. {
  82.     int pln = PlayerNumber();
  83.     int i;
  84.  
  85.     for (i = 0; i < SCRIPTSLOTS; i++) { ClearSignal(pln, i); }
  86.  
  87.     while (!(ClassifyActor(0) & ACTOR_WORLD))
  88.     {
  89.         CatchSignals(pln);
  90.         Delay(1);
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement