Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ai>
- #include <aicolor>
- #include <lrp>
- /*#include <a_samp>
- #include <a_players>
- #include <float>
- #define teal1 0x00bbbb00
- #define teal3 0x00999900*/
- #define maxplayers 200
- //----[Quick Stats]-------------------------------------------------------------
- new mphtext = 0; // 0 = textdraw, 1 = gamemodetext.
- new style = 0; // The Default Style 0 = mph, 1 = kmph.
- new incar = 0; // Display speedo only in car. 0 = yes, 1 = no.
- new timeramt= 300;// Speed of the speedometer timer in milliseconds.
- new spcolor = 0; // Default Color. 0 = blue, 1 = green, 2 = red, 3 = purple, 4 = yellow.
- //------------------------------------------------------------------------------
- new Mphtext[maxplayers];
- new Style[maxplayers];
- new Color[maxplayers];
- new timer;
- new Text:Speedometer[maxplayers];
- new ToggleSpeedometer[maxplayers];
- new Displaying[maxplayers];
- enum pos
- {
- Float:x,
- Float:y,
- Float:z
- }
- new Pos[maxplayers][pos];
- new Pos2[maxplayers][pos];
- new Float:DistanceX[maxplayers];
- new Float:DistanceY[maxplayers];
- new Float:DistanceX2[maxplayers];
- new Float:DistanceY2[maxplayers];
- new Float:Distance[maxplayers];
- new Float:S1[maxplayers];
- new Float:S2[maxplayers];
- new Float:S3[maxplayers];
- new SpeedStep[maxplayers];
- new Float:TotalSpeed[maxplayers];
- forward Timer();
- forward PlayerMessage(playerid, color, string[]);
- public OnFilterScriptInit() // OnFilterScriptInit
- {
- print(" ");
- print(" >> AI Speed initiated");
- print(" ");
- timer = SetTimer("Timer", timeramt, true);
- return 1;
- } //----------
- public OnFilterScriptExit() // OnFilterScriptExit
- {
- print(" ");
- print(" >> AI Speed shut down...");
- print(" ");
- KillTimer(timer);
- for(new i=0; i<=GetMaxPlayers(); i++)
- {
- TextDrawDestroy(Speedometer[i]);
- }
- return 1;
- } //----------
- public OnPlayerConnect(playerid) // OnPlayerConnect
- {
- Mphtext[playerid] = mphtext;
- Style[playerid] = style;
- Color[playerid] = spcolor;
- Displaying[playerid] = 1;
- Speedometer[playerid] = TextDrawCreate(300, 400, " ");
- //Speedometer[playerid] = TextDrawCreate(502, 110, " "); Used for my script
- TextDrawAlignment(Speedometer[playerid],1);
- TextDrawSetProportional(Speedometer[playerid],1);
- TextDrawSetOutline(Speedometer[playerid], 1);
- TextDrawFont(Speedometer[playerid], 2);
- TextDrawShowForPlayer(playerid, Speedometer[playerid]);
- return 1;
- } //----------
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(ToggleSpeedometer[playerid] == 1)
- {
- TextDrawShowForPlayer(playerid, Speedometer[playerid]);
- return 1;
- }
- return 1;
- }
- public Timer() // Timer
- {
- for(new i=0; i<=GetMaxPlayers(); i++)
- {
- if(IsPlayerConnected(i))
- {
- if(ToggleSpeedometer[i] == 1)
- {
- new str[64];
- new cstr[64];
- if(SpeedStep[i] == 0)
- {
- GetPlayerPos(i, Pos[i][x], Pos[i][y], Pos[i][z]);
- }
- if(SpeedStep[i] == 1)
- {
- GetPlayerPos(i, Pos2[i][x], Pos2[i][y], Pos2[i][z]);
- DistanceX[i] = Pos[i][x] - Pos2[i][x];
- DistanceY[i] = Pos[i][y] - Pos2[i][y];
- DistanceX2[i] = DistanceX[i] * DistanceX[i];
- DistanceY2[i] = DistanceY[i] * DistanceY[i];
- Distance[i] = (DistanceX2[i] + DistanceY2[i])/2;
- S1[i] = Distance[i];
- }
- if(SpeedStep[i] == 2)
- {
- GetPlayerPos(i, Pos[i][x], Pos[i][y], Pos[i][z]);
- }
- if(SpeedStep[i] == 3)
- {
- GetPlayerPos(i, Pos2[i][x], Pos2[i][y], Pos2[i][z]);
- DistanceX[i] = Pos[i][x] - Pos2[i][x];
- DistanceY[i] = Pos[i][y] - Pos2[i][y];
- DistanceX2[i] = DistanceX[i] * DistanceX[i];
- DistanceY2[i] = DistanceY[i] * DistanceY[i];
- Distance[i] = (DistanceX2[i] + DistanceY2[i])/2;
- S2[i] = Distance[i];
- }
- if(SpeedStep[i] == 4)
- {
- GetPlayerPos(i, Pos[i][x], Pos[i][y], Pos[i][z]);
- }
- if(SpeedStep[i] == 5)
- {
- GetPlayerPos(i, Pos2[i][x], Pos2[i][y], Pos2[i][z]);
- DistanceX[i] = Pos[i][x] - Pos2[i][x];
- DistanceY[i] = Pos[i][y] - Pos2[i][y];
- DistanceX2[i] = DistanceX[i] * DistanceX[i];
- DistanceY2[i] = DistanceY[i] * DistanceY[i];
- Distance[i] = (DistanceX2[i] + DistanceY2[i])/2;
- S3[i] = Distance[i];
- }
- TotalSpeed[i] = (S1[i]+S2[i]+S3[i])/3;
- if(Mphtext[i] == 0)
- {
- if(incar == 0)
- {
- if(!IsPlayerInAnyVehicle(i))
- {
- TextDrawHideForPlayer(i, Speedometer[i]);
- }
- if(IsPlayerInAnyVehicle(i))
- {
- TextDrawShowForPlayer(i, Speedometer[i]);
- if(Style[i] == 0)
- {
- if(Displaying[i] == 0)
- {
- Speedometer[i] = TextDrawCreate(300, 400, " ");
- //Speedometer[playerid] = TextDrawCreate(502, 110, " "); Used for my script
- TextDrawAlignment(Speedometer[i],1);
- TextDrawSetProportional(Speedometer[i],1);
- TextDrawSetOutline(Speedometer[i], 1);
- TextDrawFont(Speedometer[i], 2);
- TextDrawShowForPlayer(i, Speedometer[i]);
- Displaying[i] = 1;
- }
- format(str, sizeof(str), "mph:~w~%.0f",TotalSpeed[i]);
- if(Color[i] == 0)
- {
- format(cstr, sizeof(cstr), "~b~%s", str);
- }
- if(Color[i] == 1)
- {
- format(cstr, sizeof(cstr), "~g~%s", str);
- }
- if(Color[i] == 2)
- {
- format(cstr, sizeof(cstr), "~r~%s", str);
- }
- if(Color[i] == 3)
- {
- format(cstr, sizeof(cstr), "~p~%s", str);
- }
- if(Color[i] == 4)
- {
- format(cstr, sizeof(cstr), "~y~%s", str);
- }
- if(Color[i] == 5)
- {
- format(cstr, sizeof(cstr), "~l~%s", str);
- }
- TextDrawSetString(Speedometer[i], cstr);
- }
- if(Style[i] == 1)
- {
- if(Displaying[i] == 0)
- {
- Speedometer[i] = TextDrawCreate(300, 400, " ");
- //Speedometer[playerid] = TextDrawCreate(502, 110, " "); Used for my script
- TextDrawAlignment(Speedometer[i],1);
- TextDrawSetProportional(Speedometer[i],1);
- TextDrawSetOutline(Speedometer[i], 1);
- TextDrawFont(Speedometer[i], 2);
- TextDrawShowForPlayer(i, Speedometer[i]);
- Displaying[i] = 1;
- }
- format(str, sizeof(str), "kmph:~w~%.0f",TotalSpeed[i]*1.609);
- if(Color[i] == 0)
- {
- format(cstr, sizeof(cstr), "~b~%s", str);
- }
- if(Color[i] == 1)
- {
- format(cstr, sizeof(cstr), "~g~%s", str);
- }
- if(Color[i] == 2)
- {
- format(cstr, sizeof(cstr), "~r~%s", str);
- }
- if(Color[i] == 3)
- {
- format(cstr, sizeof(cstr), "~p~%s", str);
- }
- if(Color[i] == 4)
- {
- format(cstr, sizeof(cstr), "~y~%s", str);
- }
- if(Color[i] == 5)
- {
- format(cstr, sizeof(cstr), "~l~%s", str);
- }
- TextDrawSetString(Speedometer[i], cstr);
- }
- }
- }
- if(incar == 1)
- {
- TextDrawShowForPlayer(i, Speedometer[i]);
- if(Style[i] == 0)
- {
- if(Displaying[i] == 0)
- {
- Speedometer[i] = TextDrawCreate(300, 400, " ");
- //Speedometer[playerid] = TextDrawCreate(502, 110, " "); Used for my script
- TextDrawAlignment(Speedometer[i],1);
- TextDrawSetProportional(Speedometer[i],1);
- TextDrawSetOutline(Speedometer[i], 1);
- TextDrawFont(Speedometer[i], 2);
- TextDrawShowForPlayer(i, Speedometer[i]);
- Displaying[i] = 1;
- }
- format(str, sizeof(str), "mph:~w~%.0f",TotalSpeed[i]);
- if(Color[i] == 0)
- {
- format(cstr, sizeof(cstr), "~b~%s", str);
- }
- if(Color[i] == 1)
- {
- format(cstr, sizeof(cstr), "~g~%s", str);
- }
- if(Color[i] == 2)
- {
- format(cstr, sizeof(cstr), "~r~%s", str);
- }
- if(Color[i] == 3)
- {
- format(cstr, sizeof(cstr), "~p~%s", str);
- }
- if(Color[i] == 4)
- {
- format(cstr, sizeof(cstr), "~y~%s", str);
- }
- if(Color[i] == 5)
- {
- format(cstr, sizeof(cstr), "~l~%s", str);
- }
- TextDrawSetString(Speedometer[i], cstr);
- }
- if(Style[i] == 1)
- {
- if(Displaying[i] == 0)
- {
- Speedometer[i] = TextDrawCreate(300, 400, " ");
- //Speedometer[playerid] = TextDrawCreate(502, 110, " "); Used for my script
- TextDrawAlignment(Speedometer[i],1);
- TextDrawSetProportional(Speedometer[i],1);
- TextDrawSetOutline(Speedometer[i], 1);
- TextDrawFont(Speedometer[i], 2);
- TextDrawShowForPlayer(i, Speedometer[i]);
- Displaying[i] = 1;
- }
- format(str, sizeof(str), "kmph:~w~%.0f",TotalSpeed[i]*1.609);
- if(Color[i] == 0)
- {
- format(cstr, sizeof(cstr), "~b~%s", str);
- }
- if(Color[i] == 1)
- {
- format(cstr, sizeof(cstr), "~g~%s", str);
- }
- if(Color[i] == 2)
- {
- format(cstr, sizeof(cstr), "~r~%s", str);
- }
- if(Color[i] == 3)
- {
- format(cstr, sizeof(cstr), "~p~%s", str);
- }
- if(Color[i] == 4)
- {
- format(cstr, sizeof(cstr), "~y~%s", str);
- }
- if(Color[i] == 5)
- {
- format(cstr, sizeof(cstr), "~l~%s", str);
- }
- TextDrawSetString(Speedometer[i], cstr);
- }
- }
- }
- if(Mphtext[i] == 1)
- {
- if(incar == 0)
- {
- if(Style[i] == 0)
- {
- if(Color[i] == 0)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~b~mph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 1)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~mph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 2)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~mph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 3)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~p~mph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 4)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~y~mph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 5)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~l~mph:~w~%.0f", TotalSpeed[i]);
- }
- GameTextForPlayer(i, str, timeramt, 3);
- }
- if(Style[i] == 1)
- {
- if(Color[i] == 0)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~b~kmph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 1)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~kmph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 2)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~kmph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 3)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~p~kmph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 4)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~y~kmph:~w~%.0f", TotalSpeed[i]);
- }
- if(Color[i] == 5)
- {
- format(str, sizeof(str), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~l~kmph:~w~%.0f", TotalSpeed[i]);
- }
- GameTextForPlayer(i, str, timeramt, 3);
- }
- }
- }
- SpeedStep[i] ++;
- if(SpeedStep[i] == 6)
- {
- SpeedStep[i] = 0;
- }
- }
- }
- }
- return 1;
- } //----------
- public OnPlayerPrivmsg(playerid, recieverid, text[]) // OnPlayerPrivmsg
- {
- return 0;
- } //----------
- public OnPlayerCommandText(playerid, cmdtext[]) // OnPlayerCommandText
- {
- if (strcmp("/speedometer", cmdtext, true) == 0)
- {
- if(ToggleSpeedometer[playerid] == 0)
- {
- ToggleSpeedometer[playerid] = 1;
- PlayerMessage(playerid, teal3, " >> Speedometer turned on.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- TextDrawShowForPlayer(playerid, Speedometer[playerid]);
- return 1;
- }
- if(ToggleSpeedometer[playerid] == 1)
- {
- ToggleSpeedometer[playerid] = 0;
- PlayerMessage(playerid, teal3, " >> Speedometer turned off.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- TextDrawHideForPlayer(playerid, Speedometer[playerid]);
- return 1;
- }
- return 1;
- }
- if(strcmp("/mph", cmdtext, true) == 0)
- {
- Style[playerid] = 0;
- PlayerMessage(playerid, teal3, " >> Speedometer set to mph.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/kmph", cmdtext, true) == 0 || strcmp("/kph", cmdtext, true) == 0)
- {
- Style[playerid] = 1;
- PlayerMessage(playerid, teal3, " >> Speedometer set to kmph.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/blue", cmdtext, true) == 0)
- {
- Color[playerid] = 0;
- PlayerMessage(playerid, teal3, " >> Speedometer color set to blue.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/green", cmdtext, true) == 0)
- {
- Color[playerid] = 1;
- PlayerMessage(playerid, teal3, " >> Speedometer color set to green.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/red", cmdtext, true) == 0)
- {
- Color[playerid] = 2;
- PlayerMessage(playerid, teal3, " >> Speedometer color set to red.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/purple", cmdtext, true) == 0)
- {
- Color[playerid] = 3;
- PlayerMessage(playerid, teal3, " >> Speedometer color set to purple.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/yellow", cmdtext, true) == 0)
- {
- Color[playerid] = 4;
- PlayerMessage(playerid, teal3, " >> Speedometer color set to yellow.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/black", cmdtext, true) == 0)
- {
- Color[playerid] = 5;
- PlayerMessage(playerid, teal3, " >> Speedometer color set to black.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(strcmp("/mphtext", cmdtext, true) == 0)
- {
- if(Mphtext[playerid] == 0)
- {
- Mphtext[playerid] = 1;
- PlayerMessage(playerid, teal3, " >> Speedometer set to gamemodetext.");
- TextDrawHideForPlayer(playerid, Speedometer[playerid]);
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- if(Mphtext[playerid] == 1)
- {
- Mphtext[playerid] = 0;
- PlayerMessage(playerid, teal3, " >> Speedometer set to text draw.");
- PlayerPlaySound(playerid, 1053, 0, 0, 0);
- return 1;
- }
- return 1;
- }
- if(strcmp("/help", cmdtext, true) == 0)
- {
- PlayerMessage(playerid, teal1, " >> Help");
- PlayerMessage(playerid, teal1, " >> /speedometer (toggles on and off)");
- PlayerMessage(playerid, teal1, " >> /mphtext (toggles textdraw and gamemodetext)");
- PlayerMessage(playerid, teal1, " >> /mph /kmph (switches to the style of your choosing.)");
- PlayerMessage(playerid, teal1, " >> /blue /green /red /purple /yellow /black (switches the color of the mph/kmph display.)");
- return 1;
- }
- return 0;
- } //----------
- public PlayerMessage(playerid, color, string[]) // PlayerMessage
- {
- SendClientMessage(playerid, color, string);
- return 1;
- } //----------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement