All pastes #911594 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-02-20 20:27 UTC
rendered paste body
public OnGameModeInit(){
for(new i=0; i<SLOTS; i++){
TextDrawSetOutline(Speedo[i], 1);
TextDrawFont(Speedo[i], 1);
TextDrawLetterSize(Speedo[i], 0.5, 1.2);
TextDrawUseBox(Speedo[i],1);
TextDrawBoxColor(Speedo[i],0x00ffff66);
TextDrawAlignment(Speedo[i], 2);
TextDrawTextSize(Speedo[i],200.0,200.0);}

public OnPlayerStateChange(playerid, newstate, oldstate){
if(newstate == PLAYER_STATE_ONFOOT){
TextDrawHideForPlayer(playerid, Speedo[playerid]);}
if(newstate == PLAYER_STATE_DRIVER){
TextDrawShowForPlayer(playerid, Speedo[playerid]);}
return 1;}

forward UpdateSpeed();
public UpdateSpeed(){
new Float:HealthV, valueSV;
new Float:x,Float:y,Float:z;
new Float:distance,string[256];
for(new i=0; i<SLOTS; i++){
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)){
TextDrawHideForPlayer(i, Speedo[i]);}}
for(new i=0; i<SLOTS; i++){
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)){
GetPlayerPos(i, x, y, z);
GetVehicleHealth(GetPlayerVehicleID(i), HealthV);
HealthV = floatsub(HealthV, 250.0);
if(HealthV < 1)HealthV = 0;
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));
valueSV = floatround(distance * 5000);
if(UpdateSeconds > 1){
valueSV = floatround(valueSV / UpdateSeconds);}
if(HealthV >= 750.01){
format(string,sizeof(string),"~r~KM/H: ~w~%d~n~~g~Uszkodzenia: ~w~%.02f",floatround(valueSV/1200), HealthV);}
if(HealthV <= 750.0){
format(string,sizeof(string),"~r~KM/H: ~w~%d~n~~g~Uszkodzenia: ~w~%.02f",floatround(valueSV/1200), HealthV);}
if(HealthV <= 400.0){
format(string,sizeof(string),"~r~KM/H: ~w~%d~n~~g~Uszkodzenia: ~y~%.02f",floatround(valueSV/1200), HealthV);}
if(HealthV <= 100.0){
format(string,sizeof(string),"~r~KM/H: ~w~%d~n~~g~Uszkodzenia: ~r~%.02f",floatround(valueSV/1200), HealthV);}
Speedo[i] = TextDrawCreate(525, 410, string);
TextDrawSetString(Speedo[i], string);}
SavePlayerPos[i][LastX] = x;
SavePlayerPos[i][LastY] = y;
SavePlayerPos[i][LastZ] = z;}}