deskoft

Lawedan's useful functions

May 20th, 2011
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.99 KB | None | 0 0
  1. /*******************************************************************************
  2.         *********************************************
  3.         *                   Lawedan Labs            *
  4.         *             Los Angeles, California       *
  5.         *********************************************
  6. (C)Lawedan Labs 2009-2011. All Rights Reserved.
  7.  
  8. ********************    TERMS OF USE    ****************************************
  9.  
  10. 1.0 WHAT IS LAWEDAN LABS
  11. ----1.1 Our Services
  12. Lawedan Labs is a gaming enterprise, which main duty is to create high quality
  13. servers and "scripts" for gaming communities, aswell as softwares to improve
  14. the experience while inside the game.
  15. As we are a private enterprise, we require each member to accept our terms of
  16. use. If you have reached this script, you have previously accepted our terms
  17. of service.
  18.  
  19. 2.0 DEFINITIONS
  20. A "Script", is a set of instructions executed based on another software.
  21. Lawedan Labs currently uses "Scripts" for San Andreas Multiplayer, which
  22. at the same time is a modification of The Rockstar Games Grand Theft Auto
  23. San Andreas.
  24. "TOU", is the acronym for Terms Of Use, which is the text you are currently reading,
  25. this text defines what the user can do and what the user can't do.
  26. "TOS", is the acronym for Terms Of Service, which is accepted upon requesting
  27. to download any of our scripts.
  28.  
  29. 3.0 ACCEPTANCE
  30. ----2.1 What am I accepting?
  31. Upon using this script, you are accepting this Terms of Use, and our
  32. Lawedan Labs Terms Of Service, found at our CEO's Blog,
  33. deskoft.tumblr.com.
  34.  
  35. 4.0 THIS SCRIPT
  36. ----4.1 What is this Script?
  37. This script is the Lawedan Labs Useful Functions (lluf.inc),
  38. which is a include for San Andreas Multiplayer.
  39. ----4.2 Release
  40. This script is currently being released in the sa-mp forums and in my blog,
  41. by using this script you accept that at no time you will get profit from this
  42. script, you accept not to delete the credits from this script, and you
  43. accept to follow our Terms of Service.
  44. ________________________________________________________________________________
  45. ********************************************************************************                                                                        */
  46. // #define Accept // <- Uncomment that if you accept the Terms of Service.
  47.  
  48. #include <a_samp>
  49. #if defined Accept
  50.  
  51. /*
  52. native DisableEnterExitPaySpray(No Params Needed)
  53. native PlayerName(playerid)
  54. native IsPlayerDriver(playerid)
  55. native IsPlayerPassenger(playerid)
  56. native Create3DTextLabel(text[], color, Float:X, Float:Y, Float:Z, Float:DrawDistance, virtualworld, testLOS)
  57. */
  58.  
  59. #define startup main(){}
  60. startup
  61.  
  62. forward OnPlayerShootPlayer(playerid, victimid);
  63.  
  64. stock Daf__OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  65. {
  66.         // Credits to whoever made it
  67.         if(((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE)) || ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) ||  (newkeys & KEY_FIRE))
  68.         {
  69.                 for(new i = 0; i < GetMaxPlayers(); i++)
  70.                 {
  71.                     if(IsPlayerConnected(i) && playerid != i && !IsPlayerNPC(i))
  72.                     {
  73.                                 if(IsPlayerAiming(playerid, i) && GetPlayerState(i) != PLAYER_STATE_WASTED)
  74.                                 {
  75.                                     OnPlayerShootPlayer(playerid, i);
  76.                                 }
  77.                         }
  78.                 }
  79.         }
  80.         return 1;
  81. }
  82.  
  83. stock IsPlayerAiming(playerid, aimid)
  84. {
  85.         // Credits to Whoever made it
  86.         new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2;
  87.         GetPlayerPos(playerid, X1, Y1, Z1);
  88.         GetPlayerPos(aimid, X2, Y2, Z2);
  89.         new Float:Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
  90.         if(Distance < 100)
  91.         {
  92.                 new Float:A;
  93.                 GetPlayerFacingAngle(playerid, A);
  94.                 X1 += (Distance * floatsin(-A, degrees));
  95.                 Y1 += (Distance * floatcos(-A, degrees));
  96.                 Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
  97.                 if(Distance < 0.5)
  98.                 {
  99.                     return true;
  100.                 }
  101.         }
  102.         return false;
  103. }
  104.  
  105. stock DisableEnterExitPaySpray()
  106. {
  107.     CreateObject(974, 720.11761474609, -462.47760009766, 17.578575134277, 0, 0, 0);
  108.     CreateObject(974, 2071.2622070313, -1831.3481445313, 14.521961212158, 0, 0, 89.622436523438);
  109.     CreateObject(974, 1041.3873291016, -1025.708984375, 32.809097290039, 0, 0, 0);
  110.     CreateObject(974, 1024.9073, -1029.1785, 32.3793, 0.0000, 0.0000, 0.0000);
  111.     CreateObject(974, 1041.5345, -1025.7608, 32.3793, 0.0000, 0.0000, 0.0000);
  112.     CreateObject(974, 2644.8608, -2039.4061, 13.0777, 0.0000, 0.0000, 0.0000);
  113. }
  114.  
  115. stock GetClientName(playerid)
  116. {
  117.     if(!IsPlayerConnected)
  118.     {
  119.         return 0;
  120.     }
  121.     new playername[128];
  122.     GetPlayerName(playerid, playername, sizeof(playername));
  123.     return playername;
  124. }
  125.  
  126. stock IsPlayerDriver(playerid)
  127. {
  128.     new playerstate = GetPlayerState(playerid);
  129.     if(playerstate == PLAYER_STATE_DRIVER)
  130.     {
  131.         return 1;
  132.     }else{
  133.         return 0;
  134.     }
  135. }
  136.  
  137. stock IsPlayerPassenger(playerid)
  138. {
  139.     new playerstate = GetPlayerState(playerid);
  140.     if(playerstate == PLAYER_STATE_PASSENGER)
  141.     {
  142.         return 1;
  143.     }else{
  144.         return 0;
  145.     }
  146. }
  147.  
  148. stock compile(buf[]) {
  149.     // udb_hash, credits to the original creator.
  150.     new length=strlen(buf);
  151.     new s1 = 1;
  152.     new s2 = 0;
  153.     new n;
  154.     for (n=0; n<length; n++)
  155.     {
  156.        s1 = (s1 + buf[n]) % 65521;
  157.        s2 = (s2 + s1)     % 65521;
  158.     }
  159.     return (s2 << 16) + s1;
  160. }
  161.  
  162. /*
  163. native SendClientSubtitle(playerid, subtitle[]);
  164. */
  165. new Text:Subtitle[MAX_PLAYERS];
  166.  
  167. stock LOnGameModeInit()
  168. {
  169.     for(new playerid=0; playerid<MAX_PLAYERS;playerid++)
  170.     {
  171.         Subtitle[playerid] = TextDrawCreate(147, 367, "Subtitlehere");
  172.         TextDrawFont(Subtitle[playerid] , 1);
  173.         TextDrawLetterSize(Subtitle[playerid] , 0.3, 2.1);
  174.         TextDrawColor(Subtitle[playerid] , 0xFFFFFFFF);
  175.         TextDrawSetOutline(Subtitle[playerid] , 0);
  176.         TextDrawSetProportional(Subtitle[playerid] , 1);
  177.         TextDrawSetShadow(Subtitle[playerid] , 1);
  178.     }
  179. }
  180. forward HideSubtitle(playerid);
  181. public HideSubtitle(playerid)
  182. {
  183.     TextDrawHideForPlayer(playerid, Subtitle[playerid]);
  184. }
  185.  
  186. stock SendClientSubtitles(playerid, subtitle[])
  187. {
  188.     if(IsPlayerConnected(playerid))
  189.     {
  190.         TextDrawSetString(Subtitle[playerid], subtitle);
  191.         TextDrawShowForPlayer(playerid, Subtitle[playerid]);
  192.         SetTimerEx("HideSubtitle", strlen(subtitle)*100, false, "u", playerid);
  193.     }
  194. }
  195.  
  196.  
  197. /*
  198. native SetPlayerCheckpointEx(playerid, cpid, Float:x, Float:y, Float:z, Float:size);
  199. */
  200. new checkpointid[MAX_PLAYERS];
  201. forward OnPlayerEnterCheckpointEx(playerid, cpid);
  202. stock LOnPlayerEnterCheckpoint(playerid)
  203. {
  204.     OnPlayerEnterCheckpointEx(playerid, checkpointid[playerid]);
  205. }
  206.  
  207. stock SetPlayerCheckpointEx(playerid, cpid, Float:x, Float:y, Float:z, Float:size)
  208. {
  209.     if(IsPlayerConnected(playerid) == 1)
  210.     {
  211.         SetPlayerCheckpoint(playerid, x, y, z, size);
  212.         checkpointid[playerid] = cpid;
  213.     }
  214. }
  215.  
  216. #else
  217. #error You need to accept the terms of use in the lluf.inc (Do this by typing #define Accept)
  218. #endif
Advertisement
Add Comment
Please, Sign In to add comment