Advertisement
razvan_xd

Pt. Sp3cTeR @ gta-mp.ro

Dec 29th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.44 KB | None | 0 0
  1. new
  2.     UltimulVehicul [ MAX_PLAYERS ],
  3.     Arma [ MAX_PLAYERS ]
  4. ;
  5.  
  6. stock GetDriverID ( veh )
  7. {
  8.     foreach ( Player, i )
  9.     {
  10.         if( GetPlayerState ( i ) == PLAYER_STATE_DRIVER && GetPlayerVehicleID ( i ) == veh )
  11.             return i;
  12.     }
  13.     return INVALID_PLAYER_ID;
  14. }
  15.  
  16.  
  17. public OnPlayerStateChange ( playerid, newstate, oldstate )
  18. {
  19.     if ( newstate == PLAYER_STATE_DRIVER )
  20.     {
  21.         UltimulVehicul [ playerid ] = GetPlayerVehicleID ( playerid );
  22.         foreach ( Player, i )
  23.         {
  24.             if ( GetPlayerVehicleID ( i ) == UltimulVehicul [ playerid ] )
  25.             {
  26.                 if ( i == playerid ) continue;
  27.                 SetPlayerArmedWeapon ( i, Arma [ i ] );
  28.             }
  29.         }
  30.     }
  31.    
  32.     if ( newstate == PLAYER_STATE_PASSENGER )
  33.     {
  34.         if ( GetDriverID ( GetPlayerVehicleID ( playerid ) ) == INVALID_PLAYER_ID )
  35.         {
  36.             foreach ( Player, i )
  37.             {
  38.                 new
  39.                     arma = GetPlayerWeapon ( i )
  40.                 ;
  41.                 if ( arma != 0 )
  42.                 {
  43.                     Arma [ i ] = arma;
  44.                     SetPlayerArmedWeapon ( i, 0 );
  45.                 }
  46.             }
  47.         }
  48.     }
  49.  
  50.     if ( oldstate == PLAYER_STATE_DRIVER )
  51.     {
  52.         foreach ( Player, i )
  53.         {
  54.             if ( ( GetPlayerVehicleID ( i ) == UltimulVehicul [ playerid ] ) && UltimulVehicul [ playerid ] != INVALID_VEHICLE_ID )
  55.             {
  56.                 new
  57.                     arma = GetPlayerWeapon ( i )
  58.                 ;
  59.                 if ( arma != 0 )
  60.                 {
  61.                     Arma [ i ] = arma;
  62.                     SetPlayerArmedWeapon ( i, 0 );
  63.                 }
  64.             }
  65.         }
  66.         UltimulVehicul [ playerid ] = INVALID_VEHICLE_ID;
  67.     }
  68.     return 1;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement