Guest User

Untitled

a guest
Oct 16th, 2011
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 17.12 KB | None | 0 0
  1. /*
  2.     [Include] Func - Simple functions
  3.                             by SmiT
  4. */
  5.  
  6. #if defined _FUNC_included
  7.         #endinput
  8. #endif
  9. #define _FUNC_included
  10.  
  11. #include <a_samp>
  12. #include <foreach>
  13.  
  14. #if !defined MAX_VEHICLES
  15.     #define MAX_VEHICLES    (2000)
  16. #endif
  17.  
  18. /*
  19. native GivePlayerHealth(playerid, Float:health);
  20. native GivePlayerArmour(playerid, Float:armour);
  21. native GivePlayerWantedLevel(playerid, level);
  22. native GivePlayerDrunkLevel(playerid, level);
  23. native GivePlayerAmmo(playerid, weaponslot, ammo);
  24. native GivePlayerScore(playerid, score);
  25. native GiveVehicleHealth(vehicleid, Float:health);
  26. native SetPlayerMoney(playerid, money);
  27. native GiveAllHealth(Float:health);
  28. native GiveAllArmour(Float:armour);
  29. native GiveAllWantedLevel(level);
  30. native GiveAllDrunkLevel(level);
  31. native GiveAllAmmo(weaponslot, ammo);
  32. native GiveAllScore(score);
  33. native GiveAllWeapon(weaponid, ammo);
  34. native GiveAllMoney(money);
  35. native SetAllHealth(Float:health);
  36. native SetAllArmour(Float:armour);
  37. native SetAllWantedLevel(level);
  38. native SetAllDrunkLevel(level);
  39. native SetAllAmmo(weaponslot, ammo);
  40. native SetAllScore(score);
  41. native SetAllMoney(money);
  42. native SetAllInterior(interiorid);
  43. native SetAllVirtualWorld(virtualworld);
  44. native SetAllTime(hour, minute);
  45. native SetAllCheckpoint(Float:x, Float:y, Float:z, Float:size);
  46. native SetAllFightingStyle(style);
  47. native SetAllSkillLevel(skill, level);
  48. native SetAllSkin(skinid);
  49. native SetAllColor(color);
  50. native SetAllPos(Float:x, Float:y, Float:z);
  51. native SpawnAllVehicles();
  52. native ResetAllMoney();
  53. native SpawnAllPlayers();
  54. native SetMapName(string[]);
  55. native Freeze(playerid);
  56. native Unfreeze(playerid);
  57. */
  58.  
  59. /*----------------------------------------------------------------------------*-
  60. Function:
  61.     SetMapName
  62. Parameters:
  63.     string - The mapname.
  64. Action:
  65.     - Changes the server mapname.
  66. -*----------------------------------------------------------------------------*/
  67. stock SetMapName(string[])
  68. {
  69.     new
  70.         str[ 32 ];
  71.     format( str, 32, "mapname %s", string );
  72.     SendRconCommand( str );
  73. }
  74. /*----------------------------------------------------------------------------*-
  75. Function:
  76.     SpawnAllPlayers
  77. Parameters:
  78.     -
  79. Action:
  80.     - Spawns all players.
  81. -*----------------------------------------------------------------------------*/
  82. stock SpawnAllPlayers()
  83. {
  84.     foreach(Player, i) SpawnPlayer( i );
  85.     return true;
  86. }
  87. /*----------------------------------------------------------------------------*-
  88. Function:
  89.     SpawnAllVehicles
  90. Parameters:
  91.     -
  92. Action:
  93.     - Spawns all vehicles.
  94. -*----------------------------------------------------------------------------*/
  95. stock SpawnAllVehicles()
  96. {
  97.     for ( new v = 0; v < MAX_VEHICLES; v ++) SetVehicleToRespawn( v );
  98.     return true;
  99. }
  100. /*----------------------------------------------------------------------------*-
  101. Function:
  102.     GiveVehicleHealth
  103. Parameters:
  104.     vehicleid - The vehicleid to give health.
  105.     Float: health - The health to give.
  106. Action:
  107.     - Increase a vehicle health.
  108. -*----------------------------------------------------------------------------*/
  109. stock GiveVehicleHealth(vehicleid, Float:health)
  110. {
  111.     new
  112.         Float: hp
  113.     ;
  114.     SetVehicleHealth(vehicleid, GetVehicleHealth( vehicleid, hp ) + Float:health );
  115.     return true;
  116. }
  117. /*----------------------------------------------------------------------------*-
  118. Function:
  119.     SetAllPos
  120. Parameters:
  121.     Float:x - coordinates x.
  122.     Float:y - coordinates y.
  123.     Float:z - coordinates z.
  124. Action:
  125.     - Sets all players position.
  126. -*----------------------------------------------------------------------------*/
  127. stock SetAllPos(Float:x, Float:y, Float:z)
  128. {
  129.     foreach(Player, i) SetPlayerPos( i, Float:x, Float:y, Float:z );
  130.     return true;
  131. }
  132. /*----------------------------------------------------------------------------*-
  133. Function:
  134.     SetAllColor
  135. Parameters:
  136.     color - color to set.
  137. Action:
  138.     - Sets all players color.
  139. -*----------------------------------------------------------------------------*/
  140. stock SetAllColor(color)
  141. {
  142.     foreach(Player, i) SetPlayerColor( i, color );
  143.     return true;
  144. }
  145. /*----------------------------------------------------------------------------*-
  146. Function:
  147.     SetAllSkin
  148. Parameters:
  149.     skinid - skin id to set.
  150. Action:
  151.     - Sets all players skin.
  152. -*----------------------------------------------------------------------------*/
  153. stock SetAllSkin(skinid)
  154. {
  155.     foreach(Player, i) SetPlayerSkin( i, skinid );
  156.     return true;
  157. }
  158. /*----------------------------------------------------------------------------*-
  159. Function:
  160.     SetAllSkillLevel
  161. Parameters:
  162.     skill - skill to set.
  163.     level - level to set.
  164. Action:
  165.     - Sets all players skill level.
  166. -*----------------------------------------------------------------------------*/
  167. stock SetAllSkillLevel(skill, level)
  168. {
  169.     foreach(Player, i) SetPlayerSkillLevel( i, skill, level );
  170.     return true;
  171. }
  172. /*----------------------------------------------------------------------------*-
  173. Function:
  174.     SetAllFightingStyle
  175. Parameters:
  176.     style - fighting style to set.
  177. Action:
  178.     - Sets all players fighting style.
  179. -*----------------------------------------------------------------------------*/
  180. stock SetAllFightingStyle(style)
  181. {
  182.     foreach(Player, i) SetPlayerFightingStyle( i, style );
  183.     return true;
  184. }
  185. /*----------------------------------------------------------------------------*-
  186. Function:
  187.     SetAllCheckpoint
  188. Parameters:
  189.     Float:x - coordinates x.
  190.     Float:y - coordinates y.
  191.     Float:z - coodinates z.
  192.     Float:size - size of the checkpoint
  193. Action:
  194.     - Sets a checkpoint to all players.
  195. -*----------------------------------------------------------------------------*/
  196. stock SetAllCheckpoint(Float:x, Float:y, Float:z, Float:size)
  197. {
  198.     foreach(Player, i) SetPlayerCheckpoint( i, Float:x, Float:y, Float:z, Float:size );
  199.     return true;
  200. }
  201. /*----------------------------------------------------------------------------*-
  202. Function:
  203.     SetAllTime
  204. Parameters:
  205.     hour - hour to set.
  206.     minute - minute to set.
  207. Action:
  208.     - Sets all players time.
  209. -*----------------------------------------------------------------------------*/
  210. stock SetAllTime(hour, minute)
  211. {
  212.     foreach(Player, i) SetPlayerTime( i, hour, minute );
  213.     return true;
  214. }
  215. /*----------------------------------------------------------------------------*-
  216. Function:
  217.     SetAllInterior
  218. Parameters:
  219.     interiorid - interior id to set.
  220. Action:
  221.     - Sets all players interior id.
  222. -*----------------------------------------------------------------------------*/
  223. stock SetAllInterior(interiorid)
  224. {
  225.     foreach(Player, i) SetPlayerInterior( i, interiorid );
  226.     return true;
  227. }
  228. /*----------------------------------------------------------------------------*-
  229. Function:
  230.     SetAllVirtualWorld
  231. Parameters:
  232.     virtualworld - virtualworld to set.
  233. Action:
  234.     - Sets all players virtualworld.
  235. -*----------------------------------------------------------------------------*/
  236. stock SetAllVirtualWorld(virtualworld)
  237. {
  238.     foreach(Player, i) SetPlayerVirtualWorld( i, virtualworld );
  239.     return true;
  240. }
  241. /*----------------------------------------------------------------------------*-
  242. Function:
  243.     ResetAllMoney
  244. Parameters:
  245.     -
  246. Action:
  247.     - Resets all players money.
  248. -*----------------------------------------------------------------------------*/
  249. stock ResetAllMoney()
  250. {
  251.     foreach(Player, i) ResetPlayerMoney( i );
  252.     return true;
  253. }
  254. /*----------------------------------------------------------------------------*-
  255. Function:
  256.     SetPlayerMoney
  257. Parameters:
  258.     playerid - the player who receive the money.
  259.     money - money to set.
  260. Action:
  261.     - Sets a player money.
  262. -*----------------------------------------------------------------------------*/
  263. stock SetPlayerMoney(playerid, money)
  264. {
  265.     ResetPlayerMoney( playerid );
  266.     GivePlayerMoney( playerid, money );
  267.     return true;
  268. }
  269. /*----------------------------------------------------------------------------*-
  270. Function:
  271.     SetAllMoney
  272. Parameters:
  273.     money - money to set.
  274. Action:
  275.     - Sets all players money.
  276. -*----------------------------------------------------------------------------*/
  277. stock SetAllMoney(money)
  278. {
  279.     foreach(Player, i)
  280.     {
  281.         ResetPlayerMoney( i );
  282.         GivePlayerMoney( i, money );
  283.     }
  284.     return true;
  285. }
  286. /*----------------------------------------------------------------------------*-
  287. Function:
  288.     GiveAllMoney
  289. Parameters:
  290.     money - money to give.
  291. Action:
  292.     - Gives all players money.
  293. -*----------------------------------------------------------------------------*/
  294. stock GiveAllMoney(money)
  295. {
  296.     foreach(Player, i)  GivePlayerMoney( i, money );
  297.     return true;
  298. }
  299. /*----------------------------------------------------------------------------*-
  300. Function:
  301.     GiveAllWeapon
  302. Parameters:
  303.     weaponid - weaponid to give.
  304.     ammo - ammo to give.
  305. Action:
  306.     - Gives all players a weapon.
  307. -*----------------------------------------------------------------------------*/       
  308. stock GiveAllWeapon(weaponid, ammo)
  309. {
  310.     foreach(Player, i) GivePlayerWeapon( i, weaponid, ammo );
  311.     return true;
  312. }
  313. /*----------------------------------------------------------------------------*-
  314. Function:
  315.     SetAllScore
  316. Parameters:
  317.     score - score to set.
  318. Action:
  319.     - Sets all players score.
  320. -*----------------------------------------------------------------------------*/       
  321. stock SetAllScore(score)
  322. {
  323.     foreach(Player, i) SetPlayerScore( i, score );
  324.     return true;
  325. }
  326. /*----------------------------------------------------------------------------*-
  327. Function:
  328.     SetAllAmmo
  329. Parameters:
  330.     weaponslot - weaponslot to set ammo.
  331.     ammo - ammo to set.
  332. Action:
  333.     - Sets all players ammo.
  334. -*----------------------------------------------------------------------------*/
  335. stock SetAllAmmo(weaponslot, ammo)
  336. {
  337.     foreach(Player, i) SetPlayerAmmo( i, weaponslot, ammo );
  338.     return true;
  339. }
  340. /*----------------------------------------------------------------------------*-
  341. Function:
  342.     SetAllDrunkLevel
  343. Parameters:
  344.     level - drunk level to set.
  345. Action:
  346.     - Sets all players drunk level.
  347. -*----------------------------------------------------------------------------*/       
  348. stock SetAllDrunkLevel(level)
  349. {
  350.     foreach(Player, i) SetPlayerDrunkLevel( i, level );
  351.     return true;
  352. }
  353. /*----------------------------------------------------------------------------*-
  354. Function:
  355.     SetAllWantedLevel
  356. Parameters:
  357.     level - wanted level to set.
  358. Action:
  359.     - Sets all players wanted level.
  360. -*----------------------------------------------------------------------------*/       
  361. stock SetAllWantedLevel(level)
  362. {
  363.     foreach(Player, i) SetPlayerWantedLevel( i, level );
  364.     return true;
  365. }
  366. /*----------------------------------------------------------------------------*-
  367. Function:
  368.     SetAllArmour
  369. Parameters:
  370.     Float:armor - armour to set.
  371. Action:
  372.     - Sets all players armour.
  373. -*----------------------------------------------------------------------------*/       
  374. stock SetAllArmour(Float:armor)
  375. {
  376.     foreach(Player, i) SetPlayerArmour( i, Float: armor);
  377.     return true;
  378. }
  379. /*----------------------------------------------------------------------------*-
  380. Function:
  381.     SetAllHealth
  382. Parameters:
  383.     Float:health - health to set.
  384. Action:
  385.     - Sets all players health.
  386. -*----------------------------------------------------------------------------*/       
  387. stock SetAllHealth(Float:health)
  388. {
  389.     foreach(Player, i) SetPlayerHealth( i, Float: health );
  390.     return true;
  391. }
  392. /*----------------------------------------------------------------------------*-
  393. Function:
  394.     GiveAllScore
  395. Parameters:
  396.     score - score to increase.
  397. Action:
  398.     - Increase a player score.
  399. -*----------------------------------------------------------------------------*/       
  400. stock GiveAllScore(score)
  401. {
  402.     foreach(Player, i) SetPlayerScore( i, GetPlayerScore( i ) + score );
  403.     return true;
  404. }
  405. /*----------------------------------------------------------------------------*-
  406. Function:
  407.     GiveAllAmmo
  408. Parameters:
  409.     weaponslot - weaponslot to give ammo.
  410.     ammo - ammo to give.
  411. Action:
  412.     - Gives all players ammo.
  413. -*----------------------------------------------------------------------------*/
  414. stock GiveAllAmmo(weaponslot, ammo)
  415. {
  416.     foreach(Player, i) SetPlayerAmmo( i, weaponslot, GetPlayerAmmo( i ) + ammo );
  417.     return true;
  418. }
  419. /*----------------------------------------------------------------------------*-
  420. Function:
  421.     GiveAllDrunkLevel
  422. Parameters:
  423.     level - drunk level to increase.
  424. Action:
  425.     - Increase all players drunk level.
  426. -*----------------------------------------------------------------------------*/       
  427. stock GiveAllDrunkLevel(level)
  428. {
  429.     foreach(Player, i) SetPlayerDrunkLevel( i, GetPlayerDrunkLevel( i ) + level );
  430.     return true;
  431. }
  432. /*----------------------------------------------------------------------------*-
  433. Function:
  434.     GiveAllWantedLevel
  435. Parameters:
  436.     level - wanted level to increase.
  437. Action:
  438.     - Increase all players wanted level.
  439. -*----------------------------------------------------------------------------*/       
  440. stock GiveAllWantedLevel(level)
  441. {
  442.     foreach(Player, i) SetPlayerWantedLevel( i, GetPlayerWantedLevel( i ) + level );
  443.     return true;
  444. }
  445. /*----------------------------------------------------------------------------*-
  446. Function:
  447.     GiveAllHealth
  448. Parameters:
  449.     Float:health - health to increase.
  450. Action:
  451.     - Increase all players health.
  452. -*----------------------------------------------------------------------------*/       
  453. stock GiveAllHealth(Float:health)
  454. {
  455.     new
  456.         Float: hp
  457.     ;
  458.     foreach(Player, i)
  459.     {
  460.         SetPlayerHealth( i, GetPlayerHealth( i, hp ) + Float: health );
  461.     }
  462.     return true;
  463. }
  464. /*----------------------------------------------------------------------------*-
  465. Function:
  466.     GiveAllArmour
  467. Parameters:
  468.     Float:armour - armour to increase.
  469. Action:
  470.     - Increase all players armour.
  471. -*----------------------------------------------------------------------------*/
  472. stock GiveAllArmour(Float:armour)
  473. {
  474.     new
  475.         Float: arm
  476.     ;
  477.     foreach(Player, i)
  478.     {
  479.         SetPlayerArmour( i, GetPlayerArmour( i, arm ) + Float: armour );
  480.     }
  481.     return true;
  482. }
  483. /*----------------------------------------------------------------------------*-
  484. Function:
  485.     GivePlayerHealth
  486. Parameters:
  487.     playerid - playerid who receive the health.
  488.     Float:health - health to give.
  489. Action:
  490.     - Increase a player health.
  491. -*----------------------------------------------------------------------------*/
  492. stock GivePlayerHealth(playerid, Float:health)
  493. {
  494.     new
  495.         Float: hp
  496.     ;
  497.     SetPlayerHealth( playerid, GetPlayerHealth( playerid, hp ) + Float: health);
  498.     return true;
  499. }
  500. /*----------------------------------------------------------------------------*-
  501. Function:
  502.     GivePlayerArmour
  503. Parameters:
  504.     playerid - player who receive the armour.
  505.     Float:armour - armour to give.
  506. Action:
  507.     - Increase a player armour.
  508. -*----------------------------------------------------------------------------*/
  509. stock GivePlayerArmour(playerid, Float:armour)
  510. {
  511.     new
  512.         Float: arm
  513.     ;
  514.     SetPlayerArmour( playerid, GetPlayerArmour( playerid, arm ) + Float: armour);
  515.     return true;
  516. }
  517. /*----------------------------------------------------------------------------*-
  518. Function:
  519.     GivePlayerDrunkLevel
  520. Parameters:
  521.     playerid - player who receive the drunk level.
  522.     level - drunk level to increase.
  523. Action:
  524.     - Increase a player drunk level.
  525. -*----------------------------------------------------------------------------*/
  526. stock GivePlayerDrunkLevel(playerid, level)
  527. {
  528.     SetPlayerDrunkLevel( playerid, GetPlayerDrunkLevel( playerid ) + level );
  529.     return true;
  530. }
  531. /*----------------------------------------------------------------------------*-
  532. Function:
  533.     GivePlayerWantedLevel
  534. Parameters:
  535.     playerid - player who receive the wanted level.
  536.     level - wanted level to give.
  537. Action:
  538.     - Increase a player wanted level.
  539. -*----------------------------------------------------------------------------*/       
  540. stock GivePlayerWantedLevel(playerid, level)
  541. {
  542.     SetPlayerWantedLevel( playerid, GetPlayerWantedLevel( playerid ) + level );
  543.     return true;
  544. }
  545. /*----------------------------------------------------------------------------*-
  546. Function:
  547.     GivePlayerAmmo
  548. Parameters:
  549.     playerid - player who receive the ammo.
  550.     weaponslot - weaponslot to give the ammo.
  551.     ammo - ammo to give.
  552. Action:
  553.     - Increase a player ammo.
  554. -*----------------------------------------------------------------------------*/       
  555. stock GivePlayerAmmo(playerid, weaponslot, ammo)
  556. {
  557.     SetPlayerAmmo( playerid, weaponslot, GetPlayerAmmo( playerid ) + ammo );
  558.     return true;
  559. }
  560. /*----------------------------------------------------------------------------*-
  561. Function:
  562.     GivePlayerScore
  563. Parameters:
  564.     playerid - player who receive the score.
  565.     score - score to increase.
  566. Action:
  567.     - Increase a player score.
  568. -*----------------------------------------------------------------------------*/       
  569. stock GivePlayerScore(playerid, score)
  570. {
  571.     SetPlayerScore( playerid, GetPlayerScore( playerid ) + score );
  572.     return true;
  573. }
  574. /*----------------------------------------------------------------------------*-
  575. Function:
  576.     Freeze
  577. Parameters:
  578.     playerid - player who gets freezed.
  579. Action:
  580.     - Freeze a player.
  581. -*----------------------------------------------------------------------------*/   
  582. stock Freeze( playerid )
  583. {
  584.     TogglePlayerControllable( playerid, 0 );
  585.     return true;
  586. }
  587. /*----------------------------------------------------------------------------*-
  588. Function:
  589.     Unfreeze
  590. Parameters:
  591.     playerid - player who gets unfreezed.
  592. Action:
  593.     - Unfreeze a player.
  594. -*----------------------------------------------------------------------------*/   
  595. stock Unfreeze( playerid )
  596. {
  597.     TogglePlayerControllable( playerid, 1 );
  598.     return true;
  599. }
  600.        
  601.  
  602.  
Advertisement
Add Comment
Please, Sign In to add comment