Advertisement
Guest User

[SAMP] Deer Hunting v1.02 by Dinnozor - English version

a guest
Jan 1st, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.61 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. forward MovingDeer(DeerID);
  31. forward DestroyDeer(DeerID);
  32. forward FinDeer(DeerID,playerid);
  33.  
  34. forward Float:Distance(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB);
  35.  
  36. new Deers[MAX_ANIM],DeerKO[MAX_ANIM],DeerObject[MAX_ANIM];
  37. new DeerMeat[MAX_ANIM],InfectedDeer[MAX_ANIM],DeerMove[MAX_ANIM],MeatPick[MAX_PLAYERS];
  38.  
  39. enum pInfo
  40. {
  41.     Viande
  42. }
  43. ;
  44. new PlayerInfo[MAX_PLAYERS][pInfo];
  45.  
  46. //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...
  47. //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)
  48.  
  49. new Float:DeerSpawn[DEER_SPAWN_LOC][3]=
  50. {
  51.    
  52.    
  53.    
  54.     {
  55.         -604.803588,-1308.452636,22.106567
  56.        
  57.        
  58.     }
  59.     ,
  60.    
  61.    
  62.    
  63.     {
  64.         -702.036621,-1309.305297,63.694377
  65.        
  66.        
  67.     }
  68.     ,
  69.    
  70.    
  71.    
  72.     {
  73.         -630.591491,-889.400268,108.452827
  74.        
  75.        
  76.     }
  77.     ,
  78.    
  79.    
  80.    
  81.     {
  82.         -992.249938,-930.179138,129.602951
  83.        
  84.        
  85.     }
  86.     ,
  87.    
  88.    
  89.    
  90.     {
  91.         -935.597717,-1146.799194,129.202728
  92.        
  93.        
  94.     }
  95.     ,
  96.    
  97.    
  98.    
  99.     {
  100.         -394.224884,87.232124,28.368480
  101.        
  102.        
  103.     }
  104.     ,
  105.    
  106.    
  107.    
  108.     {
  109.         -636.897583,-92.761047,64.660194
  110.        
  111.        
  112.     }
  113.     ,
  114.    
  115.    
  116.    
  117.     {
  118.         -2447.039794,-2192.797851,28.498489
  119.        
  120.        
  121.     }
  122.     ,
  123.    
  124.    
  125.    
  126.     {
  127.         -2224.478759,-2367.201416,32.494483
  128.        
  129.        
  130.     }
  131.     ,
  132.    
  133.    
  134.    
  135.     {
  136.         -1803.133300,-2423.008789,26.044141
  137.        
  138.        
  139.     }
  140.     ,
  141.    
  142.    
  143.    
  144.     {
  145.         -1690.161499,-2070.091308,42.189098
  146.        
  147.        
  148.     }
  149.     ,
  150.    
  151.    
  152.    
  153.     {
  154.         2006.325439,-766.786865,131.285568
  155.        
  156.        
  157.     }
  158.     ,
  159.    
  160.    
  161.    
  162.     {
  163.         -1817.458251,-1867.854980,86.802558
  164.        
  165.        
  166.     }
  167.     ,
  168.    
  169.    
  170.    
  171.     {
  172.         2176.190429,-897.414916,84.565956
  173.        
  174.        
  175.     }
  176.     ,
  177.    
  178.    
  179.    
  180.     {
  181.         2647.276855,-840.732543,70.997520
  182.        
  183.        
  184.     }
  185.     ,
  186.    
  187.    
  188.    
  189.     {
  190.         2601.860351,-436.280792,73.739181
  191.        
  192.        
  193.     }
  194.     ,
  195.    
  196.    
  197.    
  198.     {
  199.         2365.430664,-356.828186,59.507225
  200.        
  201.        
  202.     }
  203.     ,
  204.    
  205.    
  206.    
  207.     {
  208.         927.202453,-10.505444,91.440376
  209.        
  210.        
  211.     }
  212.     ,
  213.    
  214.    
  215.    
  216.     {
  217.         1092.987304,15.023153,68.779556
  218.        
  219.        
  220.     }
  221.     ,
  222.    
  223.    
  224.    
  225.     {
  226.         1504.512084,192.802429,22.368137
  227.        
  228.        
  229.     }
  230.     ,
  231.    
  232.    
  233.    
  234.     {
  235.         1083.728637,362.787322,25.921319
  236.        
  237.        
  238.     }
  239. }
  240. ;
  241.  
  242. public OnGameModeInit()
  243. {
  244.     for(new i=0;i<MAX_ANIM;i++)
  245.    
  246.    
  247.     {
  248.         new rand=random(DEER_SPAWN_LOC);
  249.         new Float:X=DeerSpawn[rand][0];
  250.         new Float:Y=DeerSpawn[rand][1];
  251.         CreateDeer(X,Y);
  252.        
  253.        
  254.        
  255.     }
  256.     return 1;
  257. }
  258.  
  259. public OnPlayerConnect(playerid)
  260. {
  261.     MeatPick[playerid]=0;
  262.     return 1;
  263. }
  264.  
  265. //You need the MapAndreas Include (see my post on SAMP Forums for the link)
  266. stock Float: GetPointZPos(const Float: fX, const Float: fY, &Float: fZ = 0.0)
  267. {
  268.     if(!((-3000.0 < fX < 3000.0) && (-3000.0 < fY < 3000.0)))
  269.    
  270.     {
  271.         return 0.0;
  272.        
  273.        
  274.     }
  275.     static
  276.     File: s_hMap
  277.     ;
  278.     if(!s_hMap)
  279.    
  280.     {
  281.         s_hMap = fopen("SAfull.hmap", io_read);
  282.        
  283.         if(!s_hMap)
  284.        
  285.         {
  286.             return 0.0;
  287.            
  288.            
  289.         }
  290.        
  291.        
  292.     }
  293.     new
  294.     afZ[1]
  295.     ;
  296.     fseek(s_hMap, ((6000 * (-floatround(fY, floatround_tozero) + 3000) + (floatround(fX, floatround_tozero) + 3000)) << 1));
  297.     fblockread(s_hMap, afZ);
  298.    
  299.     return (fZ = ((afZ[0] >>> 16) * 0.01));
  300. }
  301.  
  302. stock IsPlayerAimingPoint(playerid, Float:X2,Float:Y2,Float:Z2, Float:range,Float:accuracy,weapon=0)
  303. {
  304.     new Float:Dist, Float:xv,Float:yv,Float:zv,Float:xc,Float:yc,Float:zc,Float:xt,Float:yt,Float:zt,Float:wDis;
  305.     GetPlayerCameraPos(playerid,xc,yc,zc);
  306.     GetPlayerCameraFrontVector(playerid,xv,yv,zv);
  307.    
  308.     xt=xc+range*xv;
  309.     yt=yc+range*yv;
  310.     zt=range*zv+zc;
  311.    
  312.     switch(weapon)
  313.     {
  314.         case 34:
  315.         {
  316.             AngleD=0;
  317.             wDis=100;
  318.            
  319.         }
  320.         case 33:
  321.         {
  322.             AngleD=3;
  323.             wDis=90;
  324.            
  325.         }
  326.         case 30,31:
  327.         {
  328.             AngleD=4;
  329.             wDis=70;
  330.            
  331.         }
  332.         case 22..24:
  333.         {
  334.             AngleD=6;
  335.             wDis=40;
  336.            
  337.         }
  338.         case 25..27:
  339.         {
  340.             AngleD=4;
  341.             wDis=25;
  342.            
  343.         }
  344.         default:
  345.         {
  346.             AngleD=6;
  347.             wDis=50;
  348.            
  349.         }
  350.        
  351.     }
  352.     Dist=floatsqroot(floatpower(floatabs(xt-X2), 2) + floatpower(floatabs(yt-Y2), 2)+floatpower(floatabs(range*floattan(AngleD,degrees)+zt-Z2),2));
  353.    
  354.     if (Dist<=accuracy&&wDis>=range) return true;
  355.     return false;
  356. }
  357.  
  358. public Float:Distance(Float:xA,Float:yA,Float:zA,Float:xB,Float:yB,Float:zB)
  359. {
  360.     new Float:Dist=floatsqroot((xB-xA)*(xB-xA)+(yB-yA)*(yB-yA)+(zB-zA)*(zB-zA));
  361.     return Dist;
  362. }
  363.  
  364. public OnPlayerUpdate(playerid)//Or whatever equivalent function called frequently (like your own Update function)
  365. {
  366.     new Float:xP,Float:yP,Float:zP;
  367.     GetPlayerPos(playerid,xP,yP,zP);
  368.     if(IsPosInDeerZone(xP,yP))
  369.     {
  370.         for(new i=0;i<MAX_ANIM;i++)
  371.        
  372.         {
  373.             if(IsValidDynamicObject(DeerObject[i])&&Deers[i]>0)
  374.            
  375.            
  376.             {
  377.                 new Float:xd,Float:yd,Float:zd;
  378.                 GetDynamicObjectPos(DeerObject[i],xd,yd,zd);
  379.                 if(IsPlayerInAnyVehicle(playerid))
  380.                
  381.                
  382.                 {
  383.                     if(GetVehicleCategory(GetPlayerVehicleID(playerid))!=21)
  384.                    
  385.                    
  386.                     {
  387.                         if(IsPlayerInRangeOfPoint(playerid,25,xd,yd,zd))
  388.                        
  389.                        
  390.                         {
  391.                             MovingDeer(i);
  392.                            
  393.                            
  394.                            
  395.                         }
  396.                        
  397.                        
  398.                        
  399.                     }
  400.                     else
  401.                    
  402.                    
  403.                     {
  404.                         if(IsPlayerInRangeOfPoint(playerid,10,xd,yd,zd))
  405.                        
  406.                        
  407.                         {
  408.                             MovingDeer(i);
  409.                            
  410.                            
  411.                            
  412.                         }
  413.                        
  414.                        
  415.                        
  416.                     }
  417.                    
  418.                    
  419.                    
  420.                 }
  421.                 else if(IsPlayerInRangeOfPoint(playerid,2,xd,yd,zd)&&InfectedDeer[i]==1&&DeerKO[i]==0&&random(15)==0)
  422.                
  423.                
  424.                 {
  425.                     new Float:phealth;
  426.                     GetPlayerHealth(playerid,phealth);
  427.                     SetPlayerHealth(playerid,floatround(phealth-1,floatround_round));
  428.                     OnePlayAnim(playerid,"ped","HIT_wall",4,0,1,1,0,0);
  429.                     GameTextForPlayer(playerid,"A deer is attacking you !",3000,6);
  430.                    
  431.                    
  432.                    
  433.                 }
  434.                 else
  435.                
  436.                
  437.                 {
  438.                     if(IsPlayerInRangeOfPoint(playerid,15,xd,yd,zd))
  439.                    
  440.                    
  441.                     {
  442.                        
  443.                         if(InfectedDeer[i]==1&&DeerKO[i]==0&&DeerMove[i]==0)
  444.                        
  445.                        
  446.                         {
  447.                             new Float:xp,Float:yp,Float:zp;
  448.                             GetPlayerPos(playerid,xp,yp,zp);
  449.                             GetPointZPos(xp,yp,zp);
  450.                             if(IsPosInDeerZone(xp,yp))
  451.                            
  452.                            
  453.                             {
  454.                                 DeerMove[i]=1;
  455.                                 if((xp-xd)>0&&(yp-yd)>0)Angle=atan((yp-yd)/(xp-xd));
  456.                                 else Angle=atan((yp-yd)/(xp-xd))-180;
  457.                                 switch(random(2))
  458.                                
  459.                                
  460.                                 {
  461.                                     case 0:MoveDynamicObject(DeerObject[i],xp-1,yp,zp+0.3,8,0,0,Angle);
  462.                                     case 1:MoveDynamicObject(DeerObject[i],xp,yp-1,zp+0.3,10,0,0,Angle);
  463.                                    
  464.                                 }
  465.                                
  466.                                
  467.                                
  468.                             }
  469.                             else MovingDeer(i);
  470.                            
  471.                            
  472.                            
  473.                         }
  474.                         else MovingDeer(i);
  475.                        
  476.                        
  477.                        
  478.                     }
  479.                    
  480.                    
  481.                    
  482.                 }
  483.                
  484.                
  485.                
  486.             }
  487.            
  488.            
  489.         }
  490.     }
  491.     new iCurWeap = GetPlayerWeapon(playerid);
  492.     new iCurAmmo = GetPlayerAmmo(playerid);
  493.     if(iCurWeap==GetPVarInt(playerid,"iCurrentWeapon")&&iCurAmmo!=GetPVarInt(playerid,"iCurrentAmmo"))
  494.    
  495.     {
  496.         OnPlayerShoot(playerid,GetPVarInt(playerid, "iCurrentAmmo"), iCurAmmo,iCurWeap);
  497.         SetPVarInt(playerid,"iCurrentAmmo",iCurAmmo);
  498.        
  499.        
  500.     }
  501.     return 1;
  502. }
  503.  
  504. stock OnPlayerShoot(playerid,oldammo,newammo,weapon)
  505. {
  506.     for (new i=0;i<MAX_ANIM;i++)
  507.    
  508.    
  509.     {
  510.         new Float:X,Float:Y,Float:Z,Float:rx,Float:ry,Float:rz,Float:Z2,Float:xp,Float:yp,Float:zp;
  511.         GetDynamicObjectPos(DeerObject[i],X,Y,Z);
  512.         if(IsPlayerInRangeOfPoint(playerid,100,X,Y,Z))
  513.        
  514.         {
  515.             GetPlayerCameraPos(playerid,xp,yp,zp);
  516.             new Float:Dist=Distance(xp,yp,zp,X,Y,Z);
  517.            
  518.             if(IsPlayerAimingPoint(playerid,X,Y,Z,Dist,1.50,GetPlayerWeapon(playerid)))
  519.            
  520.            
  521.             {
  522.                 GetDynamicObjectRot(DeerObject[i],rx,ry,rz);
  523.                 GetPointZPos(X,Y,Z2);
  524.                 MoveDynamicObject(DeerObject[i],X+0.1,Y,Z2+0.15,0.4,90,0,rz);
  525.                 switch(GetPlayerWeapon(playerid))
  526.                
  527.                
  528.                 {
  529.                     case 22,23,33,34:DeerMeat[i]--;
  530.                     case 25..27:DeerMeat[i]-=3;
  531.                     default:DeerMeat[i]-=2;
  532.                    
  533.                    
  534.                    
  535.                 }
  536.                 DeerKO[i]=1;
  537.                
  538.                
  539.                
  540.             }
  541.            
  542.             else
  543.            
  544.            
  545.             {
  546.                 if(IsPlayerInRangeOfPoint(playerid,45,X,Y,Z)) MovingDeer(i);//Shooting will frighten near deers
  547.                
  548.                
  549.             }
  550.            
  551.            
  552.         }
  553.        
  554.        
  555.     }
  556. }
  557.  
  558. public OnPlayerCommandText(playerid,cmdtext[])
  559. {
  560.     if (!strcmp(cmdtext,"/resetdeers",true))
  561.    
  562.    
  563.    
  564.     {
  565.         if (PlayerInfo[playerid][AdminLvl]<1) SendClientMessage(playerid,COLOR_RED,"You are not allowed to use this command.");
  566.         else
  567.        
  568.        
  569.         {
  570.             for(new i=0;i<MAX_ANIM;i++)
  571.            
  572.            
  573.             {
  574.                 DestroyDeer(i);
  575.                 new rand=random(DEER_SPAWN_LOC);
  576.                 new Float:X=DeerSpawn[rand][0];
  577.                 new Float:Y=DeerSpawn[rand][1];
  578.                 CreateDeer(X,Y);
  579.                
  580.                
  581.                
  582.             }
  583.            
  584.            
  585.            
  586.         }
  587.         return 1;
  588.        
  589.        
  590.        
  591.     }
  592.     return 0;
  593. }
  594.  
  595. stock CreateDeer(Float:X,Float:Y)
  596. {
  597.     new DeerID=-1;
  598.     for (new i=0;i<MAX_ANIM;i++)
  599.    
  600.    
  601.     {
  602.         if(Deers[i]==0)
  603.        
  604.        
  605.         {
  606.             DeerID=i;
  607.             i=MAX_ANIM;
  608.            
  609.            
  610.            
  611.         }
  612.        
  613.        
  614.        
  615.     }
  616.     if(DeerID!=-1)
  617.    
  618.    
  619.     {
  620.         new Float:Z;
  621.         GetPointZPos(X,Y,Z);
  622.         DeerObject[DeerID]=CreateDynamicObject(19315,X,Y,Z+1,0,0,0,-1,-1,-1,300);
  623.         Deers[DeerID]=1;
  624.         DeerMeat[DeerID]=5+random(10);
  625.         DeerKO[DeerID]=0;
  626.         MovingDeer(DeerID);
  627.         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...
  628.         else InfectedDeer[DeerID]=0;
  629.        
  630.        
  631.        
  632.     }
  633. }
  634.  
  635. public DestroyDeer(DeerID)
  636. {
  637.     DeerMeat[DeerID]=0;
  638.     Deers[DeerID]=0;
  639.     DestroyDynamicObject(DeerObject[DeerID]);
  640.     return 1;
  641. }
  642.  
  643. public MovingDeer(DeerID)
  644. {
  645.     if(DeerKO[DeerID]==0&&DeerMove[DeerID]==0)
  646.    
  647.    
  648.     {
  649.         new Float:X,Float:Y,Float:Z,Float:Xrand,Float:Yrand,Float:Zrand,Float:speedRand,Float:Angle,Float:coef,Float:X2,Float:Y2;
  650.         GetDynamicObjectPos(DeerObject[DeerID],X,Y,Z);
  651.         new rand1=random(2),rand2=random(2);
  652.         if(rand1==0) Xrand=X+10+float(random(10));
  653.         else Xrand=X-10-float(random(10));
  654.         if(rand2==0) Yrand=Y+10+float(random(10));
  655.         else Yrand=Y-10-float(random(10));
  656.         Zrand=GetPointZPos(Xrand,Yrand,Zrand);
  657.         speedRand=7+float(random(9));
  658.         if((Xrand-X)>0&&(Yrand-Y)>0)Angle=atan((Yrand-Y)/(Xrand-X));
  659.         else Angle=atan((Yrand-Y)/(Xrand-X))-180;
  660.        
  661.         if(floatabs(Zrand-Z)<3.0)
  662.        
  663.        
  664.         {
  665.             if(IsPosInDeerZone(Xrand,Yrand))
  666.            
  667.            
  668.             {
  669.                 GetPointZPos(Xrand,Yrand,Zrand);
  670.                 SetDynamicObjectRot(DeerObject[DeerID],0,0,Angle);
  671.                 MoveDynamicObject(DeerObject[DeerID],Xrand,Yrand,Zrand+0.3,speedRand,0,0,Angle);
  672.                 DeerMove[DeerID]=1;
  673.                 SetTimerEx("MovingDeer",10000+random(40000),false,"i",DeerID);//On peut changer la fréquence des mouvements
  674.                
  675.                
  676.                
  677.             }
  678.             else MovingDeer(DeerID);
  679.            
  680.            
  681.            
  682.         }
  683.         else MovingDeer(DeerID);
  684.        
  685.        
  686.        
  687.     }
  688.     return 1;
  689. }
  690.  
  691. 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.
  692. {
  693.     if(X>-1590.561645&&X<-395.603057&&Y<-816.069274&&Y>-1717.792480) return 1;
  694.     else if(X>-689.845947&&X<197.757766&&Y<138.800338&&Y>-258.169403) return 1;
  695.     else if(X>567.683715&&X<1504.512084&&Y<376.543304&&Y>-37.922641) return 1;
  696.     else if(X>1787.830322&&X<2753.750976&&Y<-310.041870&&Y>-954.100341) return 1;
  697.     else if(X>-2527.260498&&X<-1637.774780&&Y<-1732.938232&&Y>-2647.622802) return 1;
  698.     else return 0;
  699. }
  700.  
  701. public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
  702. {
  703.     if (GetPlayerState(playerid)==1)
  704.    
  705.     {
  706.         if(GetPlayerWeapon(playerid)==4||GetPlayerWeapon(playerid)==8||GetPlayerWeapon(playerid)==9)
  707.        
  708.        
  709.         {
  710.             //Knive, katana, chainsaw
  711.             if(HOLDING(KEY_FIRE))
  712.            
  713.            
  714.             {
  715.                 for(new i=0;i<MAX_ANIM;i++)
  716.                
  717.                
  718.                 {
  719.                     new Float:xd,Float:yd,Float:zd;
  720.                     GetDynamicObjectPos(DeerObject[i],xd,yd,zd);
  721.                     if(IsPlayerInRangeOfPoint(playerid,3,xd,yd,zd))
  722.                    
  723.                    
  724.                     {
  725.                         if(IsPlayerAimingPoint(playerid,xd,yd,zd,5,3))
  726.                        
  727.                        
  728.                         {
  729.                             if(DeerMeat[i]>0&&InfectedDeer[i]==0)
  730.                            
  731.                            
  732.                             {
  733.                                 if(DeerKO[i]==0)
  734.                                
  735.                                
  736.                                 {
  737.                                     new Float:X,Float:Y,Float:Z,Float:rx,Float:ry,Float:rz;
  738.                                     GetDynamicObjectPos(DeerObject[i],X,Y,Z);
  739.                                     GetDynamicObjectRot(DeerObject[i],rx,ry,rz);
  740.                                     MoveDynamicObject(DeerObject[i],X,Y,Z,90,ry,0);
  741.                                     DeerKO[i]=1;
  742.                                    
  743.                                    
  744.                                    
  745.                                 }
  746.                                 else
  747.                                
  748.                                
  749.                                 {
  750.                                     LoopingAnim(playerid,"BOMBER","BOM_Plant_Loop",4,1,1,1,0,DeerMeat[i]*1000);
  751.                                     GameTextForPlayer(playerid,"Picking up the meat...",3000,6);
  752.                                     if(MeatPick[playerid]==0)
  753.                                    
  754.                                     {
  755.                                         SetTimerEx("FinDeer",1000+random(3000),false,"ii",i,playerid);
  756.                                         MeatPick[playerid]=1;
  757.                                        
  758.                                        
  759.                                     }
  760.                                    
  761.                                    
  762.                                 }
  763.                                
  764.                                
  765.                                
  766.                             }
  767.                             else
  768.                            
  769.                            
  770.                             {
  771.                                 DestroyDeer(i);
  772.                                 SendClientMessage(playerid,COLOR_GREEN,"You could not find any edible meat on this animal.");
  773.                                 new rand=random(DEER_SPAWN_LOC);//if you've added any spawn locations, replace the 21
  774.                                 new Float:X=DeerSpawn[rand][0];
  775.                                 new Float:Y=DeerSpawn[rand][1];
  776.                                 CreateDeer(X,Y);
  777.                                
  778.                                
  779.                                
  780.                             }
  781.                            
  782.                            
  783.                            
  784.                         }
  785.                        
  786.                        
  787.                        
  788.                     }
  789.                    
  790.                    
  791.                    
  792.                 }
  793.                
  794.                
  795.                
  796.             }
  797.            
  798.            
  799.         }
  800.        
  801.     }
  802.     return 1;
  803. }
  804.  
  805. public FinDeer(DeerID,playerid)
  806. {
  807.     new str[128];
  808.     PlayerInfo[playerid][Viande]+=DeerMeat[DeerID];//Add this variable to the PlayerInfo. 'viande' means 'meat' FYI ;)
  809.     MeatPick[playerid]=0;
  810.     format(str,sizeof(str),"You picked up %d kg of meat.",DeerMeat[DeerID]);
  811.     DestroyDeer(DeerID);
  812.     SendClientMessage(playerid,COLOR_GREEN,str);
  813.     format(str,sizeof(str),"You are carrying %d kg of meat.",PlayerInfo[playerid][Viande]);
  814.     SendClientMessage(playerid,COLOR_GREEN,str);
  815.     new rand=random(DEER_SPAWN_LOC);//Replace the 21 if you've added locations...
  816.     new Float:X=DeerSpawn[rand][0];
  817.     new Float:Y=DeerSpawn[rand][1];
  818.     CreateDeer(X,Y);
  819.     return 1;
  820. }
  821.  
  822. public OnDynamicObjectMoved(objectid)
  823. {
  824.     for(new i=0;i<MAX_ANIM;i++)
  825.    
  826.    
  827.     {
  828.         if(IsValidDynamicObject(DeerObject[i]))
  829.        
  830.        
  831.         {
  832.             DeerMove[i]=0;
  833.            
  834.            
  835.            
  836.         }
  837.        
  838.        
  839.        
  840.     }
  841.     return 1;
  842. }
  843.  
  844. public OnPlayerVehicleDamage(playerid,vehicleid,Float:damage)
  845. {
  846.     for(new i=0;i<MAX_ANIM;i++)
  847.    
  848.    
  849.     {
  850.         new Float:xd,Float:yd,Float:zd;
  851.         GetDynamicObjectPos(DeerObject[i],xd,yd,zd);
  852.         if(IsPlayerInRangeOfPoint(playerid,5,xd,yd,zd))
  853.        
  854.        
  855.         {
  856.             new Float:rx,Float:ry,Float:rz;
  857.             GetDynamicObjectRot(DeerObject[i],rx,ry,rz);
  858.             GetPointZPos(xd,yd,zd);
  859.             MoveDynamicObject(DeerObject[i],xd+0.1,yd,zd+0.15,0.3,90,0,rz);
  860.             DeerMeat[i]-=4;
  861.             DeerKO[i]=1;
  862.            
  863.            
  864.            
  865.         }
  866.        
  867.        
  868.        
  869.     }
  870.     return 1;
  871. }
  872.  
  873. OnePlayAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
  874. {
  875.     ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp,1);
  876. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement