Top:
[pawn]enum playerToSpeedo
{ Speedo,
SpeedoAct,
Float:LastX,
Float:LastY,
Float:LastZ,
}[/pawn]
[pawn]new Speedometer[MAX_PLAYERS][playerToSpeedo];
new MSN[256];[/pawn]
OnPlayerSpawn:
[pawn] new Float:x,Float:y,Float:z;
GameTextForPlayerBottom(playerid,"\x10");
GetPlayerPos(playerid,x,y,z);
Speedometer[playerid][LastX] = x;
Speedometer[playerid][LastY] = y;
Speedometer[playerid][LastZ] = z;
if(Speedometer[playerid][Speedo] == 0 && Speedometer[playerid][SpeedoAct] == 0) Speedometer[playerid][Speedo] = 1;[/pawn]
OnGameModeInIt:
[pawn]SetTimer("SpeedoVehicle",500,1);[/pawn]
pubilc:
[pawn]public SpeedoVehicle()
{
new Float:x, Float:y, Float:z, Float:distance;
for(new i = 0; i <= MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) == 1)
if (Speedometer[Speedo] == 1 && IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) {
GetPlayerPos(i, x, y, z);
distance = floatsqroot(floatpower(floatabs(floatsub(x,Speedometer[LastX])),2)+floatpower(floatabs(floatsub(y,Speedometer[LastY])),2)+floatpower(floatabs(floatsub(z,Speedometer[LastZ])),2));
Speedometer[LastX] = x;
Speedometer[LastY] = y;
Speedometer[LastZ] = z;
format(MSN, sizeof(MSN), "~x~KpH: ~h~ %d",floatround(floatmul(distance,3.2)));
GameTextForPlayerBottom(i,MSN);
}
}
return 1;
}[/pawn]
final:
[pawn] else if (strcmp(cmd, "kph", true) == 0) {
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) SendClientMessageToAll(COLOR_WHITE,"[Syntax] - The correct use: /c <on/off>");
else {
if (strcmp(tmp, "on", true) == 0) {
if (Speedometer[playerid][SpeedoAct] == 0) SendClientMessage(playerid,COLOR_WHITE,"[Error] - You have are already KpH turned ON.");
else {
Speedometer[playerid][SpeedoAct] = 0;
SendClientMessage(playerid,COLOR_WHITE,"KpH turned ON.");
Speedometer[playerid][Speedo] = 1;
}
}
else if (strcmp(tmp, "off", true) == 0) {
if (Speedometer[playerid][SpeedoAct] == 1) SendClientMessage(playerid,COLOR_WHITE,"[Error] - You have are already KpH turned OFF.");
else {
Speedometer[playerid][SpeedoAct] = 1;
SendClientMessage(playerid,COLOR_WHITE,"KpH turned OFF.");
{Speedometer[playerid][Speedo] = 0; GameTextForAllBottom("");}
}
}
else SendClientMessageToAll(COLOR_WHITE,"[Syntax] - The correct use: /c kph <on/off>");
}
return 1;
}[/pawn]