Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #################################
- # #
- # Kacper Michewicz #
- # © All right reserved #
- # #
- #################################
- */
- #include <a_samp>
- #include <mapandreas>
- #include <sscanf2>
- #include <zcmd>
- #define VERSION "0.3"
- #define PVARNAME "SuperEkstraZajebistaNazwaPVara"
- #define PVAR_RUN "SuperEkstraZajebistaNazwa"
- #define PVAR_SPEED "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
- #define VEH_SPEED_DEF 0.01 // Wartość przyspieszenia domyślnego (NIE PODAWAC WIECEJ NIZ 0.1)
- #define VEH_SPEED_TIME 200
- #define DIALOG 999
- #define PVAR_ON 1
- #define PVAR_OFF 0
- #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define HOLDING(%0) ((newkeys & (%0)) == (%0))
- #define RELEASED(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #define COLOR_MESSAGE 0x42B542FF
- forward
- Speed(playerid);
- Float:GetHeadingAngle(Float:targetX, Float:targetY, Float:entityX, Float:entityY) //autor: Destrojer
- {
- new
- Float:vectorX = targetX - entityX,
- Float:vectorY = targetY - entityY,
- Float:HeadingAngle;
- HeadingAngle = atan(-(vectorX/vectorY));
- if(vectorY < 0)
- HeadingAngle = (HeadingAngle >= 180) ? HeadingAngle - 180.0 : HeadingAngle + 180.0;
- return HeadingAngle;
- }
- Float:GetVehSpeed(vehid)
- {
- new
- Float:velX,
- Float:velY,
- Float:velZ,
- Float:speed;
- GetVehicleVelocity(vehid, velX, velY, velZ);
- speed = floatsqroot(velX * velX + velY * velY + velZ * velZ);
- return speed;
- }
- public OnPlayerConnect(playerid) {
- SetPVarFloat(playerid, PVAR_SPEED, VEH_SPEED_DEF);
- return 1;
- }
- public
- OnPlayerExitVehicle(playerid, vehicleid)
- return KillTimer(GetPVarInt(playerid, PVARNAME));
- public
- OnPlayerDisconnect(playerid, reason)
- return KillTimer(GetPVarInt(playerid, PVARNAME));
- public
- OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return 1;
- if(!GetPVarInt(playerid, PVAR_RUN)) return 1;
- if(PRESSED(KEY_SPRINT))
- {
- KillTimer(GetPVarInt(playerid, PVARNAME));
- SetPVarInt(playerid, PVARNAME, SetTimerEx("Speed", VEH_SPEED_TIME, 1, "d", playerid));
- }
- else if(HOLDING(KEY_HANDBRAKE) || HOLDING(KEY_JUMP) || RELEASED(KEY_SPRINT))
- return KillTimer(GetPVarInt(playerid, PVARNAME));
- if(newkeys == KEY_UP) return 0;
- return 1;
- }
- public
- Speed(playerid)
- {
- new
- vehicleid = GetPlayerVehicleID(playerid),
- Float:rotZ,
- Float:velX,
- Float:velY,
- Float:velZ,
- Float:speed = Float:GetVehSpeed(vehicleid) + GetPVarFloat(playerid, PVAR_SPEED),
- Float:pos[4],
- Float:d = 1;
- if(d == 1.0 && GetVehSpeed(vehicleid) == 0.0) {
- return true;
- }
- GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
- MapAndreas_FindZ_For2DCoord(pos[0], pos[1], pos[3]);
- if(pos[2] - pos[3] >= 0.9) {
- return true;
- }
- GetVehicleVelocity(vehicleid, velX, velY, velZ);
- if(velX == 0.0 && velY == 0.0 && velZ == 0.0) {
- GetVehicleZAngle(vehicleid, rotZ);
- } else {
- rotZ = GetHeadingAngle(velX, velY, 0.0, 0.0);
- }
- SetVehicleVelocity(vehicleid, speed * floatsin(-rotZ, degrees), speed * floatcos(-rotZ, degrees), velZ);
- return 1;
- }
- cmd(turbo, playerid, cmdtext[])
- {
- if(GetPVarInt(playerid, PVAR_RUN))
- {
- SetPVarInt(playerid, PVAR_RUN, PVAR_OFF);
- ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", "Turbo Cars by Kacper\nzostało wyłączone!", "Okey", "Zamknij");
- }
- else if(!GetPVarInt(playerid, PVAR_RUN))
- {
- SetPVarFloat(playerid, PVAR_SPEED, VEH_SPEED_DEF);
- SetPVarInt(playerid, PVAR_RUN, PVAR_ON);
- 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");
- }
- return 1;
- }
- cmd(setspeed, playerid, cmdtext[])
- {
- 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");
- new speed = strval(cmdtext);
- 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");
- 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);
- switch(speed)
- {
- case 0: SetPVarFloat(playerid, PVAR_SPEED, 0.01);
- case 1: SetPVarFloat(playerid, PVAR_SPEED, 0.02);
- case 2: SetPVarFloat(playerid, PVAR_SPEED, 0.03);
- case 3: SetPVarFloat(playerid, PVAR_SPEED, 0.04);
- case 4: SetPVarFloat(playerid, PVAR_SPEED, 0.05);
- case 5: SetPVarFloat(playerid, PVAR_SPEED, 0.06);
- case 6: SetPVarFloat(playerid, PVAR_SPEED, 0.07);
- case 7: SetPVarFloat(playerid, PVAR_SPEED, 0.08);
- case 8: SetPVarFloat(playerid, PVAR_SPEED, 0.09);
- case 9: SetPVarFloat(playerid, PVAR_SPEED, 0.10);
- }
- format(cmdtext, 126, "Ustawiłeś przyspieszenie na\n%.2f.", GetPVarFloat(playerid, PVAR_SPEED));
- ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", cmdtext, "Okey", "Zamknij");
- return 1;
- }
- cmd(ss, playerid, cmdtext[]) return cmd_setspeed(playerid, cmdtext);
- cmd(asetspeed, playerid, cmdtext[])
- {
- if(IsPlayerAdmin(playerid)) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip » Info:", "Komenda wyłącznie dla admina!", "Okey", "Zamknij");
- new id, Float:speed, str[70], Nick[MAX_PLAYER_NAME];
- 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");
- if(id == INVALID_PLAYER_ID) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip » Info:", "Nie znaleziono gracza.", "Okey", "Zamknij");
- if(speed < 10 && speed > 0) return ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Tip » Info:", "Zła wartość przyspieszenia.", "Okey", "Zamknij");
- SetPVarFloat(id, PVAR_SPEED, speed);
- GetPlayerName(id, Nick, sizeof(Nick));
- format(str, sizeof(str), "Przyspieszenie dla gracza %s (%d)\nzostało ustawione na %.2f", Nick, speed);
- ShowPlayerDialog(playerid, DIALOG, DIALOG_STYLE_MSGBOX, "Turbo Cars "VERSION" » Info:", str, "Okey", "Zamknij");
- return 1;
- }
- cmd(ass, playerid, cmdtext[]) return cmd_asetspeed(playerid, cmdtext);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement