Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*______________________________________________________________________________
- (C)lassic (T)oggle(P)layer(C)ontrollable - BRING BACK THE INVINCIBILITY !
- ________________________________________________________________________________
- Libraria CTPC readuce posibilitatea de a face un jucator invincibil prin
- functia TogglePlayerControllable, posibilitate inlaturata din 0.3x . Libraria
- adauga un nou parametru functiei TogglePlayerControllable, invincibilitatea .
- In mod implicit, parametrul de invincibilitate este setat pe 1, deci daca
- includeti libraria CTPC intr-un script care script foloseste
- TogglePlayerControllable, nu va trebui sa modificati nimic pentru a readuce
- posibilitatea de a face un jucator invincibil, aceasta fiind activata automat .
- Cand parametrul de invincibilitate este setat pe 1, jucatorul este invincibil,
- cand este setat pe 0, TogglePlayerControllable functioneaza normal .
- ________________________________________________________________________________
- Noua sintaxa:
- TogglePlayerControllable ( playerid, toggle, invincibility = 1 );
- ________________________________________________________________________________
- Exemple de folosire:
- TogglePlayerControllable ( playerid, 0, 0 ); // Jucatorul va fi blocat .
- TogglePlayerControllable ( playerid, 0, 1 ); // Jucatorul va fi blocat si invincibil .
- TogglePlayerControllable ( playerid, 0 ); // Jucatorul va fi blocat si invincibi ( motivul este scris mai sus ) .
- TogglePlayerControllable ( playerid, 1 ); // Jucatorul va fi deblocat .
- ________________________________________________________________________________
- Credite:
- SA-MP Team
- Persoana ce a conceput metoda ALS de HOOKING
- RaZVaN ^ xD
- ________________________________________________________________________________*/
- #if defined _ctpc_included
- #endinput
- #endif
- #define _ctpc_included
- #include < a_samp >
- #if !defined EnableVehicleFriendlyFire
- #error Libraria CTPC necesita sa aveti versiunea SA-MP 0.3x sau mai mare .
- #endif
- stock _ctpc_TogglePlayerControllable ( playerid, toggle, invincibility = 1 )
- {
- switch ( toggle )
- {
- case 0:
- {
- switch ( invincibility )
- {
- case 0:
- {
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
- DeletePVar ( playerid, "CTPC_HEALTH" );
- }
- }
- case 1:
- {
- if ( !GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- new Float: _ctpc_HP;
- GetPlayerHealth ( playerid, _ctpc_HP );
- if ( _ctpc_HP <= 0.0 ) return 1;
- SetPVarFloat ( playerid, "CTPC_HEALTH", _ctpc_HP );
- }
- SetPlayerHealth ( playerid, Float: 0x7F800000 );
- }
- default:
- {
- print ( "\n[ERROR] CTPC - Parametrul \"invincibility\" este invalid ( doar 0 sau 1 ) .\n[ERROR] CTPC - A fost setat automat pe 0 ( fara invincibilitate ) .\n" );
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
- DeletePVar ( playerid, "CTPC_HEALTH" );
- }
- }
- }
- }
- case 1:
- {
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
- DeletePVar ( playerid, "CTPC_HEALTH" );
- }
- }
- default:
- {
- print ( "\n[ERROR] CTPC - Parametrul \"toggle\" este invalid ( doar 0 sau 1 ) .\n[ERROR] CTPC - A fost setat automat pe 1 ( deblocat ) .\n" );
- toggle = 1;
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- SetPlayerHealth ( playerid, GetPVarFloat ( playerid, "CTPC_HEALTH" ) );
- DeletePVar ( playerid, "CTPC_HEALTH" );
- }
- }
- }
- return TogglePlayerControllable ( playerid, toggle );
- }
- #if defined _ALS_TogglePlayerControllable
- #undef TogglePlayerControllable
- #else
- #define _ALS_TogglePlayerControllable
- #endif
- #define TogglePlayerControllable _ctpc_TogglePlayerControllable
- public OnPlayerDeath ( playerid, killerid, reason )
- {
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- DeletePVar ( playerid, "CTPC_HEALTH" );
- }
- CallLocalFunction ( "_ctpc_OnPlayerDeath", "iii", playerid, killerid, reason );
- return 1;
- }
- #if defined _ALS_OnPlayerDeath
- #undef OnPlayerDeath
- #else
- #define _ALS_OnPlayerDeath
- #endif
- #define OnPlayerDeath _ctpc_OnPlayerDeath
- forward _ctpc_OnPlayerDeath ( playerid, killerid, reason );
- public OnPlayerSpawn ( playerid )
- {
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- DeletePVar ( playerid, "CTPC_HEALTH" );
- }
- CallLocalFunction ( "_ctpc_OnPlayerSpawn", "i", playerid );
- return 1;
- }
- #if defined _ALS_OnPlayerSpawn
- #undef OnPlayerSpawn
- #else
- #define _ALS_OnPlayerSpawn
- #endif
- #define OnPlayerSpawn _ctpc_OnPlayerSpawn
- forward _ctpc_OnPlayerSpawn ( playerid );
- public OnPlayerTakeDamage ( playerid, issuerid, Float: amount, weaponid )
- {
- if ( GetPVarFloat ( playerid, "CTPC_HEALTH" ) )
- {
- SetPlayerHealth ( playerid, Float: 0x7F800000 );
- }
- CallLocalFunction ( "_ctpc_OnPlayerTakeDamage", "iifi", playerid, issuerid, amount, weaponid );
- return 1;
- }
- #if defined _ALS_OnPlayerTakeDamage
- #undef OnPlayerTakeDamage
- #else
- #define _ALS_OnPlayerTakeDamage
- #endif
- #define OnPlayerTakeDamage _ctpc_OnPlayerTakeDamage
- forward _ctpc_OnPlayerTakeDamage ( playerid, issuerid, Float: amount, weaponid );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement