Author Topic: Speedometer(KPH)command  (Read 3593 times)

0 Members and 1 Guest are viewing this topic.

76362836l

  • Guest
Speedometer(KPH)command
« on: September 10, 2013, 05:13:16 pm »
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]

Offline MatheuS

  • Made Man
  • ***
  • Posts: 207
  • Pawn And Squirrel Scripter
    • View Profile
    • Brazillian Community
Re: Speedometer(KPH)command
« Reply #1 on: September 10, 2013, 06:41:16 pm »
Kph script WarChiefs by madara  :o

Offline kkkk

  • Street Thug
  • *
  • Posts: 32
    • View Profile
Re: Speedometer(KPH)command
« Reply #2 on: September 11, 2013, 07:29:58 am »