OtaconEvil

[FS] System of Twin (99% functional) | By OTACON

May 29th, 2016
597
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     * ## LEASE ATENTAMENTE PARA NO CONVERTIRSE EN LAMMER!!.: :D ##
  3.     *
  4.     * Estè Simple FILTERSCRIPT esta hecho especialmente para www.forum.sa-mp.com
  5.     * NO Publicar estè FILTERSCRIPT en Otros foros de SA-MP y hacerse pasar por el creador del CODE.
  6.     *
  7.     * Codigo Creado Por OTACON
  8.     *
  9.     * CREDITOS:
  10.     *     OTACON: Realizacion y Idea de creacion del code.
  11.     *     TÙ: Modificacion libremente respetando lo mencionado ;).
  12.     *
  13.     *    NOTA: Menos Creditos para los que me los critican.. JO'PUTAS! :D xD ;)
  14.     *
  15.     *                Prohibido TOTALMENTE el Robo de Créditos o la
  16.     *                  Publicación de este FILTERSCRIPT sin Mi Permiso.
  17. */
  18. /*
  19.     * ## READ CAREFULLY TO AVOID BECOMING LAMMER!.: :D ##
  20.     *
  21.     * This simple FILTERSCRIPT is made especially for www.forum.sa-mp.com
  22.     * DO NOT Post the FILTERSCRIPT in Other SAMP forums and impersonating the creator of the CODE.
  23.     *
  24.     * Code Created By OTACON
  25.     *
  26.     * CREDITS:
  27.     *     OTACON: Idea Making and code creation.
  28.     *     YOUR: Modification freely respecting the above ;).
  29.     *
  30.     *    NOTE: Less Credits for those who criticize me.. JO'PUTAS! :D xD ;)
  31.     *
  32.     *                        FULLY spaces Theft Credit or
  33.     *                 Publication of this FILTERSCRIPT without my permission.
  34. */
  35.  
  36. /*
  37. http://i.imgur.com/2e5mYe6.png
  38. */
  39.  
  40.  
  41. #include <a_samp>
  42. #include <zcmd>
  43.  
  44. enum twin{
  45.     bool:dActive,
  46.     bool:dInvulnerable,
  47.     Float:dHealth,
  48.     Float:dPos[4],
  49.     dWorld,
  50.     dTwin,
  51.     dTimer,
  52.     bool:dSale,
  53.     dName[30],
  54. };
  55. new InfoTwin[MAX_PLAYERS][twin];
  56.  
  57. COMMAND:twin(playerid,params[]){
  58.     new Float:pos[5],
  59.         VirtualWorld,
  60.         pname[24],str[100];
  61.     GetPlayerName(playerid,pname,sizeof(pname));
  62.    
  63.     if(InfoTwin[playerid][dSale]){
  64.         if(!InfoTwin[playerid][dActive]){
  65.             InfoTwin[playerid][dActive] = true;
  66.             DestroyActor(InfoTwin[playerid][dTwin]);
  67.             InfoTwin[playerid][dTwin] = CreateActor(GetPlayerSkin(playerid),0,0,0,0);
  68.             SetActorPos(InfoTwin[playerid][dTwin], InfoTwin[playerid][dPos][0], InfoTwin[playerid][dPos][1], InfoTwin[playerid][dPos][2]);
  69.             SetActorFacingAngle(InfoTwin[playerid][dTwin], InfoTwin[playerid][dPos][3]);
  70.             SetActorHealth(InfoTwin[playerid][dTwin], InfoTwin[playerid][dHealth]);
  71.             SetActorVirtualWorld(InfoTwin[playerid][dTwin], InfoTwin[playerid][dWorld]);
  72.             SetActorInvulnerable(InfoTwin[playerid][dTwin], InfoTwin[playerid][dInvulnerable]);
  73.             KillTimer(InfoTwin[playerid][dTimer]);
  74.             ApplyActorAnimation(InfoTwin[playerid][dTwin], "CARRY","null",0,0,0,0,0,0);
  75.             InfoTwin[playerid][dTimer] = SetTimerEx("update_twin",170,true,"i",playerid);
  76.            
  77.             // SendClientMessage(playerid,-1,"{FFFFFF}INFO: {00B100}sistema de gemelo encendido{FFFFFF}!.");
  78.             PlayerPlaySound(playerid,21000,0,0,0);
  79.         }else{
  80.             InfoTwin[playerid][dActive] = false;
  81.             GetActorPos(InfoTwin[playerid][dTwin], pos[0],pos[1],pos[2]);
  82.             GetActorFacingAngle(InfoTwin[playerid][dTwin], pos[3]);
  83.             GetActorHealth(InfoTwin[playerid][dTwin], pos[4]);
  84.             VirtualWorld = GetActorVirtualWorld(InfoTwin[playerid][dTwin]);
  85.  
  86.             InfoTwin[playerid][dPos][0] = pos[0], InfoTwin[playerid][dPos][1] = pos[1], InfoTwin[playerid][dPos][2] = pos[2];
  87.             InfoTwin[playerid][dPos][3] = pos[3];
  88.             InfoTwin[playerid][dHealth] = pos[4];
  89.             InfoTwin[playerid][dWorld] = VirtualWorld;
  90.             InfoTwin[playerid][dInvulnerable] = InfoTwin[playerid][dInvulnerable];
  91.             InfoTwin[playerid][dSale] = InfoTwin[playerid][dSale];
  92.  
  93.             DestroyActor(InfoTwin[playerid][dTwin]);
  94.             KillTimer(InfoTwin[playerid][dTimer]);
  95.             // SendClientMessage(playerid,-1,"{FFFFFF}INFO: {B00000}sistema de gemelo apagado{FFFFFF}!.");
  96.             PlayerPlaySound(playerid,21000,0,0,0);
  97.         }
  98.     }else{
  99.         GetPlayerPos(playerid, pos[0],pos[1],pos[2]);
  100.         GetPlayerFacingAngle(playerid, pos[3]);
  101.         GetPlayerHealth(playerid, pos[4]);
  102.         VirtualWorld = GetPlayerVirtualWorld(playerid);
  103.  
  104.         pos[0] -= (2.0 * floatsin(-pos[4], degrees));
  105.         pos[1] -= (2.0 * floatcos(-pos[4], degrees));
  106.         InfoTwin[playerid][dPos][0] = pos[0], InfoTwin[playerid][dPos][1] = pos[1], InfoTwin[playerid][dPos][2] = pos[2];
  107.         InfoTwin[playerid][dPos][3] = pos[3];
  108.         InfoTwin[playerid][dHealth] = pos[4];
  109.         InfoTwin[playerid][dWorld] = VirtualWorld;
  110.         InfoTwin[playerid][dInvulnerable] = false;
  111.         format(InfoTwin[playerid][dName],30,"%s Jr.", pname);
  112.  
  113.         InfoTwin[playerid][dSale] = true;
  114.         /* SendClientMessage(playerid,-1,"{FFFFFF}INFO: {00B7FF}usted ha generado un gemelo, enhorabuena{FFFFFF}!.");
  115.         format(str,sizeof(str),"{FFFFFF}INFO: {00B7FF}el nombre del gemelo es: {FFFFFF}%s", InfoTwin[playerid][dName]);
  116.         SendClientMessage(playerid,-1,str); */
  117.         PlayerPlaySound(playerid,21000,0,0,0);
  118.     }
  119.     return true;
  120. }
  121.  
  122. forward update_twin(playerid);
  123. public update_twin(playerid){
  124.     if(IsValidActor(InfoTwin[playerid][dTwin]) && InfoTwin[playerid][dSale]){
  125.         static Float:pos[4],
  126.             VirtualWorld,
  127.             vehicleid,
  128.             animlib[32],animname[32];
  129.         GetAnimationName(GetPlayerAnimationIndex(playerid), animlib, sizeof(animlib), animname, sizeof(animname));
  130.        
  131.         vehicleid = GetPlayerVehicleID(playerid);
  132.         if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, pos[0], pos[1], pos[2]), GetPlayerFacingAngle(playerid, pos[3]), VirtualWorld = GetPlayerVirtualWorld(playerid);
  133.         else GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]), GetVehicleZAngle(vehicleid, pos[3]), VirtualWorld = GetVehicleVirtualWorld(vehicleid);
  134.         if(!IsPlayerInAnyVehicle(playerid)) pos[0] -= (2 * floatsin(-pos[3], degrees)), pos[1] -= (2 * floatcos(-pos[3], degrees));
  135.         else pos[0] -= (10 * floatsin(-pos[3], degrees)), pos[1] -= (10 * floatcos(-pos[3], degrees));
  136.        
  137.         SetActorPos(InfoTwin[playerid][dTwin], pos[0], pos[1], pos[2]);
  138.         SetActorVirtualWorld(InfoTwin[playerid][dTwin], VirtualWorld);
  139.         static Float:asd[2][3];
  140.         GetPlayerCameraPos(playerid, asd[1][0],asd[1][1],asd[1][2]);
  141.         GetPlayerCameraFrontVector(playerid, asd[0][0],asd[0][1],asd[0][2]);
  142.         SetActorToFacePos(InfoTwin[playerid][dTwin], asd[0][0] + asd[1][0], asd[0][1]+asd[1][1]);
  143.        
  144.         ApplyActorAnimation(InfoTwin[playerid][dTwin], "CARRY","crry_prtial",0,0,0,0,0,0);
  145.         if(IsPlayerInVehicle(playerid, GetPlayerVehicleID(playerid)){ ApplyActorAnimation(InfoTwin[playerid][dTwin], "PED","sprint_civi",4.1,0,1,1,1,1);
  146.         }else ApplyActorAnimation(InfoTwin[playerid][dTwin], animlib,animname,4.1,0,1,1,1,1);
  147.     }
  148. }
  149.  
  150. forward Float:SetActorToFacePos(actorid, Float:X, Float:Y);
  151. public Float:SetActorToFacePos(actorid, Float:X, Float:Y){
  152.     new Float:pX, Float:pY, Float:pZ, Float:ang;
  153.     if(!IsValidActor(actorid)) return 0.0;
  154.     GetActorPos(actorid, pX, pY, pZ);
  155.     if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  156.     else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
  157.     else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
  158.     if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
  159.     else ang = (floatabs(ang) - 180.0);
  160.     ang += 180.0;
  161.     SetActorFacingAngle(actorid, ang);
  162.     SetActorFacingAngle(actorid, ang);
  163.     return ang;
  164. }
  165.  
  166. public OnFilterScriptInit(){
  167.     AddPlayerClass(23,1916.1304,-1367.8215,13.6492,99.3507,0,0,0,0,0,0); //
  168.     return true;
  169. }
RAW Paste Data