1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #define SLOTS 100
enum SavePlayerPosEnum { Float:LastX, Float:LastY, Float:LastZ }
new SpeedMode = 0; new UpdateSeconds = 1; new SavePlayerPos[SLOTS][SavePlayerPosEnum]; new Text:darstellungunten[100]; new killsvonplayer[MAX_PLAYERS]; forward UpdateSpeed(playerid);
public UpdateSpeed(playerid){ new Float:x,Float:y,Float:z; new Float:distance,value,string[256]; for(new i=0; i<SLOTS; i++){ for(new a=0; a<MAX_PLAYERS; a++){ if(IsPlayerConnected(a) ){ TextDrawDestroy(darstellungunten[a]); GetPlayerPos(i, x, y, z); distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floata bs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])), 2)); value = floatround(distance * 2500); if(UpdateSeconds > 1){ value = floatround(value / UpdateSeconds); } if(SpeedMode){ format(string,sizeof(string),"~r~%d MPH",floatround(value/1600)); GameTextForPlayer(i, string, 1100, 5); } else{ killsvonplayer[a] = GetPlayerScore(a); format(string,sizeof(string),"~r~Kills:~w~%d ~r~%d ~w~KM/H", killsvonplayer[a], floatround(value/100 0)); darstellungunten[a] = TextDrawCreate(50.0, 420.0, string); TextDrawLetterSize(darstellungunten[a], 0.5, 2.5); TextDrawShowForPlayer(a,darstellungunten[a]); } } SavePlayerPos[i][LastX] = x; SavePlayerPos[i][LastY] = y; SavePlayerPos[i][LastZ] = z; } } }
SetTimer("UpdateSpeed", UpdateSeconds*1000, 1);
|