Advertisement
iPLEOMAX

iMouse - iPLEOMAX

Jul 31st, 2011
1,388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.72 KB | None | 0 0
  1. /*******************************************************/
  2. /* Experimental Cursor FilterScript for SA-MP          */
  3. /* Made by iPLEOMAX ©.                                 */
  4. /* > Works well when player is aiming wtih a           */
  5. /*   Sniper Rifle/HeatSeeker/RPG.                      */
  6. /* > I gave sniper so that they can't                  */
  7. /*   boom themselves.. xD                              */
  8. /* WARNING! You are not allowed to remove any credits! */
  9. /*******************************************************/
  10.  
  11. #include < a_samp >
  12.  
  13. #define frc(%0) floatround(%0*100, floatround_ceil)
  14.  
  15. #define iM_MODE_CREATE 1
  16. #define iM_MODE_UPDATE 2
  17.  
  18. new Text:CursorBG;
  19.  
  20. enum iM_Configs
  21. {
  22.     bool:Enabled,
  23.     Timer,
  24.     CX, CY,
  25.     Text:PointerP1,
  26.     Text:PointerP2
  27. };
  28. new iM[MAX_PLAYERS][iM_Configs];
  29.  
  30. public OnFilterScriptInit()
  31. {
  32.     print("\n * On-Screen Cursor FS Loaded! - iPLEOMAX \n");
  33.    
  34.     CursorBG = TextDrawCreate(665.000000, 0.000000, "ScreenB");
  35.     TextDrawBackgroundColor(CursorBG, 255);
  36.     TextDrawFont(CursorBG, 1);
  37.     TextDrawLetterSize(CursorBG, 0.000000, 50.800003);
  38.     TextDrawColor(CursorBG, -1);
  39.     TextDrawSetOutline(CursorBG, 0);
  40.     TextDrawSetProportional(CursorBG, 1);
  41.     TextDrawSetShadow(CursorBG, 1);
  42.     TextDrawUseBox(CursorBG, 1);
  43.     TextDrawBoxColor(CursorBG, 255);
  44.     TextDrawTextSize(CursorBG, -65.000000, 0.000000);
  45.    
  46.     return true;
  47. }
  48.  
  49. public OnFilterScriptExit() { print(" * On-Screen Cursor FS exited."); return true; }
  50.  
  51. public OnPlayerDisconnect( playerid, reason ) { return DisableCursor( playerid ); }
  52.  
  53. public OnPlayerCommandText( playerid, cmdtext[] )
  54. {
  55.     if (!strcmp("/cursor", cmdtext, true))
  56.     {
  57.         if(!iM[playerid][Enabled]) { EnableCursor( playerid ); }
  58.         else { DisableCursor( playerid ); }
  59.         return true;
  60.     }
  61.     if (!strcmp("/backgr", cmdtext, true))
  62.     {
  63.         TextDrawShowForPlayer( playerid, CursorBG );
  64.         return true;
  65.     }
  66.     return false;
  67. }
  68.  
  69. public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
  70. {
  71.     if(newkeys & KEY_FIRE && iM[playerid][Enabled])
  72.     {
  73.         new str[64];
  74.         format(str, sizeof(str), "Mouse Location - X: %i, Y: %i", iM[playerid][CX], iM[playerid][CY]);
  75.         SendClientMessage(playerid, -1, str);
  76.     }
  77. }
  78.  
  79. forward EnableCursor( playerid );
  80. public EnableCursor( playerid )
  81. {
  82.     if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, -1, "You need to be on-foot to use this command.");
  83.    
  84.     TextDrawShowForPlayer( playerid, CursorBG );
  85.     GivePlayerWeapon( playerid, 34, -1 );
  86.     //SetPlayerInterior(playerid, 1);
  87.     SetPlayerVirtualWorld( playerid, playerid+MAX_PLAYERS );
  88.     iM[playerid][CX] = 320; iM[playerid][CY] = 240;
  89.     iM[playerid][Timer] = SetTimerEx( "CursorCheck", 100, true, "d", playerid );
  90.     iM[playerid][Enabled] = true;
  91.     return true;
  92. }
  93.  
  94. forward DisableCursor( playerid );
  95. public DisableCursor( playerid )
  96. {
  97.     KillTimer( iM[playerid][Timer] );
  98.     TextDrawDestroy( iM[playerid][PointerP1] );
  99.     TextDrawDestroy( iM[playerid][PointerP2] );
  100.     TextDrawHideForPlayer( playerid, CursorBG );
  101.     SpawnPlayer( playerid );
  102.     SetPlayerInterior( playerid, 0 );
  103.     SetPlayerVirtualWorld( playerid, 0 );
  104.     iM[playerid][Enabled] = false;
  105.     return true;
  106. }
  107.  
  108. forward CursorCheck( playerid );
  109. public CursorCheck( playerid )
  110. {
  111.     if(!iM[playerid][Enabled]) return true;
  112.     if(GetPlayerState(playerid) != 1) return true;
  113.    
  114.     SetPlayerFacingAngle(playerid, 0);
  115.     SetCameraBehindPlayer(playerid);
  116.     new Float:P[3];
  117.     GetPlayerCameraFrontVector( playerid, P[0], P[1], P[2] );
  118.     Cursor( playerid, iM[playerid][CX]+frc(P[0])-1, iM[playerid][CY]+(frc(P[2])+4)*-1 );
  119.    
  120.     return true;
  121. }
  122.  
  123. stock Cursor( playerid, X, Y )
  124. {
  125.     if(X>640) X=640; if(Y>480) Y=480;
  126.     if(X<0) X=0; if(Y<0) Y=0;
  127.    
  128.     iM[playerid][CX]=X;
  129.     iM[playerid][CY]=Y;
  130.  
  131.     TextDrawDestroy( iM[playerid][PointerP1] );
  132.     TextDrawDestroy( iM[playerid][PointerP2] );
  133.    
  134.     iM[playerid][PointerP1] = TextDrawCreate(X, Y, "\\_");
  135.     TextDrawBackgroundColor(iM[playerid][PointerP1], 255);
  136.     TextDrawFont(iM[playerid][PointerP1], 1);
  137.     TextDrawLetterSize(iM[playerid][PointerP1], 0.670000, 1.200000);
  138.     TextDrawColor(iM[playerid][PointerP1], -1);
  139.     TextDrawSetOutline(iM[playerid][PointerP1], 0);
  140.     TextDrawSetProportional(iM[playerid][PointerP1], 1);
  141.     TextDrawSetShadow(iM[playerid][PointerP1], 0);
  142.  
  143.     iM[playerid][PointerP2] = TextDrawCreate(X-2.000000, Y-1.000000, "\\_");
  144.     TextDrawBackgroundColor(iM[playerid][PointerP2], 255);
  145.     TextDrawFont(iM[playerid][PointerP2], 2);
  146.     TextDrawLetterSize(iM[playerid][PointerP2], 1.120000, 1.200000);
  147.     TextDrawColor(iM[playerid][PointerP2], -1);
  148.     TextDrawSetOutline(iM[playerid][PointerP2], 0);
  149.     TextDrawSetProportional(iM[playerid][PointerP2], 1);
  150.     TextDrawSetShadow(iM[playerid][PointerP2], 0);
  151.  
  152.     TextDrawShowForPlayer( playerid, iM[playerid][PointerP1] );
  153.     TextDrawShowForPlayer( playerid, iM[playerid][PointerP2] );
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement