ulfricmalcom

fusroda

Dec 2nd, 2012
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.15 KB | None | 0 0
  1.  
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <zcmd>
  6. #include <sscanf2>
  7.  
  8. new Float: speed = 0.5; // by default
  9. new Float: height = 0.5;
  10.  
  11. public OnFilterScriptInit()
  12. {
  13.     print("\n--------------------------------------");
  14.     print(" Fus Ro Dah by myAnus");
  15.     print("--------------------------------------\n");
  16.     return 1;
  17. }
  18.  
  19. public OnFilterScriptExit()
  20. {
  21.     print("Shout unloaded.");
  22.     return 1;
  23. }
  24. CMD:setshoutdata(playerid, params[])
  25. {
  26.     new string[128];
  27.     new dataType[20], Float: value;
  28.     if(sscanf(params, "s[20]f", dataType, value)) return SendClientMessage(playerid, -1, "/setshoutvalue [type](speed, height) [value](float)");
  29.     if(strcmp(dataType, "speed", true) == 0)
  30.     {
  31.         if(value <= 0.0) SendClientMessage(playerid, -1, "Warning: speed need to be greater than 0");
  32.         format(string, sizeof(string), "Speed has been changed from %f to %f .", speed, value);
  33.         speed = value;
  34.         SendClientMessageToAll(-1, string);
  35.     }
  36.     else if(strcmp(dataType, "height", true) == 0)
  37.     {
  38.         format(string, sizeof(string), "Z velocity has been changed from %f to %f .", height, value);
  39.         height = value;
  40.         SendClientMessageToAll(-1, string);
  41.     }
  42.     else SendClientMessage(playerid, -1, "/setshoutvalue [type](speed, height) [value](float)");
  43.     return 1;
  44. }
  45. CMD:fusrodah(playerid, params[])
  46. {
  47.     new string[128], name[MAX_PLAYER_NAME + 1], bool:inVeh = false;
  48.     GetPlayerName(playerid, name, sizeof(name));
  49.     new Float: x, Float:y, Float:z, Float: xEx, Float: yEx;
  50.     if(IsPlayerInAnyVehicle(playerid))
  51.     {
  52.         GetPlayerPos(playerid, x, y, z);
  53.         CreateExplosion(x, y, z, 2, 10.0);
  54.         SetPlayerHealth(playerid, 0.0);
  55.         SendClientMessage(playerid, -1, "You shouted in a vehicle, thus creating an awesome explosion.");
  56.         return 1;
  57.     }
  58.     /*if(speed < 0.0001) speed = 0.5;
  59.     if(height < 0.0001) speed = 0.3;*/
  60.     GetPlayerPos(playerid, x, y, z);
  61.     GetXYInFrontOfPlayer(playerid, x, y, 5.0);
  62.     GetXYInFrontOfPlayer(playerid, xEx, yEx, 10.0);
  63.    
  64.     /* Get velocity*
  65.     new Float: xV, Float: yV, Float: fAngle;
  66.     if(IsPlayerInAnyVehicle(playerid))
  67.     {
  68.         inVeh = true;
  69.         GetVehicleZAngle(GetPlayerVehicleID(playerid), fAngle);
  70.     }
  71.     else GetPlayerFacingAngle(playerid, fAngle);
  72.     xV = (speed * floatsin(-fAngle, degrees));
  73.     yV = (speed * floatcos(-fAngle, degrees));
  74.        *End here */
  75.    
  76.     SetPlayerChatBubble(playerid, "FUS RO DAH!", -1, 16, 5000);
  77.     new Float: health;
  78.     new Float: opX, Float: opY, Float:opZ, Float: xV, Float: yV, Float: fAngle;
  79.     new Float: victimX, Float: victimY;
  80.     GetPlayerPos(playerid, opX, opY, opZ);
  81.     for(new i = 0; i < MAX_PLAYERS; i++)
  82.     {
  83.         if(IsPlayerConnected(i))
  84.         {
  85.             if(IsPlayerInRangeOfPoint(i, 5.0, x, y, z) || IsPlayerInRangeOfPoint(i, 8.0, xEx, yEx, z))
  86.             {
  87.                 if(i != playerid)
  88.                 {
  89.                     /* New Get Velocity*/
  90.                     GetPlayerPos(i, victimX, victimY, opZ);
  91.                     fAngle = GetFacingPos(victimX, victimY, opX, opY);
  92.                     xV = (speed * floatsin(-fAngle, degrees));
  93.                     yV = (speed * floatcos(-fAngle, degrees));
  94.                     xV *= -1;
  95.                     yV *= -1;
  96.                     /* End here */
  97.                    
  98.                     if (IsPlayerInAnyVehicle(i)) inVeh = true;
  99.                     GetPlayerHealth(i, health);
  100.                     if(inVeh)
  101.                     {
  102.                         xV *= 0.85; //Hard coded velocity reduction, you can change it to w/e you like.
  103.                         yV *= 0.85;
  104.                         height *= 0.85;
  105.                         SetVehicleVelocity(GetPlayerVehicleID(i), xV, yV, height);
  106.                         inVeh = false;
  107.                     }
  108.                     else
  109.                     {
  110.                         health -= 2.0;
  111.                         SetPlayerVelocity(i, xV, yV, height);
  112.                         GetPlayerVelocity(i, xV, yV, opZ);
  113.                         SetPlayerHealth(i, health);
  114.                         printf("[Z Velocity Tracker] Velocity applied to: %d | Variable \"height\" : %f | Actual Velocity applied: ", i, height, opZ);
  115.                     }
  116.                     format(string, sizeof(string), "You have been FUS RO DAH'ed by %s !", name);
  117.                     SendClientMessage(i, -1, string);
  118.                 }// not the command sender
  119.             }// range check
  120.         }//online check
  121.     }//close loop
  122.         // This following was made to detect every empty vehicle, but saidly car w/o a driver cant be assigned a velocity :(
  123.     /*new Float:distance1, Float: distance2;
  124.     GetPlayerPos(playerid, victimX, victimY, z);
  125.     for(new i = 0; i < 1782; i++)
  126.     {
  127.         if(IsVehicleEmpty(i))
  128.         {
  129.             GetVehiclePos(i, opX, opY, opZ);
  130.             distance1 = floatsqroot(floatpower(floatabs(floatsub(opX,x)),2)+floatpower(floatabs(floatsub(opY,y)),2)+floatpower(floatabs(floatsub(opZ,z)),2));
  131.             distance2 = floatsqroot(floatpower(floatabs(floatsub(opX,xEx)),2)+floatpower(floatabs(floatsub(opY,yEx)),2)+floatpower(floatabs(floatsub(opZ,z)),2));
  132.             if(distance1 <= 5.0 || distance2 <= 8.0)
  133.             {
  134.                 fAngle = GetFacingPos(opX, opY, victimX, victimY);
  135.                 xV = (speed * floatsin(-fAngle, degrees));
  136.                 yV = (speed * floatcos(-fAngle, degrees));
  137.                 xV *= -0.85;
  138.                 yV *= -0.85;
  139.                 SetVehicleVelocity(i, xV, yV, height);
  140.             }//range check
  141.         }//empty vehicle check.
  142.     }//empty vehicle check*/
  143.     return 1;
  144. }
  145. /*stock IsVehicleEmpty( vehicleid ) //credit to who ever made this
  146. {
  147.     for ( new playerid = 0; playerid < MAX_PLAYERS; playerid++ )
  148.     {
  149.         if ( !IsPlayerConnected( playerid ) )
  150.             continue;
  151.  
  152.         if ( GetPlayerVehicleID( playerid ) == vehicleid )
  153.             return false;
  154.     }
  155.  
  156.     return true;
  157. }*/
  158. forward Float: GetFacingPos(Float: fromX, Float: fromY, Float: x, Float: y);
  159. Float: GetFacingPos(Float: fromX, Float: fromY, Float:x, Float:y)//http://forum.sa-mp.com/showthread.php?t=38965&page=338
  160. {
  161.     new Float:angle;
  162.     new Float:misc = 5.0;
  163.     angle = 180.0-atan2(fromX-x,fromY-y);
  164.     angle += misc;
  165.     misc *= -1;
  166.     angle += misc;
  167.     return angle;
  168. }
  169. GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  170. {
  171.     // Credit: Y_Less
  172.  
  173.     new Float:a;
  174.  
  175.     GetPlayerPos(playerid, x, y, a);
  176.     GetPlayerFacingAngle(playerid, a);
  177.  
  178.     if (GetPlayerVehicleID(playerid)) {
  179.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  180.     }
  181.  
  182.     x += (distance * floatsin(-a, degrees));
  183.     y += (distance * floatcos(-a, degrees));
  184. }
Advertisement
Add Comment
Please, Sign In to add comment