All pastes #270063 Raw Edit

59p

public cpp v1 · immutable
·published 2006-12-07 01:18 UTC
rendered paste body
#include <a_samp>#define SLOTS 100enum SavePlayerPosEnum {Float:LastX,Float:LastY,Float:LastZ}new SavePlayerPos[SLOTS][SavePlayerPosEnum];new SpeedMode = 0; // 0 for KPH, 1 for MPHnew UpdateSeconds = 1; //1=jedna sekunda od&#347;wie&#380;anienew speedtimer;public OnFilterScriptInit() {	print("\n----------------------------------");	print("Filterscript NAZWA sucessfully loaded");	print("----------------------------------\n");}public OnFilterScriptExit() {	print("\n----------------------------------");	print("Filterscript NAZWA sucessfully un-loaded");	print("----------------------------------\n");}public OnPlayerCommandText(playerid, cmdtext[]) {	if (strcmp(cmdtext, "/speed-off", true)==0) {		KillTimer(speedtimer);    	return 1;    }	if (strcmp(cmdtext, "/speed-on", true)==0) {		speedtimer = SetTimer("UpdateSpeed", UpdateSeconds*1000, 1);    	return 1;    }	return 0;}public OnGameModeInit() {	speedtimer = SetTimer("UpdateSpeed", UpdateSeconds*1000, 1);}public GameModeExitFunc() {	KillTimer(speedtimer);}public UpdateSpeed(){	new Float:x,Float:y,Float:z;	new Float:distance,value,string[256];	for(new i=0; i<SLOTS; i++){		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)){			GetPlayerPos(i, x, y, z);			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));			value = floatround(distance * 3600);			if(UpdateSeconds > 1){				value = floatround(value / UpdateSeconds);			}			if(SpeedMode){				format(string,sizeof(string),"~w~%d MPH",floatround(value/1600));				GameTextForPlayer(i, string, 1100, 5);			}			else{				format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~w~%d ~r~KM/H",floatround(value/1000));				GameTextForPlayer(i, string, 1100, 5);			}			SavePlayerPos[i][LastX] = x;			SavePlayerPos[i][LastY] = y;			SavePlayerPos[i][LastZ] = z;		}	}}