Advertisement
Shiny_

Untitled

Sep 29th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.70 KB | None | 0 0
  1. /*
  2.     #################################
  3.     #               #
  4.     #      Kacper Michewicz #
  5.     #    © All right reserved   #
  6.     #               #
  7.     #################################
  8. */
  9. #include <a_samp>
  10. #include <mapandreas>
  11. #include <sscanf2>
  12. #include <zcmd>
  13.  
  14. #define VERSION     "0.3"
  15. #define PVARNAME    "SuperEkstraZajebistaNazwaPVara"
  16. #define PVAR_RUN        "SuperEkstraZajebistaNazwa"
  17. #define PVAR_SPEED      "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
  18. #define VEH_SPEED_DEF   0.01 // Wartość przyspieszenia domyślnego (NIE PODAWAC WIECEJ NIZ 0.1)
  19. #define VEH_SPEED_TIME  200
  20. #define DIALOG          999
  21.  
  22. #define PVAR_ON         1
  23. #define PVAR_OFF        0
  24.  
  25. #define PRESSED(%0)     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  26. #define HOLDING(%0)     ((newkeys & (%0)) == (%0))
  27. #define RELEASED(%0)    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  28.  
  29. #define COLOR_MESSAGE   0x42B542FF
  30.  
  31. forward
  32.     Speed(playerid);
  33.  
  34. Float:GetHeadingAngle(Float:targetX, Float:targetY, Float:entityX, Float:entityY) //autor: Destrojer
  35. {
  36.     new
  37.         Float:vectorX = targetX - entityX,
  38.         Float:vectorY = targetY - entityY,
  39.         Float:HeadingAngle;
  40.  
  41.     HeadingAngle = atan(-(vectorX/vectorY));
  42.  
  43.     if(vectorY < 0)
  44.         HeadingAngle = (HeadingAngle >= 180) ? HeadingAngle - 180.0 : HeadingAngle + 180.0;
  45.  
  46.     return HeadingAngle;
  47. }
  48.  
  49. Float:GetVehSpeed(vehid)
  50. {
  51.     new
  52.         Float:velX,
  53.         Float:velY,
  54.         Float:velZ,
  55.         Float:speed;
  56.  
  57.     GetVehicleVelocity(vehid, velX, velY, velZ);
  58.     speed = floatsqroot(velX * velX + velY * velY + velZ * velZ);
  59.     return speed;
  60. }
  61.  
  62. public OnPlayerConnect(playerid) {
  63.     SetPVarFloat(playerid, PVAR_SPEED, VEH_SPEED_DEF);
  64.     return 1;
  65. }
  66. public
  67.     OnPlayerExitVehicle(playerid, vehicleid)
  68.         return KillTimer(GetPVarInt(playerid, PVARNAME));
  69. public
  70.     OnPlayerDisconnect(playerid, reason)
  71.         return KillTimer(GetPVarInt(playerid, PVARNAME));
  72.        
  73. public
  74.     OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  75. {
  76.     if(!IsPlayerInAnyVehicle(playerid)) return 1;
  77.     if(!GetPVarInt(playerid, PVAR_RUN)) return 1;
  78.  
  79.     if(PRESSED(KEY_SPRINT))
  80.     {
  81.         KillTimer(GetPVarInt(playerid, PVARNAME));
  82.         SetPVarInt(playerid, PVARNAME, SetTimerEx("Speed", VEH_SPEED_TIME, 1, "d", playerid));
  83.     }
  84.     else if(HOLDING(KEY_HANDBRAKE) || HOLDING(KEY_JUMP) || RELEASED(KEY_SPRINT))
  85.         return KillTimer(GetPVarInt(playerid, PVARNAME));
  86.     if(newkeys == KEY_UP) return 0;
  87.     return 1;
  88. }
  89.  
  90. public
  91.     Speed(playerid)
  92. {
  93.     new
  94.         vehicleid = GetPlayerVehicleID(playerid),
  95.         Float:rotZ,
  96.         Float:velX,
  97.         Float:velY,
  98.         Float:velZ,
  99.         Float:speed = Float:GetVehSpeed(vehicleid) + GetPVarFloat(playerid, PVAR_SPEED),
  100.         Float:pos[4],
  101.         Float:d = 1;
  102.        
  103.     if(d == 1.0 && GetVehSpeed(vehicleid) == 0.0) {
  104.         return true;
  105.     }
  106.    
  107.     GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
  108.     MapAndreas_FindZ_For2DCoord(pos[0], pos[1], pos[3]);
  109.  
  110.     if(pos[2] - pos[3] >= 0.9) {
  111.         return true;
  112.     }
  113.    
  114.     GetVehicleVelocity(vehicleid, velX, velY, velZ);
  115.  
  116.     if(velX == 0.0 && velY == 0.0 && velZ == 0.0) {
  117.         GetVehicleZAngle(vehicleid, rotZ);
  118.     } else {
  119.         rotZ = GetHeadingAngle(velX, velY, 0.0, 0.0);
  120.     }
  121.    
  122.     SetVehicleVelocity(vehicleid, speed * floatsin(-rotZ, degrees), speed * floatcos(-rotZ, degrees), velZ);
  123.     return 1;
  124. }
  125.  
  126. cmd(turbo, playerid, cmdtext[])
  127. {
  128.     if(GetPVarInt(playerid, PVAR_RUN))
  129.     {
  130.         SetPVarInt(playerid, PVAR_RUN, PVAR_OFF);
  131.         ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", "Turbo Cars by Kacper\nzostało wyłączone!", "Okey", "Zamknij");
  132.     }
  133.     else if(!GetPVarInt(playerid, PVAR_RUN))
  134.     {
  135.         SetPVarFloat(playerid, PVAR_SPEED, VEH_SPEED_DEF);
  136.         SetPVarInt(playerid, PVAR_RUN, PVAR_ON);
  137.         ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", "Turbo Cars by Kacper\nzostało włączone!\n\nAby ustawić prędkość wpisz\n\t/setspeed (/ss)", "Okey", "Zamknij");
  138.     }
  139.     return 1;
  140. }
  141.  
  142. cmd(setspeed, playerid, cmdtext[])
  143. {
  144.     if(!GetPVarInt(playerid, PVAR_RUN)) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Błąd", "Nie możesz użyć tej komendy!\nAby właczyć Turbo Cars wpisz:\n\n\t/TURBO", "Okey", "Zamknij");
  145.     new speed = strval(cmdtext);
  146.     if(!speed) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip:", "/setspeed [Przyspieszenie]\n\nPRZYKŁAD:\n1\t-\tLekkie przyspieszenie.\n2\t-\tNiezła prędkość.\n3\t-\tTrzymajcie się!\n4\t-\tAaaaale szybko!", "Okey", "Zamknij");
  147.     if(speed == 0) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", "Przyspiesznie zostało zresetowane.", "Okey", "Zamknij") && SetPVarFloat(playerid, PVAR_SPEED, VEH_SPEED_DEF);
  148.     switch(speed)
  149.     {
  150.         case 0: SetPVarFloat(playerid, PVAR_SPEED, 0.01);
  151.         case 1: SetPVarFloat(playerid, PVAR_SPEED, 0.02);
  152.         case 2: SetPVarFloat(playerid, PVAR_SPEED, 0.03);
  153.         case 3: SetPVarFloat(playerid, PVAR_SPEED, 0.04);
  154.         case 4: SetPVarFloat(playerid, PVAR_SPEED, 0.05);
  155.         case 5: SetPVarFloat(playerid, PVAR_SPEED, 0.06);
  156.         case 6: SetPVarFloat(playerid, PVAR_SPEED, 0.07);
  157.         case 7: SetPVarFloat(playerid, PVAR_SPEED, 0.08);
  158.         case 8: SetPVarFloat(playerid, PVAR_SPEED, 0.09);
  159.         case 9: SetPVarFloat(playerid, PVAR_SPEED, 0.10);
  160.     }
  161.     format(cmdtext, 126, "Ustawiłeś przyspieszenie na\n%.2f.", GetPVarFloat(playerid, PVAR_SPEED));
  162.     ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", cmdtext, "Okey", "Zamknij");
  163.     return 1;
  164. }
  165. cmd(ss, playerid, cmdtext[]) return cmd_setspeed(playerid, cmdtext);
  166.  
  167. cmd(asetspeed, playerid, cmdtext[])
  168. {
  169.     if(IsPlayerAdmin(playerid)) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip » Info:", "Komenda wyłącznie dla admina!", "Okey", "Zamknij");
  170.     new id, Float:speed, str[70], Nick[MAX_PLAYER_NAME];
  171.     if(sscanf(cmdtext, "uf", id, speed)) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip:", "/asetspeed [ID/Nick] [Przyspieszenie]\n\nPamiętaj aby nie podawać zbyt dużych\nprzyspieszeń!", "Okey", "Zamknij");
  172.     if(id == INVALID_PLAYER_ID) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip » Info:", "Nie znaleziono gracza.", "Okey", "Zamknij");
  173.     if(speed < 10 && speed > 0) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip » Info:", "Zła wartość przyspieszenia.", "Okey", "Zamknij");
  174.  
  175.     SetPVarFloat(id, PVAR_SPEED, speed);
  176.     GetPlayerName(id, Nick, sizeof(Nick));
  177.     format(str, sizeof(str), "Przyspieszenie dla gracza %s (%d)\nzostało ustawione na %.2f", Nick, speed);
  178.     ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", str, "Okey", "Zamknij");
  179.     return 1;
  180. }
  181. cmd(ass, playerid, cmdtext[]) return cmd_asetspeed(playerid, cmdtext);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement