All pastes #100168 Raw Edit

Stuff

public cpp v1 · immutable
#100168 ·published 2006-07-25 21:50 UTC
rendered paste body
// Variablesnew EnableSpeedTimer[MAX_PLAYERS];// Put this in your OnGameModeInitSetTimer("UpdateSpeed", 1000, 1);// The function itself, just put it somewherepublic UpdateSpeed(){	new Float:x,Float:y,Float:z;	new Float:distance,value,string[256];	for(new i=0; i<SLOTS; i++){		if(IsPlayerConnected(i)){			GetPlayerPos(i, x, y, z);			if(EnableSpeedTimer[i]){				distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));				// Distance: meters in the last second				value = floatround(distance * 3600);				// meters an hour				format(string,sizeof(string),"~r~~n~~n~~n~~n~~n~~n~~n~~n~~n~                                                  %d MPH",floatround(value/1600));				GameTextForPlayer(i, string, 1100, 3);				}			SavePlayerPos[i][LastX] = x;			SavePlayerPos[i][LastY] = y;			SavePlayerPos[i][LastZ] = z;			}		}	}// Put this in your OnPlayerCommandTextif(strcmp(cmd, "/speedo", true) == 0 || strcmp(cmd, "/speed", true) == 0) {	EnableSpeedTimer[playerid] = 1;	SendClientMessage(playerid, COLOR_GREEN, "Speedometer enabled. To disable, use /speedo-off.");	return 1;	}if(strcmp(cmd, "/speedo-off", true) == 0 || strcmp(cmd, "/speed-off", true) == 0) {	EnableSpeedTimer[playerid] = 0;	SendClientMessage(playerid, COLOR_GREEN, "Killed the speedo. To enable the speedo again, type /speedo");	return 1;	}