Advertisement
Guest User

scriptSignals.c

a guest
Apr 23rd, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.16 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.  * Send 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.  * Clear 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. /**
  54.  * Process script signals and runs them.
  55.  * Returns: nothing.
  56.  **/
  57. function void CatchSignals(int pln)
  58. {
  59.     __catchsignals__(pln, 0);
  60. }
  61.  
  62. function void __catchsignals__(int pln, int noclear)
  63. {
  64.     int i;
  65.     int snum, arg1, arg2, arg3;
  66.  
  67.     for (i = 0; i < SCRIPTSLOTS; i++)
  68.     {
  69.         if (ScriptSignals[pln][i][SCRIPT_ACTIVE])
  70.         {
  71.             snum = ScriptSignals[pln][i][SCRIPT_NUMBER];
  72.             arg1 = ScriptSignals[pln][i][SCRIPT_ARG1];
  73.             arg2 = ScriptSignals[pln][i][SCRIPT_ARG2];
  74.             arg3 = ScriptSignals[pln][i][SCRIPT_ARG3];
  75.  
  76.             ACS_ExecuteWithResult(snum, arg1, arg2, arg3);
  77.         }
  78.  
  79.         if (!noclear) { ClearSignal(pln, i); }
  80.     }
  81. }
  82.  
  83.  
  84. script 723 enter
  85. {
  86.     int pln = PlayerNumber();
  87.     int i;
  88.  
  89.     for (i = 0; i < SCRIPTSLOTS; i++) { ClearSignal(pln, i); }
  90.  
  91.     while (!(ClassifyActor(0) & ACTOR_WORLD))
  92.     {
  93.         CatchSignals(pln);
  94.         Delay(1);
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement