08.02.2018, 17:26
I know my code is dump something but help me to make more professional.
So How I can remove timers with any thing else ?
Or How I can use timers with another way ?
Code:
So How I can remove timers with any thing else ?
Or How I can use timers with another way ?
Code:
PHP код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
#define MPH_KMH 1.609344
stock GetPlayerVehicleSpeed( playerid )
{
new
Float:x,
Float:y,
Float:z,
vel,
vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleVelocity( vehicleid, x, y, z );
vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 ); // KM/H
// vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 / MPH_KMH ); // Mph
return vel;
}
new killtime1, killtime2, killtime3;
new Text:speed[MAX_PLAYERS];
new str[180];
new bool:speed2[MAX_PLAYERS];
public speedtime2(playerid)
{
TextDrawHideForPlayer(playerid, speed[playerid]);
TextDrawDestroy(speed[playerid]);
speed[playerid] = TextDrawCreate(500, 373, "SPEED:");
TextDrawBoxColor(speed[playerid], 0x252826FF);
TextDrawFont(speed[playerid], 3);
format(str, sizeof(str), "SPEED:~y~%i", GetPlayerVehicleSpeed(playerid));
TextDrawSetString(speed[playerid], str);
TextDrawShowForPlayer(playerid, speed[playerid]);
killtime3 = SetTimer("speedtime", 1000, 0);
speed2[playerid] = true;
return 1;
}
forward speedtime2();
public speedtime(playerid)
{
TextDrawHideForPlayer(playerid, speed[playerid]);
TextDrawDestroy(speed[playerid]);
speed[playerid] = TextDrawCreate(500, 373, "SPEED:");
TextDrawBoxColor(speed[playerid], 0x252826FF);
TextDrawFont(speed[playerid], 3);
format(str, sizeof(str), "SPEED:~y~%i", GetPlayerVehicleSpeed(playerid));
TextDrawSetString(speed[playerid], str);
TextDrawShowForPlayer(playerid, speed[playerid]);
killtime1 = SetTimer("speedtime2", 1000, 0);
speed2[playerid] = true;
return 1;
}
forward speedtime();
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
TextDrawHideForPlayer(playerid, speed[playerid]);
TextDrawDestroy(speed[playerid]);
speed[playerid] = TextDrawCreate(500, 373, "SPEED:");
TextDrawBoxColor(speed[playerid], 0x252826FF);
TextDrawFont(speed[playerid], 3);
format(str, sizeof(str), "SPEED:~y~%i", GetPlayerVehicleSpeed(playerid));
TextDrawSetString(speed[playerid], str);
TextDrawShowForPlayer(playerid, speed[playerid]);
killtime2 = SetTimer("speedtime",1000, 0);
speed2[playerid] = true;
/////////////////////////////////////
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
KillTimer(killtime1);
KillTimer(killtime2);
KillTimer(killtime3);
TextDrawDestroy(speed[playerid]);
TextDrawHideForPlayer(playerid, speed[playerid]);
return 1;
}