Guest User

Coco76

a guest
Nov 3rd, 2009
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.50 KB | None | 0 0
  1.                                                                                                                                                                                                                                               /*
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                                    BOTSpeedV.0.1.2
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                      ////////    ////////    ////////    ////////
  16.                     //          //    //    //          //    //
  17.                    //          //    //    //          //    //
  18.                   ////////    ////////    ////////    ////////
  19.  
  20.  
  21.  
  22.                              CR�ATION DE COCO76
  23.                               Cr�ated by COCO
  24.                              
  25. Merci � :
  26. sasuke78200 pour le r�glage de l'angle !
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                                                                                                                                                                                                                                                */
  35.  
  36. #include <a_samp>
  37.  
  38. #define BOT_DISTANCE 0.6
  39. #define BOT_CALC 100
  40.  
  41. new Float:posar[3][MAX_PLAYERS];
  42. new SpeedBotUse[MAX_PLAYERS];
  43.  
  44. forward BotPlayerToPoint(Float:radi, botid, Float:x, Float:y, Float:z);
  45. forward SpeedBot(botid);
  46.  
  47. stock SetAngleBot(botid,Float:x,Float:y,&Float:z)
  48. {
  49.     new Float:xo,Float:yo,Float:zo;
  50.     GetPlayerPos(botid,xo,yo,zo);
  51.     x = x -xo;
  52.     y = y -yo;
  53.     new Float:Rot = atan2(y,x);
  54.     SetPlayerFacingAngle(botid,Rot+270);
  55. }
  56.  
  57. stock SetBotSpeed(botid,Float:x,Float:y,&Float:z)
  58. {
  59.     posar[0][botid]=x;
  60.     posar[1][botid]=y;
  61.     posar[2][botid]=z;
  62.     new Float:xo,Float:yo,Float:zo;
  63.     GetPlayerPos(botid,xo,yo,zo);
  64.     SetAngleBot(botid,x,y,z);
  65.     GetXYInFrontOfBot(botid,xo,yo,BOT_DISTANCE);
  66.     if(SpeedBotUse[botid]==0)
  67.     {
  68.         SetTimerEx("SpeedBot",BOT_CALC,0,"d",botid);
  69.     }
  70.     SpeedBotUse[botid]=1;
  71.  
  72.     ApplyAnimation(botid,"PED","WALK_player",4.1,1,1,1,1,1);
  73.  
  74. }
  75.  
  76. stock StopBotSpeed(botid)
  77. {
  78.     SpeedBotUse[botid]=0;
  79.     ApplyAnimation(botid,"PED","WALK_player",4.0,0,0,0,0,1);
  80. }
  81.  
  82. stock GetXYInFrontOfBot(botid,&Float:x,&Float:y,Float:dis)
  83. {
  84.     new Float:pos[3];
  85.     new Float:A;
  86.     GetPlayerPos(botid,pos[0],pos[1],pos[2]);
  87.     GetPlayerFacingAngle(botid,A);
  88.     GetXYInFrontOfPointBot(botid,pos[0],pos[1],x,y,A,dis);
  89. }
  90.  
  91. stock GetXYInFrontOfPointBot(botid,Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance)
  92. {
  93.     new Float:pos[3];
  94.     x2 = x + (distance * floatsin(-A,degrees));
  95.     y2 = y + (distance * floatcos(-A,degrees));
  96.  
  97.     GetPlayerPos(botid,pos[0],pos[1],pos[2]);
  98.     SetPlayerPos(botid,x2,y2,pos[2]);
  99. }
  100.  
  101. public SpeedBot(botid)
  102. {
  103.     if(SpeedBotUse[botid]==1)
  104.     {
  105.         if(BotPlayerToPoint(BOT_DISTANCE,botid,posar[0][botid],posar[1][botid],posar[2][botid]))
  106.         {
  107.             SpeedBotUse[botid]=0;
  108.             ApplyAnimation(botid,"PED","WALK_player",4.0,0,0,0,0,1);
  109.         }
  110.         else
  111.         {
  112.             new Float:pos[3];
  113.             GetPlayerPos(botid,pos[0],pos[1],pos[2]);
  114.             GetXYInFrontOfBot(botid,pos[0],pos[1],BOT_DISTANCE);
  115.             SetTimerEx("SpeedBot",BOT_CALC,0,"d",botid);
  116.         }
  117.  
  118.  
  119.  
  120.     }
  121. }
  122.  
  123. public BotPlayerToPoint(Float:radi, botid, Float:x, Float:y, Float:z)
  124. {
  125.     if(IsPlayerConnected(botid))
  126.     {
  127.         new Float:oldposx, Float:oldposy, Float:oldposz;
  128.         new Float:tempposx, Float:tempposy, Float:tempposz;
  129.         GetPlayerPos(botid, oldposx, oldposy, oldposz);
  130.         tempposx = (oldposx -x);
  131.         tempposy = (oldposy -y);
  132.         tempposz = (oldposz -z);
  133.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  134.         {
  135.             return 1;
  136.         }
  137.     }
  138.     return 0;
  139. }
  140.  
  141.  
Advertisement
Add Comment
Please, Sign In to add comment