Advertisement
legodude

trampoline

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