Guest User

[SAMP] Deer Hunting v1.02 by Dinnozor -fixed

a guest
Jan 4th, 2013
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.87 KB | None | 0 0
  1. /*
  2. Deer Hunting v1.02 for SAMP - by Dinnozor
  3. English Version
  4.  
  5. Hunt deers in the country near LS !
  6.  
  7. v1.02 fixes :
  8. -Greatly increased the accuracy ; added a parameter to IsPlayerAimingPoint function (weapon)
  9. -Another orientation problem corrected
  10. -Added a condition in the OnPlayerUpdate (which you can actually replace by a callback called less frequently) so there won't be loops on every update
  11.  
  12. v1.01 fixes :
  13. -Use of GetPlayerCameraFrontVector instead of GetPlayerFacingAngle : checks the Z coord, you can't "cheat" only using your facing angle :)
  14. -Modified the FinDeer function because it had a bug when you picked the meat. If you clicked several times on LMB you could take more. -Fixed
  15. -Corrected a bug of the deer orientation during its movement
  16. -a few little bugs fixed
  17.  
  18. Please don't remove credits if shared. Modify, customize and use as you want to.
  19. Enjoy !
  20. */
  21.  
  22. #include <a_samp>
  23.  
  24. #include <streamer>
  25. #include <OPVD>
  26.  
  27. #define MAX_ANIM 20
  28. #define DEER_SPAWN_LOC 21
  29.  
  30. // HOLDING(keys)
  31. #define HOLDING(%0) \
  32. ((newkeys & (%0)) == (%0))
  33.  
  34. forward MovingDeer(DeerID);
  35. forward DestroyDeer(DeerID);
  36. forward FinDeer(DeerID,playerid);
  37.  
  38. forward Float:Distance(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB);
  39.  
  40. new Deers[MAX_ANIM],DeerKO[MAX_ANIM],DeerObject[MAX_ANIM];
  41. new DeerMeat[MAX_ANIM],InfectedDeer[MAX_ANIM],DeerMove[MAX_ANIM],MeatPick[MAX_PLAYERS];
  42. new gPlayerUsingLoopingAnim[MAX_PLAYERS];
  43.  
  44. enum pInfo
  45. {
  46.     Viande,
  47.     AdminLvl//Replace with yoour own variables ("Viande" means "meat")
  48. }
  49. ;
  50. new PlayerInfo[MAX_PLAYERS][pInfo];
  51.  
  52. //Spawn Locations for deers. Of course, if you add areas below, add at least a spawning location for every added area, or the deers will never be belo them...
  53. //You can add as many spawning locations as you want. You just need to replace the DEER_SPAWN_LOC in the top of the script by the actual number of locations (originally it is 21)
  54.  
  55. new Float:DeerSpawn[DEER_SPAWN_LOC][3]=
  56. {
  57.    
  58.    
  59.    
  60.    
  61.     {
  62.         -604.803588,-1308.452636,22.106567
  63.        
  64.        
  65.        
  66.     }
  67.     ,
  68.    
  69.    
  70.    
  71.    
  72.     {
  73.         -702.036621,-1309.305297,63.694377
  74.        
  75.        
  76.        
  77.     }
  78.     ,
  79.    
  80.    
  81.    
  82.    
  83.     {
  84.         -630.591491,-889.400268,108.452827
  85.        
  86.        
  87.        
  88.     }
  89.     ,
  90.    
  91.    
  92.    
  93.    
  94.     {
  95.         -992.249938,-930.179138,129.602951
  96.        
  97.        
  98.        
  99.     }
  100.     ,
  101.    
  102.    
  103.    
  104.    
  105.     {
  106.         -935.597717,-1146.799194,129.202728
  107.        
  108.        
  109.        
  110.     }
  111.     ,
  112.    
  113.    
  114.    
  115.    
  116.     {
  117.         -394.224884,87.232124,28.368480
  118.        
  119.        
  120.        
  121.     }
  122.     ,
  123.    
  124.    
  125.    
  126.    
  127.     {
  128.         -636.897583,-92.761047,64.660194
  129.        
  130.        
  131.        
  132.     }
  133.     ,
  134.    
  135.    
  136.    
  137.    
  138.     {
  139.         -2447.039794,-2192.797851,28.498489
  140.        
  141.        
  142.        
  143.     }
  144.     ,
  145.    
  146.    
  147.    
  148.    
  149.     {
  150.         -2224.478759,-2367.201416,32.494483
  151.        
  152.        
  153.        
  154.     }
  155.     ,
  156.    
  157.    
  158.    
  159.    
  160.     {
  161.         -1803.133300,-2423.008789,26.044141
  162.        
  163.        
  164.        
  165.     }
  166.     ,
  167.    
  168.    
  169.    
  170.    
  171.     {
  172.         -1690.161499,-2070.091308,42.189098
  173.        
  174.        
  175.        
  176.     }
  177.     ,
  178.    
  179.    
  180.    
  181.    
  182.     {
  183.         2006.325439,-766.786865,131.285568
  184.        
  185.        
  186.        
  187.     }
  188.     ,
  189.    
  190.    
  191.    
  192.    
  193.     {
  194.         -1817.458251,-1867.854980,86.802558
  195.        
  196.        
  197.        
  198.     }
  199.     ,
  200.    
  201.    
  202.    
  203.    
  204.     {
  205.         2176.190429,-897.414916,84.565956
  206.        
  207.        
  208.        
  209.     }
  210.     ,
  211.    
  212.    
  213.    
  214.    
  215.     {
  216.         2647.276855,-840.732543,70.997520
  217.        
  218.        
  219.        
  220.     }
  221.     ,
  222.    
  223.    
  224.    
  225.    
  226.     {
  227.         2601.860351,-436.280792,73.739181
  228.        
  229.        
  230.        
  231.     }
  232.     ,
  233.    
  234.    
  235.    
  236.    
  237.     {
  238.         2365.430664,-356.828186,59.507225
  239.        
  240.        
  241.        
  242.     }
  243.     ,
  244.    
  245.    
  246.    
  247.    
  248.     {
  249.         927.202453,-10.505444,91.440376
  250.        
  251.        
  252.        
  253.     }
  254.     ,
  255.    
  256.    
  257.    
  258.    
  259.     {
  260.         1092.987304,15.023153,68.779556
  261.        
  262.        
  263.        
  264.     }
  265.     ,
  266.    
  267.    
  268.    
  269.    
  270.     {
  271.         1504.512084,192.802429,22.368137
  272.        
  273.        
  274.        
  275.     }
  276.     ,
  277.    
  278.    
  279.    
  280.    
  281.     {
  282.         1083.728637,362.787322,25.921319
  283.        
  284.        
  285.        
  286.     }
  287. }
  288. ;
  289.  
  290. public OnGameModeInit()
  291. {
  292.     for(new i=0;i<MAX_ANIM;i++)
  293.    
  294.    
  295.    
  296.     {
  297.         new rand=random(DEER_SPAWN_LOC);
  298.         new Float:X=DeerSpawn[rand][0];
  299.         new Float:Y=DeerSpawn[rand][1];
  300.         CreateDeer(X,Y);
  301.        
  302.        
  303.        
  304.        
  305.     }
  306.     return 1;
  307. }
  308.  
  309. public OnPlayerConnect(playerid)
  310. {
  311.     MeatPick[playerid]=0;
  312.     gPlayerUsingLoopingAnim[playerid]=0;
  313.     return 1;
  314. }
  315.  
  316. //You need the MapAndreas Include (see my post on SAMP Forums for the link)
  317. stock Float: GetPointZPos(const Float: fX, const Float: fY, &Float: fZ = 0.0)
  318. {
  319.     if(!((-3000.0 < fX < 3000.0) && (-3000.0 < fY < 3000.0)))
  320.    
  321.    
  322.     {
  323.         return 0.0;
  324.        
  325.        
  326.        
  327.     }
  328.     static
  329.     File: s_hMap
  330.     ;
  331.     if(!s_hMap)
  332.    
  333.    
  334.     {
  335.         s_hMap = fopen("SAfull.hmap", io_read);
  336.        
  337.         if(!s_hMap)
  338.        
  339.        
  340.         {
  341.             return 0.0;
  342.            
  343.            
  344.            
  345.         }
  346.        
  347.        
  348.        
  349.     }
  350.     new
  351.     afZ[1]
  352.     ;
  353.     fseek(s_hMap, ((6000 * (-floatround(fY, floatround_tozero) + 3000) + (floatround(fX, floatround_tozero) + 3000)) << 1));
  354.     fblockread(s_hMap, afZ);
  355.    
  356.     return (fZ = ((afZ[0] >>> 16) * 0.01));
  357. }
  358.  
  359. stock IsPlayerAimingPoint(playerid, Float:X2,Float:Y2,Float:Z2, Float:range,Float:accuracy,weapon=0)
  360. {
  361.     new Float:Dist, Float:xv,Float:yv,Float:zv,Float:xc,Float:yc,Float:zc,Float:xt,Float:yt,Float:zt,Float:wDis,Float:AngleD;
  362.     GetPlayerCameraPos(playerid,xc,yc,zc);
  363.     GetPlayerCameraFrontVector(playerid,xv,yv,zv);
  364.    
  365.     xt=xc+range*xv;
  366.     yt=yc+range*yv;
  367.     zt=range*zv+zc;
  368.    
  369.     switch(weapon)
  370.    
  371.     {
  372.         case 34:
  373.        
  374.         {
  375.             AngleD=0;
  376.             wDis=100;
  377.            
  378.            
  379.         }
  380.         case 33:
  381.        
  382.         {
  383.             AngleD=3;
  384.             wDis=90;
  385.            
  386.            
  387.         }
  388.         case 30,31:
  389.        
  390.         {
  391.             AngleD=4;
  392.             wDis=70;
  393.            
  394.            
  395.         }
  396.         case 22..24:
  397.        
  398.         {
  399.             AngleD=6;
  400.             wDis=40;
  401.            
  402.            
  403.         }
  404.         case 25..27:
  405.        
  406.         {
  407.             AngleD=4;
  408.             wDis=25;
  409.            
  410.            
  411.         }
  412.         default:
  413.        
  414.         {
  415.             AngleD=6;
  416.             wDis=50;
  417.            
  418.            
  419.         }
  420.        
  421.        
  422.     }
  423.     Dist=floatsqroot(floatpower(floatabs(xt-X2), 2) + floatpower(floatabs(yt-Y2), 2)+floatpower(floatabs(range*floattan(AngleD,degrees)+zt-Z2),2));
  424.    
  425.     if (Dist<=accuracy&&wDis>=range) return true;
  426.     return false;
  427. }
  428.  
  429. public Float:Distance(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB)
  430. {
  431.     new Float:Dist=floatsqroot((xB-xA)*(xB-xA)+(yB-yA)*(yB-yA)+(zB-zA)*(zB-zA));
  432.     return Dist;
  433. }
  434.  
  435. public OnPlayerUpdate(playerid)//Or whatever equivalent function called frequently (like your own Update function)
  436. {
  437.     new Float:xP,Float:yP,Float:zP;
  438.     GetPlayerPos(playerid,xP,yP,zP);
  439.     if(IsPosInDeerZone(xP,yP))
  440.    
  441.     {
  442.         for(new i=0;i<MAX_ANIM;i++)
  443.        
  444.        
  445.         {
  446.             if(IsValidDynamicObject(DeerObject[i])&&Deers[i]>0)
  447.            
  448.            
  449.            
  450.             {
  451.                 new Float:xd,Float:yd,Float:zd;
  452.                 GetDynamicObjectPos(DeerObject[i],xd,yd,zd);
  453.                 if(IsPlayerInAnyVehicle(playerid))
  454.                
  455.                
  456.                
  457.                 {
  458.                     new mod=GetVehicleModel(GetPlayerVehicleID(playerid)); if(mod!=509&&mod!=510&&mod!=481)
  459.                    
  460.                    
  461.                    
  462.                     {
  463.                         if(IsPlayerInRangeOfPoint(playerid,25,xd,yd,zd))
  464.                        
  465.                        
  466.                        
  467.                         {
  468.                             MovingDeer(i);
  469.                            
  470.                            
  471.                            
  472.                            
  473.                         }
  474.                        
  475.                        
  476.                        
  477.                        
  478.                     }
  479.                     else
  480.                    
  481.                    
  482.                    
  483.                     {
  484.                         if(IsPlayerInRangeOfPoint(playerid,10,xd,yd,zd))
  485.                        
  486.                        
  487.                        
  488.                         {
  489.                             MovingDeer(i);
  490.                            
  491.                            
  492.                            
  493.                            
  494.                         }
  495.                        
  496.                        
  497.                        
  498.                        
  499.                     }
  500.                    
  501.                    
  502.                    
  503.                    
  504.                 }
  505.                 else if(IsPlayerInRangeOfPoint(playerid,2,xd,yd,zd)&&InfectedDeer[i]==1&&DeerKO[i]==0&&random(15)==0)
  506.                
  507.                
  508.                
  509.                 {
  510.                     new Float:phealth;
  511.                     GetPlayerHealth(playerid,phealth);
  512.                     SetPlayerHealth(playerid,floatround(phealth-1,floatround_round));
  513.                     OnePlayAnim(playerid,"ped","HIT_wall",4,0,1,1,0,0);
  514.                     GameTextForPlayer(playerid,"A deer is attacking you !",3000,6);
  515.                    
  516.                    
  517.                    
  518.                    
  519.                 }
  520.                 else
  521.                
  522.                
  523.                
  524.                 {
  525.                     if(IsPlayerInRangeOfPoint(playerid,15,xd,yd,zd))
  526.                    
  527.                    
  528.                    
  529.                     {
  530.                        
  531.                         if(InfectedDeer[i]==1&&DeerKO[i]==0&&DeerMove[i]==0)
  532.                        
  533.                        
  534.                        
  535.                         {
  536.                             new Float:xp,Float:yp,Float:zp,Float:Angle;
  537.                             GetPlayerPos(playerid,xp,yp,zp);
  538.                             GetPointZPos(xp,yp,zp);
  539.                             if(IsPosInDeerZone(xp,yp))
  540.                            
  541.                            
  542.                            
  543.                             {
  544.                                 DeerMove[i]=1;
  545.                                 if((xp-xd)>0&&(yp-yd)>0)Angle=atan((yp-yd)/(xp-xd));
  546.                                 else Angle=atan((yp-yd)/(xp-xd))-180;
  547.                                 switch(random(2))
  548.                                
  549.                                
  550.                                
  551.                                 {
  552.                                     case 0:MoveDynamicObject(DeerObject[i],xp-1,yp,zp+0.3,8,0,0,Angle);
  553.                                     case 1:MoveDynamicObject(DeerObject[i],xp,yp-1,zp+0.3,10,0,0,Angle);
  554.                                    
  555.                                    
  556.                                 }
  557.                                
  558.                                
  559.                                
  560.                                
  561.                             }
  562.                             else MovingDeer(i);
  563.                            
  564.                            
  565.                            
  566.                            
  567.                         }
  568.                         else MovingDeer(i);
  569.                        
  570.                        
  571.                        
  572.                        
  573.                     }
  574.                    
  575.                    
  576.                    
  577.                    
  578.                 }
  579.                
  580.                
  581.                
  582.                
  583.             }
  584.            
  585.            
  586.            
  587.         }
  588.        
  589.     }
  590.     new iCurWeap = GetPlayerWeapon(playerid);
  591.     new iCurAmmo = GetPlayerAmmo(playerid);
  592.     if(iCurWeap==GetPVarInt(playerid,"iCurrentWeapon")&&iCurAmmo!=GetPVarInt(playerid,"iCurrentAmmo"))
  593.    
  594.    
  595.     {
  596.         OnPlayerShoot(playerid,GetPVarInt(playerid, "iCurrentAmmo"), iCurAmmo,iCurWeap);
  597.         SetPVarInt(playerid,"iCurrentAmmo",iCurAmmo);
  598.        
  599.        
  600.        
  601.     }
  602.     return 1;
  603. }
  604.  
  605. stock OnPlayerShoot(playerid,oldammo,newammo,weapon)
  606. {
  607.     for (new i=0;i<MAX_ANIM;i++)
  608.    
  609.    
  610.    
  611.     {
  612.         new Float:X,Float:Y,Float:Z,Float:rx,Float:ry,Float:rz,Float:Z2,Float:xp,Float:yp,Float:zp;
  613.         GetDynamicObjectPos(DeerObject[i],X,Y,Z);
  614.         if(IsPlayerInRangeOfPoint(playerid,100,X,Y,Z))
  615.        
  616.        
  617.         {
  618.             GetPlayerCameraPos(playerid,xp,yp,zp);
  619.             new Float:Dist=Distance(xp,yp,zp,X,Y,Z);
  620.            
  621.             if(IsPlayerAimingPoint(playerid,X,Y,Z,Dist,1.50,GetPlayerWeapon(playerid)))
  622.            
  623.            
  624.            
  625.             {
  626.                 GetDynamicObjectRot(DeerObject[i],rx,ry,rz);
  627.                 GetPointZPos(X,Y,Z2);
  628.                 MoveDynamicObject(DeerObject[i],X+0.1,Y,Z2+0.15,0.4,90,0,rz);
  629.                 switch(GetPlayerWeapon(playerid))
  630.                
  631.                
  632.                
  633.                 {
  634.                     case 22,23,33,34:DeerMeat[i]--;
  635.                     case 25..27:DeerMeat[i]-=3;
  636.                     default:DeerMeat[i]-=2;
  637.                    
  638.                    
  639.                    
  640.                    
  641.                 }
  642.                 DeerKO[i]=1;
  643.                
  644.                
  645.                
  646.                
  647.             }
  648.            
  649.             else
  650.            
  651.            
  652.            
  653.             {
  654.                 if(IsPlayerInRangeOfPoint(playerid,45,X,Y,Z)) MovingDeer(i);//Shooting will frighten near deers
  655.                
  656.                
  657.                
  658.             }
  659.            
  660.            
  661.            
  662.         }
  663.        
  664.        
  665.        
  666.     }
  667. }
  668.  
  669. public OnPlayerCommandText(playerid,cmdtext[])
  670. {
  671.     if (!strcmp(cmdtext,"/resetdeers",true))
  672.    
  673.    
  674.    
  675.    
  676.     {
  677.         if (PlayerInfo[playerid][AdminLvl]<1) SendClientMessage(playerid,COLOR_RED,"You are not allowed to use this command.");
  678.         else
  679.        
  680.        
  681.        
  682.         {
  683.             for(new i=0;i<MAX_ANIM;i++)
  684.            
  685.            
  686.            
  687.             {
  688.                 DestroyDeer(i);
  689.                 new rand=random(DEER_SPAWN_LOC);
  690.                 new Float:X=DeerSpawn[rand][0];
  691.                 new Float:Y=DeerSpawn[rand][1];
  692.                 CreateDeer(X,Y);
  693.                
  694.                
  695.                
  696.                
  697.             }
  698.            
  699.            
  700.            
  701.            
  702.         }
  703.         return 1;
  704.        
  705.        
  706.        
  707.        
  708.     }
  709.     return 0;
  710. }
  711.  
  712. stock CreateDeer(Float:X,Float:Y)
  713. {
  714.     new DeerID=-1;
  715.     for (new i=0;i<MAX_ANIM;i++)
  716.    
  717.    
  718.    
  719.     {
  720.         if(Deers[i]==0)
  721.        
  722.        
  723.        
  724.         {
  725.             DeerID=i;
  726.             i=MAX_ANIM;
  727.            
  728.            
  729.            
  730.            
  731.         }
  732.        
  733.        
  734.        
  735.        
  736.     }
  737.     if(DeerID!=-1)
  738.    
  739.    
  740.    
  741.     {
  742.         new Float:Z;
  743.         GetPointZPos(X,Y,Z);
  744.         DeerObject[DeerID]=CreateDynamicObject(19315,X,Y,Z+1,0,0,0,-1,-1,-1,300);
  745.         Deers[DeerID]=1;
  746.         DeerMeat[DeerID]=5+random(10);
  747.         DeerKO[DeerID]=0;
  748.         MovingDeer(DeerID);
  749.         if(random(100)<3) InfectedDeer[DeerID]=1;//Here it will "infect" 3% of the deers. If you don't want any "crazy" deer, just replace these lines with "InfectedDeer[DeerID]=0;". You can also change the 3%, just replace the 3...
  750.         else InfectedDeer[DeerID]=0;
  751.        
  752.        
  753.        
  754.        
  755.     }
  756. }
  757.  
  758. public DestroyDeer(DeerID)
  759. {
  760.     DeerMeat[DeerID]=0;
  761.     Deers[DeerID]=0;
  762.     DestroyDynamicObject(DeerObject[DeerID]);
  763.     return 1;
  764. }
  765.  
  766. public MovingDeer(DeerID)
  767. {
  768.     if(DeerKO[DeerID]==0&&DeerMove[DeerID]==0)
  769.    
  770.    
  771.    
  772.     {
  773.         new Float:X,Float:Y,Float:Z,Float:Xrand,Float:Yrand,Float:Zrand,Float:speedRand,Float:Angle,Float:coef,Float:X2,Float:Y2;
  774.         GetDynamicObjectPos(DeerObject[DeerID],X,Y,Z);
  775.         new rand1=random(2),rand2=random(2);
  776.         if(rand1==0) Xrand=X+10+float(random(10));
  777.         else Xrand=X-10-float(random(10));
  778.         if(rand2==0) Yrand=Y+10+float(random(10));
  779.         else Yrand=Y-10-float(random(10));
  780.         Zrand=GetPointZPos(Xrand,Yrand,Zrand);
  781.         speedRand=7+float(random(9));
  782.         if((Xrand-X)>0&&(Yrand-Y)>0)Angle=atan((Yrand-Y)/(Xrand-X));
  783.         else Angle=atan((Yrand-Y)/(Xrand-X))-180;
  784.        
  785.         if(floatabs(Zrand-Z)<3.0)
  786.        
  787.        
  788.        
  789.         {
  790.             if(IsPosInDeerZone(Xrand,Yrand))
  791.            
  792.            
  793.            
  794.             {
  795.                 GetPointZPos(Xrand,Yrand,Zrand);
  796.                 SetDynamicObjectRot(DeerObject[DeerID],0,0,Angle);
  797.                 MoveDynamicObject(DeerObject[DeerID],Xrand,Yrand,Zrand+0.3,speedRand,0,0,Angle);
  798.                 DeerMove[DeerID]=1;
  799.                 SetTimerEx("MovingDeer",10000+random(40000),false,"i",DeerID);//On peut changer la fréquence des mouvements
  800.                
  801.                
  802.                
  803.                
  804.             }
  805.             else MovingDeer(DeerID);
  806.            
  807.            
  808.            
  809.            
  810.         }
  811.         else MovingDeer(DeerID);
  812.        
  813.        
  814.        
  815.        
  816.     }
  817.     return 1;
  818. }
  819.  
  820. stock IsPosInDeerZone(Float:X,Float:Y)//Areas where the deers can walk/run ; they will not exit them. It is easy to add some areas : take the coords Xmax, Xmin, Ymax and Ymin of the area, and you are done. Note : These zones are around Los Santos, there are none around LV or SF so just add some if you want to.
  821. {
  822.     if(X>-1590.561645&&X<-395.603057&&Y<-816.069274&&Y>-1717.792480) return 1;
  823.     else if(X>-689.845947&&X<197.757766&&Y<138.800338&&Y>-258.169403) return 1;
  824.     else if(X>567.683715&&X<1504.512084&&Y<376.543304&&Y>-37.922641) return 1;
  825.     else if(X>1787.830322&&X<2753.750976&&Y<-310.041870&&Y>-954.100341) return 1;
  826.     else if(X>-2527.260498&&X<-1637.774780&&Y<-1732.938232&&Y>-2647.622802) return 1;
  827.     else return 0;
  828. }
  829.  
  830. public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
  831. {
  832.     if (GetPlayerState(playerid)==1)
  833.    
  834.    
  835.     {
  836.         if(GetPlayerWeapon(playerid)==4||GetPlayerWeapon(playerid)==8||GetPlayerWeapon(playerid)==9)
  837.        
  838.        
  839.        
  840.         {
  841.             //Knive, katana, chainsaw
  842.             if(HOLDING(KEY_FIRE))
  843.            
  844.            
  845.            
  846.             {
  847.                 for(new i=0;i<MAX_ANIM;i++)
  848.                
  849.                
  850.                
  851.                 {
  852.                     new Float:xd,Float:yd,Float:zd;
  853.                     GetDynamicObjectPos(DeerObject[i],xd,yd,zd);
  854.                     if(IsPlayerInRangeOfPoint(playerid,3,xd,yd,zd))
  855.                    
  856.                    
  857.                    
  858.                     {
  859.                         if(IsPlayerAimingPoint(playerid,xd,yd,zd,5,3))
  860.                        
  861.                        
  862.                        
  863.                         {
  864.                             if(DeerMeat[i]>0&&InfectedDeer[i]==0)
  865.                            
  866.                            
  867.                            
  868.                             {
  869.                                 if(DeerKO[i]==0)
  870.                                
  871.                                
  872.                                
  873.                                 {
  874.                                     new Float:X,Float:Y,Float:Z,Float:rx,Float:ry,Float:rz;
  875.                                     GetDynamicObjectPos(DeerObject[i],X,Y,Z);
  876.                                     GetDynamicObjectRot(DeerObject[i],rx,ry,rz);
  877.                                     MoveDynamicObject(DeerObject[i],X,Y,Z,90,ry,0);
  878.                                     DeerKO[i]=1;
  879.                                    
  880.                                    
  881.                                    
  882.                                    
  883.                                 }
  884.                                 else
  885.                                
  886.                                
  887.                                
  888.                                 {
  889.                                     LoopingAnim(playerid,"BOMBER","BOM_Plant_Loop",4,1,1,1,0,DeerMeat[i]*1000);
  890.                                     GameTextForPlayer(playerid,"Picking up the meat...",3000,6);
  891.                                     if(MeatPick[playerid]==0)
  892.                                    
  893.                                    
  894.                                     {
  895.                                         SetTimerEx("FinDeer",1000+random(3000),false,"ii",i,playerid);
  896.                                         MeatPick[playerid]=1;
  897.                                        
  898.                                        
  899.                                        
  900.                                     }
  901.                                    
  902.                                    
  903.                                    
  904.                                 }
  905.                                
  906.                                
  907.                                
  908.                                
  909.                             }
  910.                             else
  911.                            
  912.                            
  913.                            
  914.                             {
  915.                                 DestroyDeer(i);
  916.                                 SendClientMessage(playerid,COLOR_GREEN,"You could not find any edible meat on this animal.");
  917.                                 new rand=random(DEER_SPAWN_LOC);//if you've added any spawn locations, replace the 21
  918.                                 new Float:X=DeerSpawn[rand][0];
  919.                                 new Float:Y=DeerSpawn[rand][1];
  920.                                 CreateDeer(X,Y);
  921.                                
  922.                                
  923.                                
  924.                                
  925.                             }
  926.                            
  927.                            
  928.                            
  929.                            
  930.                         }
  931.                        
  932.                        
  933.                        
  934.                        
  935.                     }
  936.                    
  937.                    
  938.                    
  939.                    
  940.                 }
  941.                
  942.                
  943.                
  944.                
  945.             }
  946.            
  947.            
  948.            
  949.         }
  950.        
  951.        
  952.     }
  953.     return 1;
  954. }
  955.  
  956. public FinDeer(DeerID,playerid)
  957. {
  958.     new str[128];
  959.     PlayerInfo[playerid][Viande]+=DeerMeat[DeerID];//Add this variable to the PlayerInfo. 'viande' means 'meat' FYI ;)
  960.     MeatPick[playerid]=0;
  961.     format(str,sizeof(str),"You picked up %d kg of meat.",DeerMeat[DeerID]);
  962.     DestroyDeer(DeerID);
  963.     SendClientMessage(playerid,COLOR_GREEN,str);
  964.     format(str,sizeof(str),"You are carrying %d kg of meat.",PlayerInfo[playerid][Viande]);
  965.     SendClientMessage(playerid,COLOR_GREEN,str);
  966.     new rand=random(DEER_SPAWN_LOC);//Replace the 21 if you've added locations...
  967.     new Float:X=DeerSpawn[rand][0];
  968.     new Float:Y=DeerSpawn[rand][1];
  969.     CreateDeer(X,Y);
  970.     return 1;
  971. }
  972.  
  973. public OnDynamicObjectMoved(objectid)
  974. {
  975.     for(new i=0;i<MAX_ANIM;i++)
  976.    
  977.    
  978.    
  979.     {
  980.         if(IsValidDynamicObject(DeerObject[i]))
  981.        
  982.        
  983.        
  984.         {
  985.             DeerMove[i]=0;
  986.            
  987.            
  988.            
  989.            
  990.         }
  991.        
  992.        
  993.        
  994.        
  995.     }
  996.     return 1;
  997. }
  998.  
  999. public OnPlayerVehicleDamage(playerid,vehicleid,Float:damage)
  1000. {
  1001.     for(new i=0;i<MAX_ANIM;i++)
  1002.    
  1003.    
  1004.    
  1005.     {
  1006.         new Float:xd,Float:yd,Float:zd;
  1007.         GetDynamicObjectPos(DeerObject[i],xd,yd,zd);
  1008.         if(IsPlayerInRangeOfPoint(playerid,5,xd,yd,zd))
  1009.        
  1010.        
  1011.        
  1012.         {
  1013.             new Float:rx,Float:ry,Float:rz;
  1014.             GetDynamicObjectRot(DeerObject[i],rx,ry,rz);
  1015.             GetPointZPos(xd,yd,zd);
  1016.             MoveDynamicObject(DeerObject[i],xd+0.1,yd,zd+0.15,0.3,90,0,rz);
  1017.             DeerMeat[i]-=4;
  1018.             DeerKO[i]=1;
  1019.            
  1020.            
  1021.            
  1022.            
  1023.         }
  1024.        
  1025.        
  1026.        
  1027.        
  1028.     }
  1029.     return 1;
  1030. }
  1031.  
  1032. OnePlayAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
  1033. {
  1034.     ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp,1);
  1035. }
  1036.  
  1037. LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
  1038. {
  1039.     gPlayerUsingLoopingAnim[playerid] = 1;
  1040.     ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp,1);
  1041. }
Advertisement
Add Comment
Please, Sign In to add comment