Alejandro_Kardona

COCHE INVISIBLE.. | SAMP - PAWNO | SILVERGAMINGYT

Jan 29th, 2017
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.61 KB | None | 0 0
  1. //Sistema creado por Riccor y SilverGamingYT, !NO ROBAR CREDITOS!
  2. #include <a_samp>
  3. #include <sscanf2> //Credits to Y_Less (http://forum.sa-mp.com/showthread.php?t=120356)
  4. #include <zcmd> //Credits to Zeex (http://forum.sa-mp.com/showthread.php?t=91354)
  5. #define COLOR_RED 0xAA3333AA
  6. #define COLOR_YELLOW 0xFFFF00AA
  7. #undef MAX_PLAYERS
  8. #define MAX_PLAYERS 100 //number of server slots
  9. #define UPDATE_RATE 50 //define update rate of vehicle speed (milliseconds); lower values might cause lag; higher values causes not constant vehicle speed
  10. #define CCKey   KEY_ACTION //define key for CC mode
  11. #define JumpKey KEY_UP //define key for vehicle jump
  12. #define JumpSize 0.2 //define vehicle jump size when press JumpKey
  13. #define AutoRepair 1 //autorepair vehicle while using CC mode: on - 1; off - 0
  14.  
  15. new bool: cc[MAX_PLAYERS char];
  16. new Float: ccspeed[MAX_PLAYERS];
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.     for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) OnPlayerConnect(i);
  21.     return print("InFly por Riccor y SilverGamingYT cargado!");
  22. }
  23.  
  24. public OnPlayerConnect(playerid)
  25. {
  26.     cc{playerid} = false;
  27.     ccspeed[playerid] = 0.1;
  28.     return 1;
  29. }
  30.  
  31. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  32. {
  33.     if(newkeys & KEY_YES)
  34.     {
  35.         LinkVehicleToInterior( GetPlayerVehicleID(playerid) , GetPlayerVirtualWorld(playerid)+10 );// invisible
  36.     }
  37.     if(newkeys & KEY_NO)
  38.     {
  39.         LinkVehicleToInterior( GetPlayerVehicleID(playerid) , GetPlayerVirtualWorld(playerid) ); //visible
  40.     }
  41.     if(cc{playerid})
  42.     {
  43.         if(newkeys & CCKey) ccf(playerid);
  44.         else if(newkeys & JumpKey)
  45.         {
  46.             new Float: x, Float:y, Float:z;
  47.             GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
  48.             SetVehicleVelocity(GetPlayerVehicleID(playerid),x, y, z + JumpSize);
  49.         }
  50.     }
  51.     return 1;
  52. }
  53.  
  54. CMD:cc(playerid,params[])
  55. {
  56.     new Float: value;
  57.     if(!sscanf(params,"f", value))
  58.     {
  59.         if(value < 0.05 || value > 3.0) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] Valor invalido! [0.05-3.0]");
  60.         ccspeed[playerid] = value;
  61.         new string[128];
  62.         format(string,sizeof(string),":: Haz puesto la velocidad a %.2f!", ccspeed[playerid]);
  63.         return SendClientMessage(playerid, COLOR_YELLOW, string);
  64.     }
  65.     if(cc{playerid})
  66.     {
  67.         cc{playerid} = false;
  68.         return SendClientMessage(playerid, COLOR_RED, ":: Haz deshabilitado el modo CC!");
  69.     }
  70.     else
  71.     {
  72.         cc{playerid} = true;
  73.         return SendClientMessage(playerid, COLOR_YELLOW, ":: Haz activado el modo CC! Mantenga presionada la tecla CTRL mientras conduce. Usa /cc [valor] para cambiar la velocidad.");
  74.     }
  75. }
  76.  
  77. forward ccf(playerid);
  78. public ccf(playerid)
  79. {
  80.     new keys, ud, lr;
  81.     GetPlayerKeys(playerid, keys, ud, lr);
  82.     if((keys & CCKey))
  83.     {
  84.         new Float: adirection[3];
  85.         new vehid = GetPlayerVehicleID(playerid);
  86.         new Float:Quaternion[4];
  87.         new Float:transformationmatrix[4][4];
  88.  
  89.         GetVehicleRotationQuat(vehid, Quaternion[0], Quaternion[1], Quaternion[2], Quaternion[3]);
  90.  
  91.         new Float:xx = Quaternion[0] * Quaternion[0];
  92.         new Float:xy = Quaternion[0] * Quaternion[1];
  93.         new Float:xz = Quaternion[0] * Quaternion[2];
  94.         new Float:xw = Quaternion[0] * Quaternion[3];
  95.         new Float:yy = Quaternion[1] * Quaternion[1];
  96.         new Float:yz = Quaternion[1] * Quaternion[2];
  97.         new Float:yw = Quaternion[1] * Quaternion[3];
  98.         new Float:zz = Quaternion[2] * Quaternion[2];
  99.         new Float:zw = Quaternion[2] * Quaternion[3];
  100.  
  101.         transformationmatrix[0][0] = 1 - 2 * ( yy + zz );
  102.         transformationmatrix[0][1] =     2 * ( xy - zw );
  103.         transformationmatrix[0][2] =     2 * ( xz + yw );
  104.         transformationmatrix[0][3] = 0.0;
  105.  
  106.         transformationmatrix[1][0] =     2 * ( xy + zw );
  107.         transformationmatrix[1][1] = 1 - 2 * ( xx + zz );
  108.         transformationmatrix[1][2] =     2 * ( yz - xw );
  109.         transformationmatrix[1][3] = 0.0;
  110.  
  111.         transformationmatrix[2][0] =     2 * ( xz - yw );
  112.         transformationmatrix[2][1] =     2 * ( yz + xw );
  113.         transformationmatrix[2][2] = 1 - 2 * ( xx + yy );
  114.         transformationmatrix[2][3] = 0;
  115.  
  116.         transformationmatrix[3][0] = 0;
  117.         transformationmatrix[3][1] = 0;
  118.         transformationmatrix[3][2] = 0;
  119.         transformationmatrix[3][3] = 1;
  120.  
  121.         adirection[2] = -1 * transformationmatrix[0][1] + transformationmatrix[0][3];
  122.         adirection[1] = -1 * transformationmatrix[1][1] + transformationmatrix[1][3];
  123.         adirection[0] = -(-1 * transformationmatrix[2][1] + transformationmatrix[2][3]);
  124.  
  125.         #if AutoRepair == 1
  126.         RepairVehicle(vehid);
  127.         #endif
  128.  
  129.         SetVehicleVelocity(vehid, adirection[0]*ccspeed[playerid], adirection[1]*ccspeed[playerid], adirection[2]*ccspeed[playerid]);
  130.         SetTimerEx("ccf", UPDATE_RATE, false, "i", playerid);
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment