Hey Leute,
mein Tacho (die Geschwindigkeitsanzeige) funktioniert bei mir nicht. Ich bin den kompletten Code durchgegangen und prinzipell solte es funktionieren.
[pwn=221]new Text:KMH[MAX_PLAYERS];[/pwn]
[pwn=2460]KMH[playerid] = TextDrawCreate(291.000000, 386.000000, "0KM/H");
TextDrawBackgroundColor(KMH[playerid], 255);
TextDrawFont(KMH[playerid], 1);
TextDrawLetterSize(KMH[playerid], 0.450000, 2.000000);
TextDrawColor(KMH[playerid], -1);
TextDrawSetOutline(KMH[playerid], 0);
TextDrawSetProportional(KMH[playerid], 1);
TextDrawSetShadow(KMH[playerid], 1);[/pwn]
[pwn=2618]public OnPlayerDeath(playerid, killerid, reason)
{
TextDrawHideForPlayer(playerid,HintergrundTacho);
TextDrawHideForPlayer(playerid,Geschwindigkeit);
TextDrawHideForPlayer(playerid,KMH[playerid]);
TextDrawHideForPlayer(playerid,StrichTacho);
TextDrawHideForPlayer(playerid,BoxStrichTacho);[/pwn]
[pwn=5469]public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
TextDrawShowForPlayer(playerid,HintergrundTacho);
TextDrawShowForPlayer(playerid,Geschwindigkeit);
TextDrawShowForPlayer(playerid,KMH[playerid]);
TextDrawShowForPlayer(playerid,StrichTacho);
TextDrawShowForPlayer(playerid,BoxStrichTacho);[/pwn]
[pwn=5479] if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
TextDrawHideForPlayer(playerid,HintergrundTacho);
TextDrawHideForPlayer(playerid,Geschwindigkeit);
TextDrawHideForPlayer(playerid,KMH[playerid]);
TextDrawHideForPlayer(playerid,StrichTacho);
TextDrawHideForPlayer(playerid,BoxStrichTacho);[/pwn]
[pwn=5508] if(oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
{
TextDrawHideForPlayer(playerid,HintergrundTacho);
TextDrawHideForPlayer(playerid,Geschwindigkeit);
TextDrawHideForPlayer(playerid,KMH[playerid]);
TextDrawHideForPlayer(playerid,StrichTacho);
TextDrawHideForPlayer(playerid,BoxStrichTacho);[/pwn]
[pwn=7366]stock getKmh(playerid,bool:kmh)
{
new Float:x,Float:y,Float:z,Float:rtn;
if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); else GetPlayerVelocity(playerid,x,y,z);
rtn = floatsqroot(x*x+y*y+z*z);
return kmh?floatround(rtn * 50 * 2.51):floatround(rtn * 50);
//return kmh?floatround(rtn * 50 * 1.61):floatround(rtn * 50);
}[/pwn]
[pwn=8001]public UpdateTacho(playerid)
{
new string[128];
format(string, sizeof(string), "%d KM/H",getKmh(playerid, true));
TextDrawSetString(KMH[playerid], string);
return 1;
}[/pwn]
[pwn=266]forward UpdateTacho(playerid);[/pwn]
//Bei OnPlayerConnect
SetTimerEx("UpdateTacho", 500, true, "u", playerid);
Es wird nur der Default-Wert 0KM/H angezeigt. Warum funktioniert es nicht? Hab ich was übersehen?