Advertisement
Guest User

zeruel_angel

a guest
Apr 7th, 2008
4,238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.43 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. //
  3. //   Zombie Filter Script v1.2
  4. //   Designed for SA-MP v0.2.2
  5. //
  6. //   Created by zeruel_angel
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include <a_samp>
  11.  
  12. new currentObj[MAX_PLAYERS];
  13. new zombie[6];
  14. new Float:Zspeed = 5.0;
  15. new vaiven = 6;
  16. new ZTimerSpeed = 500;
  17.  
  18. new Float:X,Float:Y,Float:Z;
  19. enum zombiParts
  20. {
  21.     partModel,
  22.     Float:RelX,
  23.     Float:RelY,
  24.     Float:RelZ,
  25.     Float:RelrX,
  26.     Float:RelrY,
  27.     Float:RelrZ
  28. }
  29. new z1[6][zombiParts]=
  30. {
  31.     {2905,-0.115479,-0.023924, -1.280131, -90.000000, 90.000000,0.000000},
  32.     {2906, -0.218995, 0.200928, -0.253135, 0.000000, 180.000000, 0.000000},
  33.     {2907, -0.032227, -0.045897, -0.544213, 270.000000, 0.000000, 0.000000},
  34.     {2906, 0.187987, 0.158448, -0.265793, 0.000000, 0.000000, 0.000000},
  35.     {2908, 0.000000, 0.000000, 0.000000, 270.000000, 90.000000, 0.000000},
  36.     {2905, 0.101074, -0.012694, -1.288253, 270.000000, 90.000000, 0.000000}
  37. };
  38. new z2[6][zombiParts]=
  39. {
  40.     {2905, 0.005614, -0.110107, -1.280131, -90.000000, 90.000000, 90.000000},
  41.     {2906, -0.148926, -0.180663, -0.253135, 0.000000, 180.000000, 90.000000},
  42.     {2907, 0.047852, -0.039061, -0.544213, 270.000000, 0.000000, 90.000000},
  43.     {2906, -0.152343, 0.171387, -0.265793, 0.000000, 0.000000, 90.000000},
  44.     {2908, 0.000000, 0.000000, 0.000000, 270.000000, 90.000000, 90.000000},
  45.     {2905, 0.000977, 0.090332, -1.288253, 270.000000, 90.000000, 90.000000}
  46. };
  47. forward zombieAtaca(playerid);
  48. new TimerAtaca=-1;
  49. //------------------------------------------------------------------------------------------------------
  50. public OnFilterScriptInit()
  51. {
  52.     print("\n ZOMBIE Filter Script v1.2 Loading...\n**********************\n      (Zeruel_Angel)\n");
  53.     return 1;
  54. }
  55. //------------------------------------------------------------------------------------------------------
  56. public OnFilterScriptExit()
  57. {
  58.     print("\n*********** ZOMBIE (zeruel_angel) ***********\n");
  59.     return 1;
  60. }
  61. //------------------------------------------------------------------------------------------------------
  62.  strtok(const string[], &index)
  63. {
  64.     new length = strlen(string);
  65.     while ((index < length) && (string[index] <= ' '))
  66. {
  67.         index++;
  68. }
  69.  
  70.     new offset = index;
  71.     new result[20];
  72.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  73. {
  74.         result[index - offset] = string[index];
  75.         index++;
  76. }
  77.     result[index - offset] = EOS;
  78.     return result;
  79. }
  80. //------------------------------------------------------------------------------------------------------
  81. CrearZombie(Float:pX,Float:pY,Float:pZ,Float:angle)
  82. {
  83.     new Float:PEPE = floatsin((angle*3.14159/180.0));
  84.     new Float:PIPO = floatcos((angle*3.14159/180.0));
  85.     for (new i=0;i<6;i++)
  86.     {
  87.         zombie[i]=CreateObject(z1[i][partModel],pX+z1[i][RelX]*PIPO+PEPE*z2[i][RelX],pY+z1[i][RelY]*PIPO+PEPE*z2[i][RelY],pZ+z1[i][RelZ],z1[i][RelrX],z1[i][RelrY],angle);
  88.     }
  89.     return zombie[4];
  90. }
  91. //------------------------------------------------------------------------------------------------------
  92. ZombieLookPlayer(playerid)
  93. {
  94.     new Float:pX,Float:pY,Float:pZ,Float:angle;
  95.     GetPlayerPos(playerid,pX,pY,pZ);
  96.     GetObjectPos(zombie[4],X,Y,Z);
  97.     angle = 180.0-atan2(X-pX,Y-pY);
  98.     printf("%f",angle);
  99.     for (new i=0;i<6;i++)
  100.     {
  101.         DestroyObject(zombie[i]);
  102.     }
  103.     new Float:ran = float(random(6))-3.0;
  104.     CrearZombie(X,Y,Z,angle+ran);
  105.     return zombie[4];
  106. }
  107. //------------------------------------------------------------------------------------------------------
  108. public zombieAtaca(playerid)
  109. {
  110.     new Float:pX,Float:pY,Float:pZ,Float:angle;
  111.     GetPlayerPos(playerid,pX,pY,pZ);
  112.     GetObjectPos(zombie[4],X,Y,Z);
  113.     angle = 180.0-atan2(X-pX,Y-pY);
  114.     new Float:ran = float(random(vaiven)-vaiven/2);
  115.     angle=angle+ran;
  116.     new Float:PEPE = floatsin((angle*3.14159/180.0));
  117.     new Float:PIPO = floatcos((angle*3.14159/180.0));
  118.     for (new i=0;i<6;i++)
  119.     {
  120.         DestroyObject(zombie[i]);
  121.         zombie[i]=CreateObject(z1[i][partModel],X+z1[i][RelX]*PIPO+PEPE*z2[i][RelX],Y+z1[i][RelY]*PIPO+PEPE*z2[i][RelY],Z+z1[i][RelZ],z1[i][RelrX],z1[i][RelrY],angle);
  122.     }
  123.     for (new i=0;i<6;i++)
  124.     {
  125.         MoveObject(zombie[i],pX+z1[i][RelX]*PIPO+PEPE*z2[i][RelX],pY+z1[i][RelY]*PIPO+PEPE*z2[i][RelY],pZ+z1[i][RelZ]+0.7,Zspeed);
  126.     }
  127.     return 1;
  128. }
  129. //------------------------------------------------------------------------------------------------------
  130. public OnPlayerCommandText(playerid, cmdtext[])
  131. {
  132.     new cmd[256];
  133.     new tmp[255];
  134.     new idx;
  135.     cmd = strtok(cmdtext, idx);
  136.     if  (strcmp(cmd, "/zspeed", true)==0)
  137.     {
  138.         tmp = strtok(cmdtext, idx);
  139.         if  (!strlen(tmp))
  140.         {
  141.             SendClientMessage(playerid, 0xFFFFFFAA, "USE: /zspeed [velocidad]");
  142.             return 1;
  143.         }
  144.         Zspeed=floatstr(tmp);
  145.         return 1;
  146.     }
  147.     if  (strcmp(cmd, "/vaiven", true)==0)
  148.     {
  149.         tmp = strtok(cmdtext, idx);
  150.         if  (!strlen(tmp))
  151.         {
  152.             SendClientMessage(playerid, 0xFFFFFFAA, "USE: /vaiven [angulo]");
  153.             return 1;
  154.         }
  155.         vaiven=strval(tmp);
  156.         return 1;
  157.     }
  158.     if  (strcmp(cmd, "/ZTimerSpeed", true)==0)
  159.     {
  160.         tmp = strtok(cmdtext, idx);
  161.         if  (!strlen(tmp))
  162.         {
  163.             SendClientMessage(playerid, 0xFFFFFFAA, "USE: /ZTimerSpeed [timer speed]");
  164.             return 1;
  165.         }
  166.         ZTimerSpeed=strval(tmp);
  167.         OnPlayerCommandText(playerid, "/zstop");
  168.         OnPlayerCommandText(playerid, "/zstart");
  169.         return 1;
  170.     }
  171.     if (strcmp(cmd, "/zo", true)==0)
  172.     {
  173.         new Float:pX,Float:pY,Float:pZ,Float:Ang;
  174.         GetPlayerPos(playerid,pX,pY,pZ);
  175.         GetPlayerFacingAngle(playerid,Ang);
  176.         pX=pX+3.0*floatsin(-Ang,degrees);
  177.         pY=pY+3.0*floatcos(-Ang,degrees);
  178.         pZ=pZ+0.7;
  179.         currentObj[playerid]=CrearZombie(pX,pY,pZ,Ang+180.0);
  180.         format(tmp,sizeof(tmp),"The object ID is: %d",currentObj[playerid]);
  181.         SendClientMessage(playerid, 0xFFFFFFAA, tmp);
  182.         return 1;
  183.     }
  184.     if (strcmp(cmd, "/zlook", true)==0)
  185.     {
  186.         ZombieLookPlayer(playerid);
  187.         return 1;
  188.     }
  189.     if  (strcmp(cmd, "/zstart", true)==0)
  190.     {
  191.         if (IsValidObject(zombie[4]))
  192.         {
  193.             if (TimerAtaca!=-1)
  194.             {
  195.                 KillTimer(TimerAtaca);
  196.             }
  197.             TimerAtaca=SetTimerEx("zombieAtaca",ZTimerSpeed,1,"i",playerid);
  198.         }
  199.         else
  200.         {
  201.             SendClientMessage(playerid, 0xFFFFFFAA, "There are no zombie");
  202.             return 1;
  203.         }
  204.         return 1;
  205.     }
  206.     if  (strcmp(cmd, "/zstop", true)==0)
  207.     {
  208.         if (IsValidObject(zombie[4]))
  209.         {
  210.             if (TimerAtaca!=-1)
  211.             {
  212.                 KillTimer(TimerAtaca);
  213.             }
  214.         }
  215.         else
  216.         {
  217.             SendClientMessage(playerid, 0xFFFFFFAA, "There are no zombie");
  218.             return 1;
  219.         }
  220.         return 1;
  221.     }
  222.  
  223.     return 0;
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement