Jump to content
  • 0

pomoc Tachometr test


pe.vanasek

Dotaz

Ahoj lidi mám problém s tachometrem, když vleze hráč do auta tak se zobrazí a když vyleze, tak se skryje :d To je funkční ale jenom hráči s ID 0 ukazuje rychlost, ale ostatním hráčům to ukazuje Rychlost:%,     Prosím nevíte co s tím? :)                    Děkuju

 

new PlayerText:tachometrtest[MAX_PLAYERS];

forward tachometr1(playerid);

 

stock na rychlost.......není důležitý....

 

public tachometr1(playerid)
{
new string[50];
format(string,sizeof(string),"rychlost: %d",GetPlayerSpeed(playerid,true));
PlayerTextDrawSetString(playerid, tachometrtest[playerid], string);
return 1;
}
 
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
tachometrtest[playerid] = CreatePlayerTextDraw(playerid, 524.000000, 330.000000, "Rychlost:%");
PlayerTextDrawShow(playerid, tachometrtest[playerid]);//ZOBRAZENIE (TextDrawShowForPlayer)
SetTimer("tachometr1",1,1);
}
if(oldstate == PLAYER_STATE_DRIVER)
{
PlayerTextDrawHide(playerid, tachometrtest[playerid]);//ZMIZNUTIE (TextDrawHideForPlayer)
}
return 1;
}
 
Link to comment
Share on other sites

4 odpovědí na tuto otázku

Recommended Posts

  • 0

warning, na tvojom mieste by som už prestal spamovať

 

vanasek, existuje aj tzv. cyklus, aby si to vyvolal u všetkých hračov, ja by som to spravil úplne inak lebo toto čo si spravil je úplne na hlavu

Link to comment
Share on other sites

  • 0

warning, zbytočne píšeš -.- v posledných tématoch iba blbosti a nijak si nepomohol, možno hodnotenie ok beriem :d

 

asi nejak takto:

#include <a_samp>

new Text:Tachometer[MAX_PLAYERS];

public OnFilterScriptInit() {
	SetTimer("TachometerTimer", 100, true);
	return 1;
}

public OnFilterScriptExit() {
	return 1;
}

public OnPlayerConnect(playerid) {
	Tachometer[playerid] = TextDrawCreate(524.000000, 330.000000, "");
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate) {
	if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
	    TextDrawShowForPlayer(playerid, Tachometer[playerid]);
	} else if (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) {
	    TextDrawHideForPlayer(playerid, Tachometer[playerid]);
	}
	return 1;
}

stock GetPlayerSpeed(playerid, bool:kmh)
{
	new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
	if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
	rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
	return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}

forward TachometerTimer();
public TachometerTimer(){
	for (new i = 0; i < MAX_PLAYERS; i++) { /* Ten cyklus o ktorom som hovoril */
	    if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) {
	        new str[256];
	        format(str, sizeof(str), "Rychlost: %i", GetPlayerSpeed(i, true));
	        TextDrawSetString(Tachometer[i], str);
	    }
	}
	return 1;
}

je to spísane naslepo, lebo idem spať a už sa mi to testovať nechce, malo by to ísť

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...