Chaoz

Callbackz 3.0

Oct 27th, 2011
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 51.05 KB | None | 0 0
  1. /*
  2. |===============================================================================|
  3. |                               Callbackz                                       |
  4. |Description:                                                                   |
  5. |   This include adds new callbacks and functions to your script.               |
  6. |                                                                               |
  7. |Current Callbacks                                                              |
  8. |   OnPlayerPause(playerid)                                                     |
  9. |   OnPlayerAFK(playerid)                                                       |
  10. |   OnPlayerWeaponChange(playerid, newweaponid, oldweaponid)                    |
  11. |   OnPlayerVirtualWorldChange(playerid, newworldid, oldworldid)                |
  12. |   OnPlayerEnterWater(playerid)                                                |
  13. |   OnPlayerExitWater(playerid)                                                 |
  14. |   OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth)            |
  15. |   OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour)            |
  16. |   OnPlayerMoneyChange(playerid, newmoney, oldmoney)                           |
  17. |   OnPlayerUseVendingMachine(playerid)                                         |
  18. |   OnPlayerPlayAnimation(playerid, Lib[], Name[])                              |
  19. |   OnPlayerScoreChange(playerid, newscore, oldscore)                           |
  20. |   OnVehicleCreate(vehicleid)                                                  |
  21. |   OnVehicleDestroy(vehicleid)                                                 |
  22. |   OnPlayerStartDriveby(playerid, ispassenger)                                 |
  23. |   OnPlayerEndDriveby(playerid)                                                |
  24. |                                                                               |
  25. |Current Functions:                                                             |
  26. |   Player Functions:                                                           |
  27. |       Single Player:                                                          |
  28. |           SetPlayerAFK(playerid, bool:afk)                                    |
  29. |           IsPlayerAFK(playerid)                                               |
  30. |           IsPlayerPaused(playerid)                                            |
  31. |           IsPlayerInWater(playerid)                                           |
  32. |           IsPlayerParachuting(playerid)                                       |
  33. |           IsPlayerUsingMachine(playerid)                                      |
  34. |           EnablePlayerDriveBy(playerid, bool:enable)                          |
  35. |           EnablePlayerInteriorDamage(playerid, bool:enable)                   |
  36. |           CrashPlayer(playerid)                                               |
  37. |           GetPlayerFPS(playerid)                                              |
  38. |           Reconnect(playerid)                                                 |
  39. |           ReconnectEx(playerid, time)                                         |
  40. |           EnableVendingMachinesForPlayer(playerid, bool:enable)               |
  41. |           EnableCapsForPlayer(playerid, bool:enable)                          |
  42. |           GivePlayerScore(playerid, score)                                    |
  43. |           SetPlayerFacingPos(playerid, Float:X, Float:Y)                      |
  44. |                                                                               |
  45. |       All Players:                                                            |
  46. |           EnableDriveBy(bool:enable)                                          |
  47. |           EnableInteriorDamage(bool:enable)                                   |
  48. |           EnableUseVendingMachines(bool:enable)                               |
  49. |           EnableCapsLock(bool:enable)                                         |
  50. |                                                                               |
  51. |   Vehicle Functions:                                                          |
  52. |       Single Vehicle:                                                         |
  53. |           GetVehiclePlate(vehicleid, Plate[], size)                           |
  54. |           GetVehicleColor(vehicleid, &color1, &color2)                        |
  55. |           GetVehicleInterior(vehicleid)                                       |
  56. |           GetVehicleIDFromPlate(Plate[])                                      |
  57. |           IsVehicleCreated(vehicleid)                                         |
  58. |           EnableTiresDamageForVehicle(vehicleid, bool:enable)                 |
  59. |           GetVehicleType(model)                                               |
  60. |           GetVehicleRot(vehicleid, Float:X, Float:Y, Float:Z)                 |
  61. |                                                                               |
  62. |       All Vehicles:                                                           |
  63. |           EnableTiresDamage(bool:enable)                                      |
  64. |                                                                               |
  65. |   Extra:                                                                      |
  66. |       GetOnlinePlayers(bool:CountNPC)                                         |
  67. |       AddForbidenNick(nick[])                                                 |
  68. |       AddForbidenWord(word[])                                                 |
  69. |       GetMiddle2D(Float:x1, Float:y1, Float:x2, Float:y2, Float:rX, Float:rY) |
  70. |       GetMiddle3D(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:rX, Float:rY, Float:rZ)|
  71. |                                                                               |
  72. |ChangeLog:                                                                     |
  73. |   17/08/2011:                                                                 |
  74. |       *First Release (Beta).                                                  |
  75. |   18/08/2011:                                                                 |
  76. |       *Fixed AddStaticVehicle bub.                                            |
  77. |       *Fixed AddStaticVehicleEx bug.                                          |
  78. |       *Fixed CreteVehicle bug.                                                |
  79. |   22/08/2011:                                                                 |
  80. |       *Fixed OnPlayerPause false positive bug.                                |
  81. |       *Fixed IsPlayerParachuting false positive bug.                          |
  82. |       *OnPlayerUseMachine is now OnPlayerUseVendingMachine.                   |
  83. |       *Added new callbacks:                                                   |
  84. |           **OnPlayerPlayAnimation                                             |
  85. |           **OnPlayerScoreChange                                               |
  86. |       Added new functions:                                                    |
  87. |           **EnableVendingMachines                                             |
  88. |           **EnableVendingMachinesForPlayer                                    |
  89. |           **EnableCapsLock                                                    |
  90. |           **EnableCapsLockForPlayer                                           |
  91. |           **GivePlayerScore                                                   |
  92. |           **GetOnlinePlayers                                                  |
  93. |   06/09/2011:                                                                 |
  94. |       *Rewrited OnPlayerShotPlayer (wups method).                             |
  95. |       *Rewrited part of the code, now more efficient.                         |
  96. |       *Added the posivility to remove functions and callbacks.                |
  97. |       *Added new functions:                                                   |
  98. |           **AddForbidenNick                                                   |
  99. |           **AddForbidenWord                                                   |
  100. |           **EnableTiresDamage                                                 |
  101. |           **EnableTiresDamageForVehicle                                       |
  102. |           **GetVehicleType                                                    |
  103. |   09/09/2011:                                                                 |
  104. |       *Documented All the include.                                            |
  105. |       *EnablePlayerDriveBy is now EnableDriveByForPlayer.                     |
  106. |       *EnablePlayerInteriorDamage is now EnableInteriorDamageForPlayer.       |
  107. |   12/09/2011:                                                                 |
  108. |       *EnableCapsLock is now EnableCaps.                                      |
  109. |       *Added new callbacks:                                                   |
  110. |           **OnPlayerStartDriveBy                                              |
  111. |           **OnPlayerEndDriveBy                                                |
  112. |       *Added new functions:                                                   |
  113. |           **GetMiddle2D                                                       |
  114. |           **GetMiddle3D                                                       |
  115. |           **SetPlayerFacingPos                                                |
  116. |           **GetVehicleRot                                                     |
  117. |   16/09/2011:                                                                 |
  118. |       *Added plate[] param to vehicle creation functions                      |
  119. |   18/09/2011:                                                                 |
  120. |       *Removed OnPlayerShotPlayr                                              |
  121. |                                                                               |
  122. |Extra:                                                                         |
  123. |   You can enable or disable some callbacks/functions by comenting some        |
  124. |   macros on the config. This will reduce the amx size, and increase the       |
  125. |   speed of the script.                                                        |
  126. |                                                                               |
  127. |   Config Line:    =>  187                                                     |
  128. |                                                                               |
  129. |Credits:                                                                       |
  130. |   JernejL         =>  GetPlayerFPS & Reconnect method, & encode_tires Function|
  131. |   Stepashka       =>  GetVehicleRot Function                                  |
  132. |   Y_Less          =>  YSI                                                     |
  133. |   The Chaoz       =>  Scripting                                               |
  134. |                                                                               |
  135. |===============================================================================|*/
  136.  
  137. #if !defined _CBz_INCLUDED
  138.     #define _CBz_INCLUDED
  139. #else
  140.     #endinput
  141. #endif
  142.  
  143. #include <YSI\y_hooks>
  144.  
  145. #tryinclude <foreach>
  146.  
  147. #define PUBLIC:%0(%1)   \
  148.     forward %0(%1); public %0(%1)
  149.  
  150. #if !defined PRESSED
  151.     #define PRESSED(%0) \
  152.         (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  153. #endif
  154. #if !defined RELEASED
  155.     #define RELEASED(%0)    \
  156.         (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  157. #endif
  158.  
  159. #if !defined LOWER
  160.     #define LOWER(%0)   \
  161.         for(new index; index<strlen(%0); index++)if(%0[index]>64 && %0[index]<91)%0[index] += 32
  162. #endif
  163.  
  164. #if !defined foreach
  165.         #define foreach(%1,%2) for(new %2; %2<GetMaxPlayers(); %2++) if(IsPlayerConnected(%2))
  166.         #define __SSCANF_FOREACH__
  167. #endif
  168.  
  169. #define INVALID_VEHICLE_TYPE        (-1)
  170. #define VEHICLE_TYPE_AIRPLANE       (0)
  171. #define VEHICLE_TYPE_HELICOPTER     (1)
  172. #define VEHICLE_TYPE_BIKE           (2)
  173. #define VEHICLE_TYPE_CONVERTIBLE    (3)
  174. #define VEHICLE_TYPE_INDUSTRIAL     (4)
  175. #define VEHICLE_TYPE_LOWRIDER       (5)
  176. #define VEHICLE_TYPE_OFFROAD        (6)
  177. #define VEHICLE_TYPE_PUBLICSERV     (7)
  178. #define VEHICLE_TYPE_SALOON         (8)
  179. #define VEHICLE_TYPE_SPORT          (9)
  180. #define VEHICLE_TYPE_STATION        (10)
  181. #define VEHICLE_TYPE_BOAT           (11)
  182. #define VEHICLE_TYPE_TRAILER        (12)
  183. #define VEHICLE_TYPE_UNIQUE         (13)
  184. #define VEHICLE_TYPE_RC             (14)
  185.  
  186. #define PAUSE_TIME                  (5)
  187.  
  188. //==================================CONFIG=================================
  189. #define AFK_TIME                    (30)
  190. #define INTERVAL                    (350)
  191. #define MAX_BWORDS                  (400)
  192. #define MAX_BNAMES                  (100)
  193. #define ENGLISH             //comment this line to use spanish languaje on messajes
  194. #define USE_VEHICLE_DATA    //coment this line to disable vehicle callbacks & functions
  195. //=========================================================================
  196.  
  197. enum _I{
  198.     bool:pAFK,
  199.     bool:pPaused,
  200.     bool:pInWater,
  201.     bool:pParachuting,
  202.     bool:pMachine,
  203.     bool:pDriveBy,
  204.     bool:pIntDamage,
  205.     bool:pReconnect,
  206.     bool:pUseMachine,
  207.     bool:pPlayingAnim,
  208.     bool:pCaps,
  209.     bool:pVend,
  210.     bool:pDBing,
  211.     Float:pP[4],
  212.     pTimer,
  213.     pTime[2],
  214.     pWeap,
  215.     pVWorld,
  216.     Float:pHealth,
  217.     Float:pArmour,
  218.     pMoney,
  219.     pScore,
  220.     pWeaps[13],
  221.     pAmmo[13],
  222.     pFPS,
  223.     pDrk,
  224.     pIP[16],
  225. };
  226.  
  227. #if defined USE_VEHICLE_DATA
  228.     enum _V{
  229.         bool:vCreated,
  230.         bool:vTires,
  231.         vColor[2],
  232.         vPlate[32],
  233.         vInterior,
  234.     };
  235. #endif
  236.  
  237. enum _S{
  238.     bool:sDriveby=true,
  239.     bool:sCaps=true,
  240.     bool:sVending=true,
  241.     bool:sIntDamage=true
  242. };
  243.  
  244. new I[MAX_PLAYERS][_I], S[_S], File:Fhnd,
  245.     #if defined USE_VEHICLE_DATA
  246.         V[MAX_VEHICLES+1][_V],
  247.     #endif
  248.     bWordsC, bWords[MAX_BWORDS][16],
  249.     bNamesC, bNames[MAX_BNAMES][MAX_PLAYER_NAME];
  250.  
  251. forward OnPlayerPause(playerid);
  252. forward OnPlayerAFK(playerid);
  253. forward OnPlayerWeaponChange(playerid, newweaponid, oldweaponid);
  254. forward OnPlayerVirtualWorldChange(playerid, newworldid, oldworldid);
  255. forward OnPlayerEnterWater(playerid);
  256. forward OnPlayerExitWater(playerid);
  257. forward OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth);
  258. forward OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour);
  259. forward OnPlayerMoneyChange(playerid, newmoney, oldmoney);
  260. forward OnPlayerUseVendingMachine(playerid);
  261. forward OnPlayerPlayAnimation(playerid, Lib[], Name[]);
  262. forward OnPlayerScoreChange(playerid, newscore, oldscore);
  263. forward OnPlayerStartDriveBy(playerid, ispassenger);
  264. forward OnPlayerEndDriveBy(playerid);
  265. #if defined USE_VEHICLE_DATA
  266.     forward OnVehicleCreate(vehicleid);
  267.     forward OnVehicleDestroy(vehicleid);
  268. #endif
  269.  
  270. /*==============================
  271. Function:
  272.     SetPlayerAFK
  273.    
  274. Params:
  275.     playerid => ID of the player.
  276.     afk => true/false (true Player is now afk, otherwise false)
  277.    
  278. Return:
  279.     1 if success
  280.    
  281. Related Functions:
  282.     IsPlayerAFK
  283.    
  284. Related Callbacks:
  285.     OnPlayerAFK
  286.  
  287. Extra:
  288.     -
  289. ==============================*/
  290. stock SetPlayerAFK(playerid, bool:afk)
  291. {
  292.     I[playerid][pAFK] = afk;
  293.     return 1;
  294. }
  295.  
  296. /*==============================
  297. Function:
  298.     IsPlayerAFK
  299.    
  300. Params:
  301.     playerid => ID of the player.
  302.    
  303. Return:
  304.     true if the player is afk, otherwise false.
  305.    
  306. Related Fctunions:
  307.     SetPlayerAFK
  308.  
  309. Related Callbacks:
  310.     OnPlayerAFK
  311.  
  312. Extra:
  313.     -
  314. ==============================*/
  315. stock IsPlayerAFK(playerid)
  316.     return I[playerid][pAFK];
  317.  
  318. /*==============================
  319. Function:
  320.     IsPlayerPaused
  321.  
  322. Params:
  323.     playerid => ID of the player
  324.  
  325. Return:
  326.     true if the player is paused, otherwise false.
  327.  
  328. Related Functions:
  329.     -
  330. Related Callbacks:
  331.     OnPlayerPause
  332.  
  333. Extra:
  334.     -
  335. ==============================*/
  336. stock IsPlayerPaused(playerid)
  337.     return I[playerid][pPaused];
  338.  
  339. /*==============================
  340. Function:
  341.     IsPlayerInWater
  342.    
  343. Params:
  344.     playerid => ID of the player
  345.    
  346. Return:
  347.     true if the player is on water, otherwise false.
  348.  
  349. Related Functions:
  350.     -
  351.    
  352. Related Callbacks:
  353.     OnPlayerEnterWater
  354.     OnPlayerExitWater
  355.  
  356. Extra:
  357.     -
  358. ==============================*/
  359. stock IsPlayerInWater(playerid)
  360.     return I[playerid][pInWater];
  361.  
  362. /*==============================
  363. Function:
  364.     IsPlayerParachuting
  365.    
  366. Params:
  367.     playerid => ID of the player
  368.    
  369. Return:
  370.     true if the player is falling with a parachute, otherwise false.
  371.  
  372. Related Functions:
  373.     -
  374.    
  375. Related Callbacks:
  376.     -
  377.  
  378. Extra:
  379.     -
  380. ==============================*/
  381. stock IsPlayerParachuting(playerid)
  382.     return I[playerid][pParachuting];
  383.  
  384. /*==============================
  385. Function:
  386.     IsPlayerUsingMachine
  387.    
  388. Params:
  389.     playerid => ID of the player
  390.    
  391. Return:
  392.     true if the player is using a vending machine, otherwise false.
  393.  
  394. Related Functions:
  395.     -
  396.    
  397. Related Callbacks:
  398.     OnPlayerUseVendingMachine
  399.  
  400. Extra:
  401.     -
  402. ==============================*/
  403. stock IsPlayerUsingMachine(playerid)
  404.     return I[playerid][pMachine];
  405.  
  406. /*==============================
  407. Function:
  408.     EnableDriveByForPlayer
  409.    
  410. Params:
  411.     playerid => ID of the player
  412.     enable => true/false (true will allow the player drive by, otherwise false)
  413.    
  414. Return:
  415.     1 if success
  416.    
  417. Related Functions:
  418.     EnableDriveBy
  419.  
  420. Related Callbacks:
  421.     -
  422.  
  423. Extra:
  424.     -
  425. ==============================*/
  426. stock EnablerDriveByForPlayer(playerid, bool:enable)
  427. {
  428.     I[playerid][pDriveBy] = enable;
  429.     return 1;
  430. }
  431.  
  432. /*==============================
  433. Function:
  434.     EnableDriveBy
  435.  
  436. Params:
  437.     enable => true/false (true will allow the player drive by, otherwise false)
  438.  
  439. Return:
  440.     1 if success
  441.  
  442. Related Functions:
  443.     EnableDriveByForPlayer
  444.  
  445. Related Callbacks:
  446.     -
  447.  
  448. Extra:
  449.     -
  450. ==============================*/
  451. stock EnableDriveBy(bool:enable)
  452. {
  453.     foreach(Player, i)I[i][pDriveBy] = enable;
  454.     S[sDriveBy] = enable;
  455.     return 1;
  456. }
  457.  
  458. /*==============================
  459. Function:
  460.     EnableInteriorDamageForPlayer
  461.  
  462. Params:
  463.     playerid => ID of the player
  464.     enable => true/false (true will allow the player to shot on interiors, otherwise false)
  465.  
  466. Return:
  467.     1 if success
  468.  
  469. Related Functions:
  470.     EnableInteriorDamage
  471.  
  472. Related Callbacks:
  473.     -
  474.  
  475. Extra:
  476.     -
  477. ==============================*/
  478. stock EnableInteriorDamageForPlayer(playerid, bool:enable)
  479. {
  480.     I[playerid][pIntDamage] = enable;
  481.     return 1;
  482. }
  483.  
  484. /*==============================
  485. Function:
  486.     EnableInteriorDamage
  487.  
  488. Params:
  489.     enable => true/false (true will allow the player to shot on interiors, otherwise false)
  490.  
  491. Return:
  492.     1 if success
  493.  
  494. Related Functions:
  495.     EnableInteriorDamageForPlayer
  496.  
  497. Related Callbacks:
  498.     -
  499.  
  500. Extra:
  501.     -
  502. ==============================*/
  503. stock EnableInteriorDamage(bool:enable)
  504. {
  505.     foreach(Player, i)I[i][pIntDamage] = enable;
  506.     sIntDamage = enable;
  507.     return 1;
  508. }
  509.  
  510. /*==============================
  511. Function:
  512.     EnableVendingMachinesForPlayer
  513.  
  514. Params:
  515.     playerid => ID of the player
  516.     enable => true/false (true will allow the player to use vending machines, otherwise false)
  517.  
  518. Return:
  519.     1 if success
  520.  
  521. Related Functions:
  522.     EanbleVendingMachines
  523.  
  524. Related Callbacks:
  525.     OnPlayerUseVendingMachine
  526.  
  527. Extra:
  528.     -
  529. ==============================*/
  530. stock EnableVendingMachinesForPlayer(playerid, bool:enable)
  531. {
  532.     I[playerid][pUseMachine] = enable;
  533.     return 1;
  534. }
  535.  
  536. /*==============================
  537. Function:
  538.     EnableUseVendingMachines
  539.  
  540. Params:
  541.    
  542.  
  543. Return:
  544.     1 is success
  545.  
  546. Related Functions:
  547.     EnableVendingMachinesForPlayer
  548.  
  549. Related Callbacks:
  550.     OnPlayerUseVendingMachine
  551.  
  552. Extra:
  553.     -
  554. ==============================*/
  555. stock EnableUseVendingMachines(bool:enable)
  556. {
  557.     foreach(Player, i)I[i][pUseMachine] = enable;
  558.     S[sVending] = enable;
  559.     return 1;
  560. }
  561.  
  562. /*==============================
  563. Function:
  564.     EnableCapsForPlayer
  565.  
  566. Params:
  567.     playerid => ID of the player
  568.     enable => true/false (true will allow the player to use caps, otherwise false)
  569.  
  570. Return:
  571.     1 if success
  572.  
  573. Related Functions:
  574.     EnableCaps
  575.  
  576. Related Callbacks:
  577.     -
  578.  
  579. Extra:
  580.     -
  581. ==============================*/
  582. stock EnableCapsForPlayer(playerid, bool:enable)
  583. {
  584.     I[playerid][pCaps] = enable;
  585.     return 1;
  586. }
  587.  
  588. /*==============================
  589. Function:
  590.     EanbleCaps
  591.  
  592. Params:
  593.     enable => true/false (true will allow the player to use caps, otherwise false)
  594.  
  595. Return:
  596.     1 if success
  597.  
  598. Related Functions:
  599.     EnableCapsForPlayer
  600.  
  601. Related Callbacks:
  602.     -
  603.  
  604. Extra:
  605.     -
  606. ==============================*/
  607. stock EnableCaps(bool:enable)
  608. {
  609.     foreach(Player, i)I[i][pCaps] = enable;
  610.     S[sCaps] = enable;
  611.     return 1;
  612. }
  613.  
  614. /*==============================
  615. Function:
  616.     CrashPlayer
  617.  
  618. Params:
  619.     playerid => ID of the player
  620.  
  621. Return:
  622.     -
  623.  
  624. Related Functions:
  625.     -
  626.  
  627. Related Callbacks:
  628.     -
  629.  
  630. Extra:
  631.     -
  632. ==============================*/
  633. stock CrashPlayer(playerid)
  634.     return ApplyAnimation(playerid, "INVALID", "INVALID", 1, 0, 0, 0, 0, 0);
  635.  
  636. /*==============================
  637. Function:
  638.     GetPlayerFPS
  639.  
  640. Params:
  641.     playerid => ID of the player
  642.  
  643. Return:
  644.     Player's FPS
  645.  
  646. Related Functions:
  647.     -
  648.  
  649. Related Callbacks:
  650.     -
  651.  
  652. Extra:
  653.     -
  654. ==============================*/
  655. stock GetPlayerFPS(playerid)
  656.     return I[playerid][pFPS];
  657.  
  658. /*==============================
  659. Function:
  660.     Reconnect
  661.  
  662. Params:
  663.     playerid => ID of the player
  664.  
  665. Return:
  666.     1 if success
  667.  
  668. Related Functions:
  669.     ReconnectEx
  670.  
  671. Related Callbacks:
  672.     -
  673.  
  674. Extra:
  675.     -
  676. ==============================*/
  677. stock Reconnect(playerid)
  678. {
  679.     static cmdstr[23];
  680.     GetPlayerIp(playerid, I[playerid][pIP], 16);
  681.     format(cmdstr, 23, "banip %s", I[playerid][pIP]);
  682.     I[playerid][pReconnect] = true;
  683.     return SendRconCommand(cmdstr);
  684. }
  685.  
  686. /*==============================
  687. Function:
  688.     ReconnectEx
  689.  
  690. Params:
  691.     playerid => ID of the player
  692.     time => The time to wait before reconnect the player
  693.  
  694. Return:
  695.     -
  696.  
  697. Related Functions:
  698.     Reconnect
  699.  
  700. Related Callbacks:
  701.     -
  702.  
  703. Extra:
  704.     -
  705. ==============================*/
  706. stock ReconnectEx(playerid, time)
  707.     return SetTimerEx("ForceReconnect", time, false, "i", playerid);
  708.  
  709. /*==============================
  710. Function:
  711.     GivePlayerScore
  712.  
  713. Params:
  714.     playerid => ID of the player
  715.     score => amount of the score to increase the player's score
  716.  
  717. Return:
  718.     1 if success
  719.  
  720. Related Functions:
  721.     -
  722.  
  723. Related Callbacks:
  724.     -
  725.  
  726. Extra:
  727.     -
  728. ==============================*/
  729. stock GivePlayerScore(playerid, score)
  730. {
  731.     I[playerid][pScore] += score;
  732.     return SetPlayerScore(playerid, I[playerid][pScore]);
  733. }
  734.  
  735. /*==============================
  736. Function:
  737.     SetPlayerFacingPos
  738.  
  739. Params:
  740.     playerid => ID of the player
  741.     Float:x => The x coordinate of the position the player will face.
  742.     Float:y => The y coordinate of the position the player will face.
  743.  
  744. Return:
  745.     1 if success
  746.  
  747. Related Functions:
  748.     -
  749.  
  750. Related Callbacks:
  751.     -
  752.  
  753. Extra:
  754.     -
  755. ==============================*/
  756. stock SetPlayerFacingPos(playerid, Float:x, Float:y)
  757. {
  758.     if(!floatcmp(x, 0.0) && !floatcmp(y, 0.0))return 0;
  759.     static Float:p[3];
  760.     GetPlayerPos(playerid, p[0], p[1], p[2]);
  761.     p[2] = atan2((y-p[1]), (x-p[0])) + 270;
  762.     if(p[2]>360)p[2]-=360;
  763.     return SetPlayerFacingAngle(playerid, p[2]);
  764. }
  765.  
  766. #if defined USE_VEHICLE_DATA
  767.     /*==============================
  768.     Function:
  769.         GetVehiclePlate
  770.  
  771.     Params:
  772.         vehicleid => ID of the vehicle
  773.         Plate => array to store the plate of the vehicle
  774.         size => size of the array
  775.  
  776.     Return:
  777.         1 if success
  778.  
  779.     Related Functions:
  780.         GetVehicleColor
  781.         GetVehicleInterior
  782.  
  783.     Related Callbacks:
  784.         -
  785.  
  786.     Extra:
  787.         -
  788.     ==============================*/
  789.     stock GetVehiclePlate(vehicleid, Plate[], size)
  790.     {
  791.         format(Plate, size, "%s", V[vehicleid][vPlate]);
  792.         return 1;
  793.     }
  794.  
  795.     /*==============================
  796.     Function:
  797.         GetVehicleColor
  798.  
  799.     Params:
  800.         vehicleid => ID of the vehicle
  801.         color1 => variable to store the 1º color
  802.         color2 => variable to store the 2º color
  803.  
  804.     Return:
  805.         1 if success
  806.  
  807.     Related Functions:
  808.         GetVehiclePlate
  809.         GetVehicleInterior
  810.  
  811.     Related Callbacks:
  812.         -
  813.  
  814.     Extra:
  815.         -
  816.     ==============================*/
  817.     stock GetVehicleColor(vehicleid, &color1, &color2)
  818.     {
  819.         color1 = V[vehicleid][vColor][0];
  820.         color2 = V[vehicleid][vColor][1];
  821.         return 1;
  822.     }
  823.    
  824.     /*==============================
  825.     Function:
  826.         GetVehicleInterior
  827.  
  828.     Params:
  829.         vehicleid => ID of the vehicle
  830.  
  831.     Return:
  832.         The vehicle's interior
  833.  
  834.     Related Functions:
  835.         GetVehiclePlate
  836.         GetVehicleColor
  837.  
  838.     Related Callbacks:
  839.         -
  840.  
  841.     Extra:
  842.         -
  843.     ==============================*/
  844.     stock GetVehicleInterior(vehicleid)
  845.         return V[vehicleid][vInterior];
  846.  
  847.     /*==============================
  848.     Function:
  849.         GetVehicleIDFromPlate
  850.  
  851.     Params:
  852.         Plate => Plate to search for
  853.  
  854.     Return:
  855.         -1 if no vehicle was found, otherwise the ID of the vehicle.
  856.  
  857.     Related Functions:
  858.         -
  859.  
  860.     Related Callbacks:
  861.         -
  862.  
  863.     Extra:
  864.         -
  865.     ==============================*/
  866.     stock GetVehicleIDFromPlate(Plate[])
  867.     {
  868.         static i;
  869.         for(i=1; i<=MAX_VEHICLES; i++)if(V[i][vCreated] && !strcmp(V[i][vPlate], Plate))break;
  870.         if(!V[i][vCreated] || strcmp(V[i][vPlate], Plate))i=-1;
  871.         return i;
  872.     }
  873.  
  874.     /*==============================
  875.     Function:
  876.         IsVehicleCreated
  877.  
  878.     Params:
  879.         vehicleid => ID of the vehicle
  880.  
  881.     Return:
  882.         true if the vehicle is created, otherwise fase
  883.  
  884.     Related Functions:
  885.         -
  886.  
  887.     Related Callbacks:
  888.         -
  889.  
  890.     Extra:
  891.         -
  892.     ==============================*/
  893.     stock IsVehicleCreated(vehicleid)
  894.         return V[vehicleid][vCreated];
  895.  
  896.     /*==============================
  897.     Function:
  898.         EnableTiresDamageForVehicle
  899.  
  900.     Params:
  901.         vehicleid => ID of the vehicle
  902.         enable => true/false (true will disable the vehicle tires of being damage, otherwise false)
  903.  
  904.     Return:
  905.         1 if success
  906.  
  907.     Related Functions:
  908.         EnableTiresDamage
  909.  
  910.     Related Callbacks:
  911.         -
  912.  
  913.     Extra:
  914.         -
  915.     ==============================*/
  916.     stock EnableTiresDamageForVehicle(vehicleid, bool:enable)
  917.     {
  918.         V[vehicleid][vTires] = enable;
  919.         return 1;
  920.     }
  921.  
  922.     /*==============================
  923.     Function:
  924.         EnableTiresDamage
  925.  
  926.     Params:
  927.         enable => true/false (true will disable the vehicle tires of being damage, otherwise false)
  928.  
  929.     Return:
  930.         1 if success
  931.  
  932.     Related Functions:
  933.         EnableTiresDamageForVehicle
  934.  
  935.     Related Callbacks:
  936.         -
  937.  
  938.     Extra:
  939.         -
  940.     ==============================*/
  941.     stock EnableTiresDamage(bool:enable)
  942.     {
  943.         for(static i=1; i<=2000; i++)V[i][vTires] = enable;
  944.         return 1;
  945.     }
  946.  
  947.     /*==============================
  948.     Function:
  949.         GetVehicleType
  950.  
  951.     Params:
  952.         model => vehicle model
  953.  
  954.     Return:
  955.         Vehicle TIPE (see line: )
  956.  
  957.     Related Functions:
  958.         -
  959.  
  960.     Related Callbacks:
  961.         -
  962.  
  963.     Extra:
  964.         -
  965.     ==============================*/
  966.     stock GetVehicleType(model)
  967.     {
  968.         switch(model){
  969.             case 460, 476, 511, 512, 519, 520, 553, 577, 592, 593:return VEHICLE_TYPE_AIRPLANE;
  970.             case 417, 425, 447, 469 ,487, 488, 497, 548, 563:return VEHICLE_TYPE_HELICOPTER;
  971.             case 448, 461 .. 463, 468, 471, 481, 509, 510, 521 .. 523, 581, 586:return VEHICLE_TYPE_BIKE;
  972.             case 439, 480, 533, 555:return VEHICLE_TYPE_CONVERTIBLE;
  973.             case 403, 408, 413, 414, 422, 440, 443, 455, 456, 459, 478, 482, 498, 499, 514, 515, 524, 531, 543, 552, 554, 578, 582, 600, 605, 609:return VEHICLE_TYPE_INDUSTRIAL;
  974.             case 412, 534 .. 536, 566, 567, 575, 576:return VEHICLE_TYPE_LOWRIDER;
  975.             case 400, 424, 444, 470, 489, 495, 500, 505, 556, 557, 568, 573, 579:return VEHICLE_TYPE_OFFROAD;
  976.             case 407, 416, 420, 427, 431, 432, 433, 437, 438, 490, 528, 544, 596 .. 599, 601:return VEHICLE_TYPE_PUBLICSERV;
  977.             case 401, 405, 410, 419, 421, 426, 436, 445, 466, 467, 474, 491, 492, 504, 507, 516, 517, 518, 526, 527, 529, 540, 542, 546, 547, 549, 550, 551, 560, 562, 580, 585, 604:return VEHICLE_TYPE_SALOON;
  978.             case 402, 411, 415, 429, 451, 475, 477, 494, 496, 541, 502, 503, 506, 558, 559, 565, 587, 589, 602, 603:return VEHICLE_TYPE_SPORT;
  979.             case 404, 418, 458, 479, 561:return VEHICLE_TYPE_STATION;
  980.             case 430, 446, 452, 453, 454, 472, 473, 484, 493, 595:return VEHICLE_TYPE_BOAT;
  981.             case 435, 450, 569, 570, 584, 590, 591, 606, 607, 608, 610, 611:return VEHICLE_TYPE_TRAILER;
  982.             case 406, 409, 423, 428, 434, 442, 449, 457, 483, 485, 486, 508, 525, 530, 532, 537 .. 539, 545, 571, 572, 574, 583, 588:return VEHICLE_TYPE_UNIQUE;
  983.             case 441, 464, 465, 501, 564, 594:return VEHICLE_TYPE_RC;
  984.         }return INVALID_VEHICLE_TYPE;
  985.     }
  986.    
  987.     /*==============================
  988.     Function:
  989.         GetVehicleRot
  990.  
  991.     Params:
  992.         vehicleid => ID of the vehicle
  993.         Float:x => variable to store the X rotation
  994.         Float:y => variable to store the Y rotation
  995.         Float:z => variable to store the Z rotation
  996.  
  997.     Return:
  998.         1 if success
  999.  
  1000.     Related Functions:
  1001.         -
  1002.  
  1003.     Related Callbacks:
  1004.         -
  1005.  
  1006.     Extra:
  1007.         -
  1008.     ==============================*/
  1009.     stock GetVehicleRot(vehicleid, &Float:x, &Float:y, &Float:z)
  1010.     {
  1011.         static Float:qW, Float:qX, Float:qY, Float:qZ;
  1012.         GetVehicleRotationQuat(vehicleid, qW, qX, qY, qZ);
  1013.         x = atan2(2*((quat_x*quat_y)+(quat_w+quat_z)),(quat_w*quat_w)+(quat_x*quat_x)-(quat_y*quat_y)-(quat_z*quat_z));
  1014.         y = atan2(2*((quat_y*quat_z)+(quat_w*quat_x)),(quat_w*quat_w)-(quat_x*quat_x)-(quat_y*quat_y)+(quat_z*quat_z));
  1015.         z = asin(-2*((quat_x*quat_z)+(quat_w*quat_y)));
  1016.         return 1;
  1017.     }
  1018. #endif
  1019.  
  1020. /*==============================
  1021. Function:
  1022.     GetOnlinePlayers
  1023.  
  1024. Params:
  1025.     CountNPC => true/false (true will count the npc bots, otherwise false)
  1026.  
  1027. Return:
  1028.     Number of connected players
  1029.  
  1030. Related Functions:
  1031.     -
  1032.  
  1033. Related Callbacks:
  1034.     -
  1035.  
  1036. Extra:
  1037.     -
  1038. ==============================*/
  1039. stock GetOnlinePlayers(bool:CountNPC)
  1040. {
  1041.     static c;
  1042.     if(CountNPC)foreach(Player, i)c++;
  1043.     else foreach(Player, i)if(!IsPlayerNPC(i))c++;
  1044.     return c;
  1045. }
  1046.  
  1047. /*==============================
  1048. Function:
  1049.     AddForbidenNick
  1050.  
  1051. Params:
  1052.     nick => nick to add in the nick's blacklist
  1053.  
  1054. Return:
  1055.     1 if success
  1056.  
  1057. Related Functions:
  1058.     -
  1059.  
  1060. Related Callbacks:
  1061.     -
  1062.  
  1063. Extra:
  1064.     -
  1065. ==============================*/
  1066. stock AddForbidenNick(nick[])
  1067. {
  1068.     for(new j; j<bNamesC; j++)if(!strcmp(nick, bNames[j], true))return 0;
  1069.     if(bNamesC == MAX_BNAMES-1)return 0;
  1070.     format(bNames[bNamesC], MAX_PLAYER_NAME, "%s", nick);
  1071.     bNamesC++;
  1072.     return 1;
  1073. }
  1074.  
  1075. /*==============================
  1076. Function:
  1077.     AddForbidenWord
  1078.  
  1079. Params:
  1080.     word => word to add in the word's blacklist
  1081.  
  1082. Return:
  1083.     1 if success
  1084.  
  1085. Related Functions:
  1086.     -
  1087.  
  1088. Related Callbacks:
  1089.     -
  1090.  
  1091. Extra:
  1092.     -
  1093. ==============================*/
  1094. stock AddForbidenWord(word[])
  1095. {
  1096.     for(new j; j<bWordsC; j++)if(!strcmp(word, bWords[j], true))return 0;
  1097.     if(bWordsC == MAX_BWORDS-1)return 0;
  1098.     format(bWords[bWordsC], 16, "%s", word);
  1099.     bWordsC++;
  1100.     return 1;
  1101. }
  1102.  
  1103. /*==============================
  1104. Function:
  1105.     GetMiddle2D
  1106.  
  1107. Params:
  1108.     Float:x1 => x coordinate of the 1º position
  1109.     Float:y1 => y coordenate of the 1º position
  1110.     Float:x2 => x coordinate of the 2º position
  1111.     Float:y2 => y coordinate of the 2º position
  1112.     Float:rX => variable to store the X coordinate of the middle position between the 2 postions given.
  1113.     Float:rY => variable to store the Y coordinate of the middle position between the 2 postions given.
  1114.  
  1115. Return:
  1116.     1 if success
  1117.  
  1118. Related Functions:
  1119.     -
  1120.  
  1121. Related Callbacks:
  1122.     -
  1123.  
  1124. Extra:
  1125.     -
  1126. ==============================*/
  1127. stock GetMiddle2D(Float:x1, Float:y1, Float:x2, Float:y2, Float:rX, Float:rY)
  1128. {
  1129.     rX = floatdiv(floatadd(x1, x2), 2);
  1130.     rY = floatdiv(floatadd(y1, y2), 2);
  1131.     return 1;
  1132. }
  1133.  
  1134. /*==============================
  1135. Function:
  1136.     GetMiddle3D
  1137.  
  1138. Params:
  1139.     Float:x1 => x coordinate of the 1º position
  1140.     Float:y1 => y coordenate of the 1º position
  1141.     Float:z1 => z coordinate of the 1º position
  1142.     Float:x2 => x coordinate of the 2º position
  1143.     Float:y2 => y coordinate of the 2º position
  1144.     Float:z2 => z coordinate of the 2º position
  1145.     Float:rX => variable to store the X coordinate of the middle position between the 2 postions given.
  1146.     Float:rY => variable to store the Y coordinate of the middle position between the 2 postions given.
  1147.     Float:rZ => variable to store the Z coordinate of the middle position between the 2 postions given.
  1148.  
  1149. Return:
  1150.     1 if success
  1151.  
  1152. Related Functions:
  1153.     -
  1154.  
  1155. Related Callbacks:
  1156.     -
  1157.  
  1158. Extra:
  1159.     -
  1160. ==============================*/
  1161. stock GetMiddle3D(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:rX, Float:rY, Float:rZ)
  1162. {
  1163.     rX = floatdiv(floatadd(x1, x2), 2);
  1164.     rY = floatdiv(floatadd(y1, y2), 2);
  1165.     rZ = floatdiv(floatadd(z1, y2), 2);
  1166.     return 1;
  1167. }
  1168.  
  1169. #if defined FILTERSCRIPT
  1170.     Hook:CBz_OnFilterScriptInit()
  1171.     {
  1172.         if(fexist("ForbidenNames.cfg")){
  1173.             static line[64];
  1174.             Fhnd = fopen("ForbidenNames.cfg", io_read);
  1175.             while(fread(Fhnd, line)){
  1176.                 for(new i; i<strlen(line); i++)if(line[i] == '\r' || line[i] == '\n')line[i] = '\0';
  1177.                 if(strlen(line)){
  1178.                     format(bNames[bNamesC], MAX_PLAYER_NAME, "%s", line);
  1179.                     bNamesC++;
  1180.                 }
  1181.             }
  1182.         }
  1183.         if(fexist("ForbidenWords.cfg")){
  1184.             static line[64];
  1185.             Fhnd = fopen("ForbidenWords.cfg", io_read);
  1186.             while(fread(Fhnd, line)){
  1187.                 for(new i; i<strlen(line); i++)if(line[i] == '\r' || line[i] == '\n')line[i] = '\0';
  1188.                 if(strlen(line)){
  1189.                     format(bWords[bWordsC], MAX_PLAYER_NAME, "%s", line);
  1190.                     bWordsC++;
  1191.                 }
  1192.             }
  1193.         }
  1194.         static str[128];
  1195.         foreach(Player, i){
  1196.             if(!IsPlayerNPC(i)){
  1197.                 if(!IsPlayerAdmin(i)){
  1198.                     GetPlayerName(i, str, MAX_PLAYER_NAME);
  1199.                     for(new j; j<bNamesC; j++){
  1200.                         if(!strcmp(str, bNames[j], true)){
  1201.                             #if defined ENGLISH
  1202.                                 format(str, 128, "%s(%i) has been automaticaly kicked. [Reason: Forbiden nick]", str, i);
  1203.                                 SendClientMessage(i, 0xFF0000FF, "Forbiden nick.");
  1204.                             #else
  1205.                                 format(str, 128, "%s(%i) fue kickeado automaticamente. [Reason: Nick prohibido]", str, i);
  1206.                                 SendClientMessage(i, 0xFF0000FF, "Nick prohibido.");
  1207.                             #endif
  1208.                             Kick(i);
  1209.                             return SendClientMessageToAll(0xA6A6A6FF, str);
  1210.                         }
  1211.                     }
  1212.                 }
  1213.                 ResetPlayer(i);
  1214.                 I[i][pTime][1] = GetTickCount();
  1215.                 GetPlayerHealth(i, I[i][pHealth]);
  1216.                 GetPlayerArmour(i, I[i][pArmour]);
  1217.                 I[i][pWeap] = GetPlayerWeapon(i);
  1218.                 I[i][pMoney] = GetPlayerMoney(i);
  1219.                 I[i][pTimer] = SetTimerEx("Check", INTERVAL, true, "i", i);
  1220.             }
  1221.         }
  1222.         return 1;
  1223.     }
  1224.  
  1225.     Hook:CBz_OnFilterScriptExit()
  1226.     {
  1227.         foreach(Player, i){
  1228.             if(!IsPlayerNPC(i)){
  1229.                 if(I[i][pTimer])KillTimer(I[i][pTimer]);
  1230.                 if(I[i][pReconnect]){
  1231.                     static cmdstr[25];
  1232.                     format(cmdstr, 23, "unbanip %s", I[i][pIP]);
  1233.                     SendRconCommand(cmdstr);
  1234.                     SendRconCommand("reloadbans");
  1235.                 }
  1236.             }
  1237.         }
  1238.         Fhnd = fopen("ForbidenNames.cfg", io_write);
  1239.         for(new j; j<bNamesC; j++){
  1240.             fwrite(Fhnd, bNames[j]);
  1241.             fwrite(Fhnd, "\r\n");
  1242.         }
  1243.         fclose(Fhnd);
  1244.         Fhnd = fopen("ForbidenWords.cfg", io_write);
  1245.         for(new j; j<bWordsC; j++){
  1246.             fwrite(Fhnd, bWords[j]);
  1247.             fwrite(Fhnd, "\r\n");
  1248.         }
  1249.         fclose(Fhnd);
  1250.         return 1;
  1251.     }
  1252. #else
  1253.     Hook:CBz_OnGameModeInit()
  1254.     {
  1255.         if(fexist("ForbidenNames.cfg")){
  1256.             static line[64];
  1257.             Fhnd = fopen("ForbidenNames.cfg", io_read);
  1258.             while(fread(Fhnd, line)){
  1259.                 for(new i; i<strlen(line); i++)if(line[i] == '\r' || line[i] == '\n')line[i] = '\0';
  1260.                 if(strlen(line)){
  1261.                     format(bNames[bNamesC], MAX_PLAYER_NAME, "%s", line);
  1262.                     bNamesC++;
  1263.                 }
  1264.             }
  1265.         }
  1266.         if(fexist("ForbidenWords.cfg")){
  1267.             static line[64];
  1268.             Fhnd = fopen("ForbidenWords.cfg", io_read);
  1269.             while(fread(Fhnd, line)){
  1270.                 for(new i; i<strlen(line); i++)if(line[i] == '\r' || line[i] == '\n')line[i] = '\0';
  1271.                 if(strlen(line)){
  1272.                     format(bWords[bWordsC], MAX_PLAYER_NAME, "%s", line);
  1273.                     bWordsC++;
  1274.                 }
  1275.             }
  1276.         }
  1277.         static str[128];
  1278.         foreach(Player, i){
  1279.             if(!IsPlayerNPC(i)){
  1280.                 if(!IsPlayerAdmin(i)){
  1281.                     GetPlayerName(i, str, MAX_PLAYER_NAME);
  1282.                     for(new j; j<bNamesC; j++){
  1283.                         if(!strcmp(str, bNames[j], true)){
  1284.                             #if defined ENGLISH
  1285.                                 format(str, 128, "%s(%i) has been automaticaly kicked. [Reason: Forbiden nick]", str, i);
  1286.                                 SendClientMessage(i, 0xFF0000FF, "Forbiden nick.");
  1287.                             #else
  1288.                                 format(str, 128, "%s(%i) fue kickeado automaticamente. [Reason: Nick prohibido]", str, i);
  1289.                                 SendClientMessage(i, 0xFF0000FF, "Nick prohibido.");
  1290.                             #endif
  1291.                             Kick(i);
  1292.                             return SendClientMessageToAll(0xA6A6A6FF, str);
  1293.                         }
  1294.                     }
  1295.                 }
  1296.                 ResetPlayer(i);
  1297.                 I[i][pTime][1] = GetTickCount();
  1298.                 GetPlayerHealth(i, I[i][pHealth]);
  1299.                 GetPlayerArmour(i, I[i][pArmour]);
  1300.                 I[i][pWeap] = GetPlayerWeapon(i);
  1301.                 I[i][pMoney] = GetPlayerMoney(i);
  1302.                 I[i][pTimer] = SetTimerEx("Check", INTERVAL, true, "i", i);
  1303.             }
  1304.         }
  1305.         return 1;
  1306.     }
  1307.  
  1308.     Hook:CBz_OnGameModeExit()
  1309.     {
  1310.         foreach(Player, i){
  1311.             if(!IsPlayerNPC(i)){
  1312.                 if(I[i][pTimer])KillTimer(I[i][pTimer]);
  1313.                 if(I[i][pReconnect]){
  1314.                     static cmdstr[25];
  1315.                     format(cmdstr, 23, "unbanip %s", I[i][pIP]);
  1316.                     SendRconCommand(cmdstr);
  1317.                     SendRconCommand("reloadbans");
  1318.                 }
  1319.             }
  1320.         }
  1321.         Fhnd = fopen("ForbidenNames.cfg", io_write);
  1322.         for(new j; j<bNamesC; j++){
  1323.             fwrite(Fhnd, bNames[j]);
  1324.             fwrite(Fhnd, "\r\n");
  1325.         }
  1326.         fclose(Fhnd);
  1327.         Fhnd = fopen("ForbidenWords.cfg", io_write);
  1328.         for(new j; j<bWordsC; j++){
  1329.             fwrite(Fhnd, bWords[j]);
  1330.             fwrite(Fhnd, "\r\n");
  1331.         }
  1332.         fclose(Fhnd);
  1333.         return 1;
  1334.     }
  1335. #endif
  1336.  
  1337. Hook:CBz_OnPlayerConnect(playerid)
  1338. {
  1339.     if(IsPlayerNPC(playerid))return 1;
  1340.     ResetPlayer(playerid);
  1341.     I[playerid][pTimer] = SetTimerEx("Check", INTERVAL, true, "i", playerid);
  1342.     I[playerid][pTime][1] = GetTickCount();
  1343.     static str[128], name[MAX_PLAYER_NAME];
  1344.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  1345.     for(new i; i<bNamesC; i++){
  1346.         if(!strcmp(name, bNames[i], true)){
  1347.             #if defined ENGLISH
  1348.                 format(str, sizeof(str), "%s(%i) has been automaticaly kicked. [Reason: Forbiden nick]", name, playerid);
  1349.                 SendClientMessage(playerid, 0xFF0000FF, "Forbiden nick.");
  1350.             #else
  1351.                 format(str, sizeof(str), "%s(%i) fue kickeado automaticamente. [Reason: Nick prohibido]", name, playerid);
  1352.                 SendClientMessage(playerid, 0xFF0000FF, "Nick prohibido.");
  1353.             #endif
  1354.             Kick(playerid);
  1355.             return SendClientMessageToAll(0xA6A6A6FF, str);
  1356.         }
  1357.     }
  1358.     return 1;
  1359. }
  1360.  
  1361. Hook:CBz_OnPlayerDisconnect(playerid, reason)
  1362. {
  1363.     if(I[playerid][pTimer])KillTimer(I[playerid][pTimer]);
  1364.     if(I[playerid][pReconnect]){
  1365.         static cmdstr[25];
  1366.         I[playerid][pReconnect] = false;
  1367.         format(cmdstr, 23, "unbanip %s", I[playerid][pIP]);
  1368.         SendRconCommand(cmdstr);
  1369.         SendRconCommand("reloadbans");
  1370.     }
  1371.     return 1;
  1372. }
  1373.  
  1374. Hook:CBz_OnPlayerSpawn(playerid)
  1375. {
  1376.     I[playerid][pTime][0] = GetTickCount();
  1377.     I[playerid][pWeap] = GetPlayerWeapon(playerid);
  1378.     I[playerid][pVWorld] = GetPlayerVirtualWorld(playerid);
  1379.     _SetPlayerHealth(playerid, 100);
  1380.     SetTimerEx("GetWeaps", 500, false, "i", playerid);
  1381.     return 1;
  1382. }
  1383.  
  1384. Hook:CBz_OnPlayerDeath(playerid, killerid, reason)
  1385. {
  1386.     I[playerid][pTime][0] = GetTickCount();
  1387.     I[playerid][pHealth] = 0;
  1388.     return 1;
  1389. }
  1390.  
  1391. Hook:CBz_OnPlayerText(playerid, text[])
  1392. {
  1393.     I[playerid][pTime][1] = GetTickCount();
  1394.     I[playerid][pTime][0] = GetTickCount();
  1395.     if(!I[playerid][pCaps])LOWER(text);
  1396.     new pos;
  1397.     for(new i; i<bWordsC; i++){
  1398.         pos = strfind(text, bWords[i]);
  1399.         if(pos != -1)for(new j=pos; j<(pos+strlen(bWords[i])); j++)text[j] = '*';
  1400.     }
  1401.     return 1;
  1402. }
  1403.  
  1404. Hook:CBz_OnPlayerCommandText(playerid, cmdtext[])
  1405. {
  1406.     I[playerid][pTime][1] = GetTickCount();
  1407.     I[playerid][pTime][0] = GetTickCount();
  1408.     return 1;
  1409. }
  1410.  
  1411. Hook:OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  1412. {
  1413.     if(!I[playerid][pIntDamage]){
  1414.         if(!newinteriorid)for(new i; i<13; i++)GivePlayerWeapon(playerid, I[playerid][pWeaps][i], I[playerid][pAmmo][i]);
  1415.         else{
  1416.             for(new i; i<13; i++)GetPlayerWeaponData(playerid, i, I[playerid][pWeaps][i], I[playerid][pAmmo][i]);
  1417.             ResetPlayerWeapons(playerid);
  1418.         }
  1419.     }
  1420.     return 1;
  1421. }
  1422.  
  1423. Hook:CBz_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  1424. {
  1425.     I[playerid][pTime][1] = GetTickCount();
  1426.     if(I[playerid][pDriveBy] && IsPlayerInAnyVehicle(playerid) && I[playerid][pWeap]){
  1427.         if(PRESSED(KEY_FIRE) || PRESSED(KEY_SECONDARY_ATTACK) || HOLDING(KEY_FIRE) || HOLDING(KEY_SECONDARY_ATTAK)){
  1428.             switch(GetPlayerCameraMode(playerid)){
  1429.                 case 16, 18, 56:{
  1430.                     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
  1431.                         if(!I[playerid][pDBing]){
  1432.                             I[playerid][pDBing] = true;
  1433.                             CallLocalFunction("OnPlayerStartDriveBy", "ii", playerid, 0);
  1434.                         }
  1435.                     }
  1436.                 }
  1437.                 case 55:{
  1438.                     if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER){
  1439.                         if(!I[playerid][pDBing]){
  1440.                             I[playerid][pDBing] = true;
  1441.                             CallLocalFunction("OnPlayerStartDriveBy", "ii", playerid, 1);
  1442.                         }
  1443.                     }
  1444.                 }
  1445.                 default:{
  1446.                     if(I[playerid][pDBing]){
  1447.                         I[playerid][pDBing] = false;
  1448.                         CallLocalFunction("OnPlayerEndDriveBy", "i", playerid);
  1449.                     }
  1450.                 }
  1451.             }
  1452.         }
  1453.         else{
  1454.             if(I[playerid][pDBing]){
  1455.                 I[playerid][pDBing] = false;
  1456.                 CallLocalFunction("OnPlayerEndDriveBy", "i", playerid);
  1457.             }
  1458.         }
  1459.     }
  1460.     return 1;
  1461. }
  1462.  
  1463. Hook:CBz_OnPlayerStateChange(playerid, newstate, oldstate)
  1464. {
  1465.     static Float:rP[10], Float:HA[2];
  1466.     I[playerid][pTime][1] = GetTickCount();
  1467.     I[playerid][pTime][0] = GetTickCount();
  1468.     if(newstate == PLAYER_STATE_DRIVER){
  1469.         if(!I[playerid][pDriveBy]){
  1470.             for(new i; i<13; i++)GetPlayerWeaponData(playerid, i, I[playerid][pWeaps][i], I[playerid][pAmmo][i]);
  1471.             ResetPlayerWeapons(playerid);
  1472.         }
  1473.     }
  1474.     else if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER && !I[playerid][pDriveBy])for(new i; i<13; i++)GivePlayerWeapon(playerid, I[playerid][pWeaps][i], I[playerid][pAmmo][i]);
  1475.     return 1;
  1476. }
  1477.  
  1478. Hook:CBz_OnPlayerUpdate(playerid)
  1479. {
  1480.     static Float:rP[10], tmp[2];
  1481.     GetPlayerPos(playerid, rP[0], rP[1], rP[2]);
  1482.     GetPlayerFacingAngle(playerid, rP[3]);
  1483.     tmp[0] = GetPlayerDrunkLevel(playerid);
  1484.     if(floatcmp(rP[0], I[playerid][pP][0]) && floatcmp(rP[1], I[playerid][pP][1]) && floatcmp(rP[2], I[playerid][pP][2]) && floatcmp(rP[3], I[playerid][pP][3])){
  1485.         GetPlayerPos(playerid, I[playerid][pP][0], I[playerid][pP][1], I[playerid][pP][2]);
  1486.         GetPlayerFacingAngle(playerid, I[playerid][pP][3]);
  1487.         I[playerid][pTime][1] = GetTickCount();
  1488.         I[playerid][pAFK] = false;
  1489.     }
  1490.     if(tmp[0] < 200)SetPlayerDrunkLevel(playerid, 2000);
  1491.     else if(I[playerid][pDrk] != tmp[0]){
  1492.         tmp[1] = I[playerid][pDrk] - tmp[0];
  1493.         if(0 < tmp[1] < 200)I[playerid][pFPS] = tmp[1];
  1494.         I[playerid][pDrk] = tmp[0];
  1495.     }
  1496.     I[playerid][pTime][0] = GetTickCount();
  1497.     if(I[playerid][pPaused])I[playerid][pPaused] = false;
  1498.     return 1;
  1499. }
  1500.  
  1501. #if defined USE_VEHICLE_DATA
  1502.     Hook:CBz_OnVehicleRespray(playerid, vehicleid, color1, color2)
  1503.     {
  1504.         V[vehicleid][vColor][0] = color1;
  1505.         V[vehicleid][vColor][1] = color2;
  1506.         return 1;
  1507.     }
  1508.  
  1509.     Hook:Cbz_OnVehicleDamageStatusUpdate(vehicleid, playerid)
  1510.     {
  1511.         if(V[vehicleid][vTires]){
  1512.             static tmp[4];
  1513.             GetVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]);
  1514.             tmp[3] = encode_tires(0, 0, 0, 0);
  1515.             UpdateVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]);
  1516.         }
  1517.         return 1;
  1518.     }
  1519. #endif
  1520.  
  1521. PUBLIC:Check(playerid)
  1522. {
  1523.     if(!I[playerid][pAFK]){
  1524.         if(!I[playerid][pPaused] && (GetTickCount()-I[playerid][pTime][0])>=(PAUSE_TIME*519)){
  1525.             I[playerid][pPaused] = true;
  1526.             CallLocalFunction("OnPlayerPause", "i", playerid);
  1527.         }
  1528.         if((GetTickCount()-I[playerid][pTime][1])>=(AFK_TIME*1000)){
  1529.             I[playerid][pAFK] = true;
  1530.             CallLocalFunction("OnPlayerAFK", "i", playerid);
  1531.         }
  1532.         if(!I[playerid][pPaused]){
  1533.             static tmp, Lib[2][32], Float:HA[2];
  1534.             tmp = GetPlayerWeapon(playerid);
  1535.             if(tmp != I[playerid][pWeap]){
  1536.                 CallLocalFunction("OnPlayerWeaponChange", "iii", playerid, tmp, I[playerid][pWeap]);
  1537.                 I[playerid][pWeap] = tmp;
  1538.             }
  1539.             tmp = GetPlayerVirtualWorld(playerid);
  1540.             if(tmp != I[playerid][pVWorld]){
  1541.                 CallLocalFunction("OnPlayerVirtualWorldChange", "iii", playerid, tmp, I[playerid][pVWorld]);
  1542.                 I[playerid][pVWorld] = tmp;
  1543.             }
  1544.             tmp = GetPlayerAnimationIndex(playerid);
  1545.             if(tmp){
  1546.                 GetAnimationName(tmp, Lib[0], 32, Lib[1], 32);
  1547.                 if(!I[playerid][pPlayingAnim])CallLocalFunction("OnPlayerPlayAnimation", "iss", playerid, Lib[0], Lib[1]);
  1548.                 if(!strcmp(Lib[0], "SWIM")){
  1549.                     if(!I[playerid][pInWater]){
  1550.                         I[playerid][pInWater] = true;
  1551.                         CallLocalFunction("OnPlayerEnterWater", "i", playerid);
  1552.                     }
  1553.                 }else if(I[playerid][pInWater]){
  1554.                     I[playerid][pInWater] = false;
  1555.                     CallLocalFunction("OnPlayerExitWater", "i", playerid);
  1556.                 }
  1557.                 I[playerid][pParachuting] = (!strcmp(Lib[0], "PARACHUTE") || (!strcmp(Lib[0], "ped") && !strcmp(Lib[1], "FALL_skyDive"))) ? (true) : (false);
  1558.                 if(!strcmp(Lib[0], "VENDING")){
  1559.                     if(!I[playerid][pMachine]){
  1560.                         if(I[playerid][pUseMachine]){
  1561.                             I[playerid][pMachine] = true;
  1562.                             CallLocalFunction("OnPlayerUseVendingMachine", "i", playerid);
  1563.                         }
  1564.                         else{
  1565.                             ClearAnimations(playerid, 1);
  1566.                             SetTimerEx("NoVend", 40, false, "d", playerid);
  1567.                             I[playerid][pVend] = true;
  1568.                         }
  1569.                     }
  1570.                 }else I[playerid][pMachine] = false;
  1571.                 I[playerid][pPlayingAnim] = true;
  1572.             }else I[playerid][pPlayingAnim] = false;
  1573.             if(!I[playerid][pVend]){
  1574.                 GetPlayerHealth(playerid, HA[0]);
  1575.                 if(floatcmp(HA[0], I[playerid][pHealth])){
  1576.                     CallLocalFunction("OnPlayerHealthChange", "iff", playerid, HA[0], I[playerid][pHealth]);
  1577.                     I[playerid][pHealth] = HA[0];
  1578.                 }
  1579.                 GetPlayerArmour(playerid, HA[1]);
  1580.                 if(floatcmp(HA[1], I[playerid][pArmour])){
  1581.                     CallLocalFunction("OnPlayerArmourChange", "iff", playerid, HA[0], I[playerid][pArmour]);
  1582.                     I[playerid][pArmour] = HA[1];
  1583.                 }
  1584.                 tmp = GetPlayerMoney(playerid);
  1585.                 if(tmp != I[playerid][pMoney]){
  1586.                     CallLocalFunction("OnPlayerMoneyChange", "iii", playerid, tmp, I[playerid][pMoney]);
  1587.                     I[playerid][pMoney] = tmp;
  1588.                 }
  1589.                 tmp = GetPlayerScore(playerid);
  1590.                 if(tmp != I[playerid][pScore]){
  1591.                     CallLocalFunction("OnPlayerScoreChange", "iii", playerid, tmp, I[playerid][pScore]);
  1592.                     I[playerid][pScore] = tmp;
  1593.                 }
  1594.             }
  1595.         }
  1596.     }
  1597. }
  1598.  
  1599. PUBLIC:GetWeaps(playerid)for(new i; i<13; i++)GetPlayerWeaponData(playerid, i, I[playerid][pWeaps][i], I[playerid][pAmmo][i]);
  1600.  
  1601. PUBLIC:ForceReconnect(playerid)
  1602. {
  1603.     static cmdstr[23];
  1604.     GetPlayerIp(playerid, I[playerid][pIP], 16);
  1605.     format(cmdstr, 23, "banip %s", I[playerid][pIP]);
  1606.     I[playerid][pReconnect] = true;
  1607.     SendRconCommand(cmdstr);
  1608. }
  1609.  
  1610. PUBLIC:NoVend(playerid)
  1611. {
  1612.     _SetPlayerHealth(playerid, I[playerid][pHealth]);
  1613.     GivePlayerMoney(playerid, 1);
  1614.     I[playerid][pVend] = false;
  1615. }
  1616.  
  1617. stock ResetPlayer(playerid)
  1618. {
  1619.     new i;
  1620.     I[playerid][pAFK] = false;
  1621.     I[playerid][pPaused] = false;
  1622.     I[playerid][pInWater] = false;
  1623.     I[playerid][pParachuting] = false;
  1624.     I[playerid][pMachine] = false;
  1625.     I[playerid][pDriveBy] = S[sDriveby];
  1626.     I[playerid][pIntDamage] = S[sIntDamage];
  1627.     I[playerid][pReconnect] = false;
  1628.     I[playerid][pUseMachine] = S[sVending];
  1629.     I[playerid][pPlayingAnim] = false;
  1630.     I[playerid][pCaps] = S[sCaps];
  1631.     I[playerid][pVend] = false;
  1632.     I[playerid][pUpdatedHealth] = false;
  1633.     I[playerid][pDBing] = false;
  1634.     I[playerid][pTReleased] = 0;
  1635.     for(; i<4; i++)I[playerid][pP][i] = 0.0;
  1636.     I[playerid][pTimer] = -1;
  1637.     I[playerid][pTime][0] = GetTickCount();
  1638.     I[playerid][pTime][1] = 0;
  1639.     I[playerid][pWeap] = 0;
  1640.     I[playerid][pVWorld] = 0;
  1641.     I[playerid][pHealth] = 0.0;
  1642.     I[playerid][pArmour] = 0.0;
  1643.     I[playerid][pMoney] = 0;
  1644.     I[playerid][pScore] = 0;
  1645.     for(i=0; i<13; i++){
  1646.         I[playerid][pWeaps][i] = 0;
  1647.         I[playerid][pAmmo][i] = 0;
  1648.     }
  1649.     I[playerid][pFPS] = 0;
  1650.     I[playerid][pDrk] = 0;
  1651. }
  1652.  
  1653. #if defined USE_VEHICLE_DATA
  1654.     stock _AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2, plate[]="XYZR 000")
  1655.     {
  1656.         static vID;
  1657.         if(color1 == -1)color1 = random(127);
  1658.         if(color2 == -1)color2 = random(127);
  1659.         vID = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2);
  1660.         if(strcmp(plate, "XYZR 000")){
  1661.             SetVehicleNumberPlate(vID, plate);
  1662.             SetVehicleToRespawn(vID);
  1663.             SetVehiclePos(vID, x, y, z);
  1664.         }
  1665.         V[vID][vCreated] = true;
  1666.         V[vID][vColor][0] = color1;
  1667.         V[vID][vColor][1] = color2;
  1668.         format(V[vID][vPlate], 32, "%s", plate);
  1669.         CallLocalFunction("OnVehicleCreate", "i", vID);
  1670.         return vID;
  1671.     }
  1672.  
  1673.     stock _AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2, respawn_delay, plate[]="XYZR 000")
  1674.     {
  1675.         static vID;
  1676.         if(color1 == -1)color1 = random(127);
  1677.         if(color2 == -1)color2 = random(127);
  1678.         vID = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, z_angle, color1, color2, respawn_delay);
  1679.         if(strcmp(plate, "XYZR 000")){
  1680.             SetVehicleNumberPlate(vID, plate);
  1681.             SetVehicleToRespawn(vID);
  1682.             SetVehiclePos(vID, x, y, z);
  1683.         }
  1684.         V[vID][vCreated] = true;
  1685.         V[vID][vColor][0] = color1;
  1686.         V[vID][vColor][1] = color2;
  1687.         format(V[vID][vPlate], 32, "%s", plate);
  1688.         CallLocalFunction("OnVehicleCreate", "i", vID);
  1689.         return vID;
  1690.     }
  1691.  
  1692.     stock _CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, plate[]="XYZR 000")
  1693.     {
  1694.         if(color1 == -1)color1 = random(127);
  1695.         if(color2 == -1)color2 = random(127);
  1696.         static vID = CreateVehicle(vehicletype, x, y, z, rotation, color1, color2, respawn_delay);
  1697.         if(strcmp(plate, "XYZR 000")){
  1698.             SetVehicleNumberPlate(vID, plate);
  1699.             SetVehicleToRespawn(vID);
  1700.             SetVehiclePos(vID, x, y, z);
  1701.         }
  1702.         V[vID][vCreated] = true;
  1703.         V[vID][vColor][0] = color1;
  1704.         V[vID][vColor][1] = color2;
  1705.         format(V[vID][vPlate], 32, "%s", plate);
  1706.         CallLocalFunction("OnVehicleCreate", "i", vID);
  1707.         return vID;
  1708.     }
  1709.  
  1710.     stock _DestroyVehicle(vehicleid)
  1711.     {
  1712.         V[vehicleid][vCreated] = false;
  1713.         CallLocalFunction("OnVehicleDestroy", "i", vehicleid);
  1714.         return DestroyVehicle(vehicleid);
  1715.     }
  1716.  
  1717.     stock _ChangeVehicleColor(vehicleid, color1, color2)
  1718.     {
  1719.         V[vehicleid][vColor][0] = color1;
  1720.         V[vehicleid][vColor][1] = color2;
  1721.         return ChangeVehicleColor(vehicleid, color1, color2);
  1722.     }
  1723.  
  1724.     stock _SetVehicleNumberPlate(vehicleid, numberplate[])
  1725.     {
  1726.         format(V[vehicleid][vPlate], 32, "%s", numberplate);
  1727.         return SetVehicleNumberPlate(vehicleid, numberplate[])
  1728.     }
  1729.  
  1730.         stock _LinkVehicleToInterior(vehicleid, interiorid)
  1731.     {
  1732.         V[vehicleid][vInterior] = interiorid;
  1733.         return LinkVehicleToInterior(vehicleid, interiorid);
  1734.     }
  1735.  
  1736.     stock encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
  1737. #endif
  1738.  
  1739. stock _SetPlayerHealth(playerid, Float:health)
  1740. {
  1741.     I[playerid][pHealth] = health;
  1742.     I[playerid][pUpdatedHealth] = true;
  1743.     return SetPlayerHealth(playerid, health);
  1744. }
  1745.  
  1746. stock _GetPlayerHealth(playerid, &Float:health){
  1747.     health = I[playerid][pHealth];
  1748.     return 1;
  1749. }
  1750.  
  1751. stock _SetPlayerArmour(playerid, Float:armour)
  1752. {
  1753.     I[playerid][pArmour] = armour;
  1754.     I[playerid][pUpdatedHealth] = true;
  1755.     return SetPlayerArmour(playerid, armour);
  1756. }
  1757.  
  1758. stock _GetPlayerArmour(playerid, &Float:armour){
  1759.     armour = I[playerid][pArmour];
  1760.     return 1;
  1761. }
  1762.  
  1763. stock _SetPlayerMoney(playerid, amount)
  1764. {
  1765.     I[playerid][pMoney] = amount;
  1766.     return GivePlayerMoney(playerid, -GetPlayerMoney(playerid)+amount);
  1767. }
  1768.  
  1769. stock _GivePlayerMoney(playerid, amount)
  1770. {
  1771.     I[playerid][pMoney] += amount;
  1772.     return GivePlayerMoney(playerid, amount);
  1773. }
  1774.  
  1775. stock _GetPlayerMoney(playerid)
  1776.     return I[playerid][pMoney];
  1777.  
  1778. stock _SetPlayerScore(playerid, score)
  1779. {
  1780.     I[playerid][pScore] = score;
  1781.     return SetPlayerScore(playerid, score);
  1782. }
  1783.  
  1784. stock _SetPlayerName(playerid, name[])
  1785. {
  1786.     if(fexist("ForbidenNames.cfg")){
  1787.         static line[64];
  1788.         Fhnd = fopen("ForbidenNames.cfg", io_read);
  1789.         while(fread(Fhnd, line))if(!strcmp(line, name))return 0;
  1790.         fclose(Fhnd);
  1791.     }
  1792.     return SetPlayerName(playerid, nick);
  1793. }
  1794.  
  1795. stock pName(playerid)
  1796. {
  1797.     static n[MAX_PLAYER_NAME];
  1798.     GetPlayerName(playerid, n, MAX_PLAYER_NAME);
  1799.     return n;
  1800. }
  1801.  
  1802. #define SetPlayerHealth         _SetPlayerHealth
  1803. #define SetPlayerArmour         _SetPlayerArmour
  1804. #define SetPlayerMoney          _SetPlayerMoney
  1805. #define GivePlayerMoney         _GivePlayerMoney
  1806. #define SetPlayerScore          _SetPlayerScore
  1807. #define SetPlayerName           _SetPlayerName
  1808. #if defined USE_VEHICLE_DATA
  1809.     #define AddStaticVehicle        _AddStaticVehicle
  1810.     #define AddStaticVehicleEx      _AddStaticVehicleEx
  1811.     #define CreateVehicle           _CreateVehicle
  1812.     #define SetVehicleNumberPlate   _SetVehicleNumberPlate
  1813.     #define DestroyVehicle          _DestroyVehicle
  1814.     #define ChangeVehicleColor      _ChangeVehicleColor
  1815.     #define LinkVehicleToInterior   _LinkVehicleToInterior
  1816. #endif
Advertisement
Add Comment
Please, Sign In to add comment