Advertisement
razvan_xd

CTPC.inc - RO VERSION

Apr 9th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.31 KB | None | 0 0
  1. /*______________________________________________________________________________
  2.  
  3. (C)lassic (T)oggle(P)layer(C)ontrollable - BRING BACK THE INVINCIBILITY !
  4. ________________________________________________________________________________
  5.  
  6.  
  7.     Libraria CTPC readuce posibilitatea de a face un jucator invincibil prin
  8. functia TogglePlayerControllable, posibilitate inlaturata din 0.3x . Libraria
  9. adauga un nou parametru functiei TogglePlayerControllable, invincibilitatea .
  10.  
  11.     In mod implicit, parametrul de invincibilitate este setat pe 1, deci daca
  12. includeti libraria CTPC intr-un script care script foloseste
  13. TogglePlayerControllable, nu va trebui sa modificati nimic pentru a readuce
  14. posibilitatea de a face un jucator invincibil, aceasta fiind activata automat .
  15.  
  16.     Cand parametrul de invincibilitate este setat pe 1, jucatorul este invincibil,
  17. cand este setat pe 0, TogglePlayerControllable functioneaza normal .
  18.  
  19. ________________________________________________________________________________
  20.  
  21. Noua sintaxa:
  22.  
  23.     TogglePlayerControllable ( playerid, toggle, invincibility = 1 );
  24.  
  25. ________________________________________________________________________________
  26.  
  27. Exemple de folosire:
  28.  
  29.     TogglePlayerControllable ( playerid, 0, 0 ); // Jucatorul va fi blocat .
  30.     TogglePlayerControllable ( playerid, 0, 1 ); // Jucatorul va fi blocat si invincibil .
  31.     TogglePlayerControllable ( playerid, 0 ); // Jucatorul va fi blocat si invincibi ( motivul este scris mai sus ) .
  32.     TogglePlayerControllable ( playerid, 1 ); // Jucatorul va fi deblocat .
  33.  
  34. ________________________________________________________________________________
  35.  
  36. Credite:
  37.     SA-MP Team
  38.     Persoana ce a conceput metoda ALS de HOOKING
  39.     RaZVaN ^ xD
  40.  
  41. ________________________________________________________________________________*/
  42.  
  43.  
  44. #if defined _ctpc_included
  45.     #endinput
  46. #endif
  47. #define _ctpc_included
  48.  
  49. #include < a_samp >
  50.  
  51. #if !defined EnableVehicleFriendlyFire
  52.     #error Libraria CTPC necesita sa aveti versiunea SA-MP 0.3x sau mai mare .
  53. #endif
  54.  
  55. stock _ctpc_TogglePlayerControllable ( playerid, toggle, invincibility = 1 )
  56. {
  57.     switch ( toggle )
  58.     {
  59.         case 0:
  60.         {
  61.             switch ( invincibility )
  62.             {
  63.                 case 0:
  64.                 {
  65.                     if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  66.                     {
  67.                         SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
  68.                         DeletePVar ( playerid, "CTPC_HEALTH" );
  69.                     }
  70.                 }
  71.                 case 1:
  72.                 {
  73.                     if ( !GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  74.                     {
  75.                         new Float: _ctpc_HP;
  76.                         GetPlayerHealth ( playerid, _ctpc_HP );
  77.                         if ( _ctpc_HP <= 0.0 ) return 1;
  78.                         SetPVarFloat ( playerid, "CTPC_HEALTH", _ctpc_HP );
  79.                     }
  80.                     SetPlayerHealth ( playerid, Float: 0x7F800000 );
  81.                 }
  82.                 default:
  83.                 {
  84.                     print ( "\n[ERROR] CTPC - Parametrul \"invincibility\" este invalid ( doar 0 sau 1 ) .\n[ERROR] CTPC - A fost setat automat pe 0 ( fara invincibilitate ) .\n" );
  85.                     if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  86.                     {
  87.                         SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
  88.                         DeletePVar ( playerid, "CTPC_HEALTH" );
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.         case 1:
  94.         {
  95.             if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  96.             {
  97.                 SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
  98.                 DeletePVar ( playerid, "CTPC_HEALTH" );
  99.             }
  100.         }
  101.         default:
  102.         {
  103.             print ( "\n[ERROR] CTPC - Parametrul \"toggle\" este invalid ( doar 0 sau 1 ) .\n[ERROR] CTPC - A fost setat automat pe 1 ( deblocat ) .\n" );
  104.             toggle = 1;
  105.             if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  106.             {
  107.                 SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
  108.                 DeletePVar ( playerid, "CTPC_HEALTH" );
  109.             }
  110.         }
  111.     }
  112.     return TogglePlayerControllable ( playerid, toggle );
  113. }
  114.  
  115. #if defined _ALS_TogglePlayerControllable
  116.     #undef TogglePlayerControllable
  117. #else
  118.     #define _ALS_TogglePlayerControllable
  119. #endif
  120.  
  121. #define TogglePlayerControllable _ctpc_TogglePlayerControllable
  122.  
  123. public OnPlayerDeath ( playerid, killerid, reason )
  124. {
  125.     if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  126.     {
  127.         DeletePVar ( playerid, "CTPC_HEALTH" );
  128.     }
  129.     CallLocalFunction ( "_ctpc_OnPlayerDeath", "iii", playerid, killerid, reason );
  130.     return 1;
  131. }
  132.  
  133. #if defined _ALS_OnPlayerDeath
  134.     #undef OnPlayerDeath
  135. #else
  136.     #define _ALS_OnPlayerDeath
  137. #endif
  138.  
  139. #define OnPlayerDeath _ctpc_OnPlayerDeath
  140.  
  141. forward _ctpc_OnPlayerDeath ( playerid, killerid, reason );
  142.  
  143. public OnPlayerSpawn ( playerid )
  144. {
  145.     if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  146.     {
  147.         DeletePVar ( playerid, "CTPC_HEALTH" );
  148.     }
  149.     CallLocalFunction ( "_ctpc_OnPlayerSpawn", "i", playerid );
  150.     return 1;
  151. }
  152.  
  153. #if defined _ALS_OnPlayerSpawn
  154.     #undef OnPlayerSpawn
  155. #else
  156.     #define _ALS_OnPlayerSpawn
  157. #endif
  158.  
  159. #define OnPlayerSpawn _ctpc_OnPlayerSpawn
  160.  
  161. forward _ctpc_OnPlayerSpawn ( playerid );
  162.  
  163. public OnPlayerTakeDamage ( playerid, issuerid, Float: amount, weaponid )
  164. {
  165.     if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
  166.     {
  167.         SetPlayerHealth ( playerid, Float: 0x7F800000 );
  168.     }
  169.     CallLocalFunction ( "_ctpc_OnPlayerTakeDamage", "iifi", playerid, issuerid, amount, weaponid );
  170.     return 1;
  171. }
  172.  
  173. #if defined _ALS_OnPlayerTakeDamage
  174.     #undef OnPlayerTakeDamage
  175. #else
  176.     #define _ALS_OnPlayerTakeDamage
  177. #endif
  178.  
  179. #define OnPlayerTakeDamage _ctpc_OnPlayerTakeDamage
  180.  
  181. forward _ctpc_OnPlayerTakeDamage ( playerid, issuerid, Float: amount, weaponid );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement