Advertisement
EmmanuelU

[UPDATED 9/3/13] Advanced Track Network Players

Sep 3rd, 2013
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. //Extension of Brian's Multiplayer Struct
  2.  
  3. //put this in a header file (.h)
  4.  
  5. /*
  6. Example Usage:
  7. int tick;
  8. for(tick = 0; tick <= PLAYER16; tick++){
  9.  
  10.     YOURFUNCTIONHERE(players[tick].ped);
  11.     YOURFUNCTIONHERE(players[tick].vehicle);
  12.     YOURFUNCTIONHERE(players[tick].id);
  13.  
  14.     //etc...
  15. }
  16.  
  17. */
  18.     Ped online_char;
  19.    
  20. enum ePlayers
  21. {
  22.     PLAYER1,
  23.     PLAYER2,
  24.     PLAYER3,
  25.     PLAYER4,
  26.     PLAYER5,
  27.     PLAYER6,
  28.     PLAYER7,
  29.     PLAYER8,
  30.     PLAYER9,
  31.     PLAYER10,
  32.     PLAYER11,
  33.     PLAYER12,
  34.     PLAYER13,
  35.     PLAYER14,
  36.     PLAYER15,
  37.     PLAYER16,
  38. };
  39.  
  40.     typedef struct Multiplayer{
  41.         char* name;
  42.         Ped ped;
  43.         int id;
  44.         float x,y,z;
  45.         int weapon;
  46.         Vehicle vehicle;
  47.         uint model;
  48.     } Multiplayer;
  49.  
  50.     Multiplayer players[16];
  51.    
  52.     void SetMutliplayer(void){
  53.         for(i = 0;i <= 15;i++){
  54.             if(!IS_NETWORK_PLAYER_ACTIVE(i)) continue;
  55.             if(GET_PLAYER_ID() == i) continue;
  56.             GET_PLAYER_CHAR(i,&online_char);
  57.             players[i].ped = online_char;
  58.             players[i].name = GET_PLAYER_NAME(i);
  59.             players[i].id = i;
  60.             if(DOES_CHAR_EXIST(online_char)){
  61.                 GET_CURRENT_CHAR_WEAPON(online_char,&players[i].weapon);
  62.                 GET_CAR_CHAR_IS_USING(online_char, &players[i].vehicle);
  63.                 GET_CHAR_COORDINATES(online_char, &players[i].x,&players[i].y,&players[i].z);
  64.                 GET_CHAR_MODEL(online_char,&players[i].model);
  65.             }
  66.         }
  67.         return;
  68.     }
  69.  
  70. ///////////////////////////
  71.  
  72. //Put this in your main function and have this set to a loop
  73.  
  74. do{
  75.     WAIT(0);
  76.     SetMutliplayer();
  77. } while(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement