dEcooR

dFunc - Simple Useful Functions

Jun 19th, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.81 KB | None | 0 0
  1. /*
  2. Useful Functions 0.3x
  3. Created by: dEcooR
  4. Simply use #include <dfunc>
  5. Version: 1.0
  6.  
  7. Functions:
  8. PlayerName(playerid)
  9. GivePlayerHealth(playerid,health)
  10. GivePlayerArmour(playerid,armour)
  11. GivePlayerScore(playerid,score)
  12. GetPlayerHP(playerid)
  13. GetPlayerARM(playerid)
  14. IsVehicleBike(vehicleid)
  15. GetVehSpeed(vehicleid)
  16. GetPlayerSpeed(playerid)
  17. Fuck(playerid)
  18. IsPlayerAiming(playerid)
  19. IsPlayerInZone(playerid,x_min,y_min,x_max,y_max)
  20. SendMessageToAdmins(color,message)
  21. GetWeaponSlot(weaponid)
  22. PlayAudioStreamForAll(url)
  23. GetPlayerIP(playerid)
  24. IsPlayerInWater(playerid)
  25. */
  26.  
  27. #define MPH_KMH 1.609344
  28. #define BIEBER 0xFF00FFFF
  29.  
  30. stock PlayerName(playerid) // Get Player Name
  31. {
  32.         new name[MAX_PLAYER_NAME];
  33.         GetPlayerName(playerid,name,sizeof(name));
  34.         return name;
  35. }
  36.  
  37. stock GivePlayerHealth(playerid,Float:HP) // Give player health
  38. {
  39.     if(HP > 99.0) HP = 99.0;
  40.     if(HP < 0.0) HP = 0.0;
  41.    
  42.     new Float:Health;
  43.     GetPlayerHealth(playerid,Health);
  44.         SetPlayerHealth(playerid,Health + HP);
  45.         if(Health + HP > 99.0) SetPlayerHealth(playerid,99.0);
  46. }
  47.  
  48. stock GivePlayerArmour(playerid,Float:AR) // Give player armour
  49. {
  50.         if(AR > 99.0) AR = 99.0;
  51.     if(AR < 0.0) AR = 0.0;
  52.    
  53.     new Float:Armour;
  54.     GetPlayerArmour(playerid,Armour);
  55.         SetPlayerArmour(playerid,Armour + AR);
  56.         if(Armour + AR > 99.0) SetPlayerArmour(playerid,99.0);
  57. }
  58.  
  59. stock GivePlayerScore(playerid,score) //Give Player score eazyli
  60. {
  61.     SetPlayerScore(playerid,GetPlayerScore(playerid)+Score);
  62. }
  63.  
  64. stock GetPlayerHP(playerid) //Get player health eazy
  65. {
  66.     new Float:hp;
  67.         return GetPlayerHealth(playerid,hp);
  68. }
  69.  
  70. stock GetPlayerARM(playerid) // Get player armour eazy
  71. {
  72.     new Float:armour;
  73.         return GetPlayerArmour(playerid,armour);
  74. }
  75.  
  76. stock IsVehicleBike(vehicleid) // checks if is vehicle bike
  77. {  
  78.     new vehicleid = GetPlayerVehicleID(playerid);
  79.     switch(GetVehicleModel(vehicleid))
  80.     case 509,481,510: return 1;
  81.     return 0;
  82. }
  83.  
  84. stock GetVehSpeed(vehicleid) // Use GetVehSpeed(vehicleid)
  85. {
  86.         new Float:x,Float:y,Float:z,vel;
  87.         GetVehicleVelocity(vehicleid, x, y, z);
  88.         vel = floatround(floatsqroot( x*x + y*y + z*z ) * 180); // KM/H
  89.         //vel = floatround(floatsqroot( x*x + y*y + z*z ) * 180 / MPH_KMH); // You can use also MPH
  90.         return vel;
  91. }
  92.  
  93. stock GetPlayerSpeed(playerid)  // Use GetPlayerSpeed(playerid)
  94. {
  95.         new Float:ST[4];
  96.         if(IsPlayerInAnyVehicle(playerid))
  97.         GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
  98.         else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
  99.         ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) +       floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
  100.         return floatround(ST[3]);
  101. }
  102.  
  103. stock Fuck(playerid)
  104. {
  105.     new Float:Pos[3];
  106.     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  107.  
  108.     SetPlayerName(playerid,"BiebersMom");
  109.     SetPlayerColor(playerid,BIEBER);
  110.     SetPlayerPos(playerid, Pos[0]+8, Pos[1]+5, Pos[2]+50);
  111.     CreateExplosion(Pos[0], Pos[1], Pos[2], 8, 2.0);
  112.     SetPlayerHealth(playerid,5.0);
  113. }
  114.  
  115. stock IsPlayerAiming(playerid) // checking if is player aiming
  116. {
  117.     new a = GetPlayerAnimationIndex(playerid);
  118.     if (((a>= 1160) && (a<= 1163)) || (a== 1167) || (a== 1365) || (a== 1643) || (a== 1453) || (a== 220)) return 1;
  119.     return 0;
  120. }
  121.  
  122. IsPlayerInZone(playerid,Float:x_min,Float:y_min,Float:x_max,Float:y_max) // this function checks if is player in some zone/area
  123. {
  124.     new Float:xx,Float:yy,Float:zz;
  125.     GetPlayerPos(playerid,xx,yy,zz);
  126.     #pragma unused z_isia
  127.         if(xx> x_min && xx < x_max && yy > y_min && yy< y_max) return 1;
  128.     return 0;
  129. }
  130.  
  131. stock SendMessageToAdmins(color,const string[]) // Send message to online admins
  132. {
  133.     for(new i=0; i<MAX_PLAYERS; i++)
  134.     {
  135.         if(ISP(i))
  136.         {
  137.             if(/*your admin*/ || IsPlayerAdmin(i)) SendClientMessage(i, color, string);
  138.         }
  139.     }
  140. }
  141.  
  142. stock GetWeaponSlot(weaponid) // this get the weapon slot
  143. {
  144.     switch(weaponid)
  145.     {
  146.             case 0,1: return 0;
  147.             case 2..9: return 1;
  148.             case 10..15: return 10;
  149.             case 16..18,39: return 8;
  150.             case 22..24: return 2;
  151.             case 25..27: return 3;
  152.             case 28,29,32: return 4;
  153.             case 30,31: return 5;
  154.             case 33,34: return 6;
  155.             case 35..38: return 7;
  156.             case 41..43: return 9;
  157.             case 44..46: return 11;
  158.             default: return 12;
  159.     }
  160.     return 12;
  161. }
  162.  
  163. stock PlayAudioStreamForAll(url[])
  164. {
  165.     for(new i = 0;i < MAX_PLAYERS;i++)
  166.     {
  167.         if(IsPlayerConnected(i))
  168.         {
  169.             PlayAudioStreamForPlayer(i,url);
  170.         }
  171.     }
  172. }
  173.  
  174. stock GetPlayerIP(playerid) // Getting player ip
  175. {
  176.         new IP[16];
  177.     GetPlayerIp(playerid, IP,16);
  178.     return IP;
  179. }
  180.  
  181. stock IsPlayerInWater(playerid) // checks if is player swimming/in water
  182. {
  183.     new a = GetPlayerAnimationIndex(playerid);
  184.     if (((a>=  1538) && (a<= 1542)) || (a== 1544) || (a== 1250) || (a== 1062)) return 1;
  185.     return 0;
  186. }
Advertisement
Add Comment
Please, Sign In to add comment