Advertisement
legodude

trampoline.pwn

May 4th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.96 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #define TRAMP (14449)
  3. #define MAX_TRAMPS (5)
  4. #include <a_samp>
  5. #include <zcmd>
  6. enum tramp{
  7. objectid,
  8. Float:x,
  9. Float:y,
  10. Float:z}
  11. new Tramp[MAX_TRAMPS][tramp];
  12. public OnFilterScriptInit()
  13. {
  14.     print("\n--------------------------------------");
  15.     print("        Loading Trampoline FS         ");
  16.     print("--------------------------------------\n");
  17.     for(new i=0;i<MAX_TRAMPS;i++)Tramp[i][objectid]=-1;
  18.     print("--------------------------------------");
  19.     print("              FS Loaded               ");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     for(new i=0;i<MAX_TRAMPS;i++)
  27.     {
  28.         DestroyObject(Tramp[i][objectid]);
  29.     }
  30.     return 1;
  31. }/*
  32. minx:-1.7666
  33. maxx:1.7008
  34. miny:2.1237
  35. maxy:-2.4764
  36. */
  37. CMD:trampoline(playerid,params[])
  38. {
  39.     new Float:X,Float:Y,Float:Z;
  40.     GetPlayerPos(playerid,X,Y,Z);
  41.     for(new i=0;i<MAX_TRAMPS;i++)
  42.     {
  43.         if(Tramp[i][objectid]==-1)
  44.         {
  45.             Tramp[i][objectid]=CreateObject(TRAMP,X,Y,Z,0,0,0);
  46.             Tramp[i][x]=X,Tramp[i][y]=Y,Tramp[i][z]=Z;
  47.             printf("%.4f,%.4f,%.4f",X,Y,Z);
  48.             break;
  49.         }
  50.     }
  51. }
  52. #define BOUNCINESS (0.19)
  53. public OnPlayerUpdate(playerid)
  54. {
  55.     new Float:px,Float:py,Float:pz;
  56.     GetPlayerPos(playerid,px,py,pz);
  57.     for(new i;i<MAX_TRAMPS;i++)
  58.     {
  59.         if(Tramp[i][objectid]!=-1)
  60.         {
  61.             if(IsPlayerInArea(playerid,Tramp[i][x]-1.7666,Tramp[i][x]+1.7008,Tramp[i][y]-2.1237,Tramp[i][y]+2.4764))
  62.             {
  63.                 if(pz>Tramp[i][z]+2.00200&&pz<Tramp[i][z]+2.00300)
  64.                 {
  65.                     new keys,ud,lr;
  66.                     GetPlayerKeys(playerid,keys,ud,lr);
  67.                     new Float:vx,Float:vy,Float:vz,Float:a;
  68.                     GetPlayerVelocity(playerid,vx,vy,vz);
  69.                     GetPlayerFacingAngle(playerid,a);
  70.                     if(a>45&&a<135)SetPlayerFacingAngle(playerid,90);
  71.                     else if(a>135&&a<225)SetPlayerFacingAngle(playerid,180);
  72.                     else if(a>225&&a<315)SetPlayerFacingAngle(playerid,270);
  73.                     else if((a>315&&a<360)||(a>0&&a<45))SetPlayerFacingAngle(playerid,0);
  74.                     if(ud > 0)
  75.                     {
  76.                         if(a>45&&a<135)SetPlayerVelocity(playerid,0.02,0,BOUNCINESS);
  77.                         else if(a>135&&a<225)SetPlayerVelocity(playerid,0,0.02,BOUNCINESS);
  78.                         else if(a>225&&a<315)SetPlayerVelocity(playerid,-0.02,0,BOUNCINESS);
  79.                         else if((a>315&&a<360)||(a>0&&a<45))SetPlayerVelocity(playerid,0,-0.02,BOUNCINESS);//north
  80.                     }
  81.                     else if(ud < 0)
  82.                     {
  83.                         if(a>45&&a<135)SetPlayerVelocity(playerid,-0.02,0,BOUNCINESS);
  84.                         else if(a>135&&a<225)SetPlayerVelocity(playerid,0,-0.02,BOUNCINESS);
  85.                         else if(a>225&&a<315)SetPlayerVelocity(playerid,0.02,0,BOUNCINESS);
  86.                         else if((a>315&&a<360)||(a>0&&a<45))SetPlayerVelocity(playerid,0,0.02,BOUNCINESS);//north
  87.                     }
  88.                     else if(lr > 0)
  89.                     {
  90.                         if(a>45&&a<135)SetPlayerVelocity(playerid,0,0.02,BOUNCINESS);
  91.                         else if(a>135&&a<225)SetPlayerVelocity(playerid,-0.02,0,BOUNCINESS);
  92.                         else if(a>225&&a<315)SetPlayerVelocity(playerid,0,-0.02,BOUNCINESS);
  93.                         else if((a>315&&a<360)||(a>0&&a<45))SetPlayerVelocity(playerid,0.02,0,BOUNCINESS);//north
  94.                     }
  95.                     else if(lr < 0)
  96.                     {
  97.                         if(a>45&&a<135)SetPlayerVelocity(playerid,0,-0.02,BOUNCINESS);
  98.                         else if(a>135&&a<225)SetPlayerVelocity(playerid,0.02,0,BOUNCINESS);
  99.                         else if(a>225&&a<315)SetPlayerVelocity(playerid,0,0.02,BOUNCINESS);
  100.                         else if((a>315&&a<360)||(a>0&&a<45))SetPlayerVelocity(playerid,-0.02,0,BOUNCINESS);//north
  101.                     }
  102.                     else
  103.                     {
  104.                     SetPlayerVelocity(playerid,0,0,BOUNCINESS);
  105.                     }
  106.                 }
  107.             }
  108.         }
  109.     }
  110.     return 1;
  111. }
  112.  
  113. stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
  114. {
  115.     new Float:Px, Float:Py, Float:Pz;
  116.     GetPlayerPos(playerid, Px, Py, Pz);
  117.     if (Px > minx && Px < maxx && Py > miny && Py < maxy) return 1;
  118.     return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement