Jump to content
  • 0

Speedometer


TheGodfather

Question

Salut, cand cineva se urca in masina si conduce, scad 5 tickuri. Stiu ca este de la taskul acesta pentru ca daca il comentez cu // si se urca cineva in masina si conduce nu mai scad tickuri.

task newspeed[500]() {
    foreach(new i : Player) if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER) Checkvehinfo2(i);
}

function Checkvehinfo2(i) {
    new str2[10], spe = Carspeed(GetPlayerVehicleID(i));
    format(str2, sizeof(str2), "%s%d", spe < 100 ? ("~g~") : spe >= 150 ? ("~r~") : ("~y~"), spe);
    PlayerTextDrawSetString(i, SpeedometerPTD[0], str2);
}

SpeedometerPTD[0] = CreatePlayerTextDraw(playerid, 510.333801, 342.652039, "~g~0");
    PlayerTextDrawLetterSize(playerid, SpeedometerPTD[0], 0.628332, 2.603848);
    PlayerTextDrawTextSize(playerid, SpeedometerPTD[0], 1280.000000, 1280.000000);
    PlayerTextDrawAlignment(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawColor(playerid, SpeedometerPTD[0], 0xFFFFFFFF);
    PlayerTextDrawUseBox(playerid, SpeedometerPTD[0], 0);
    PlayerTextDrawBoxColor(playerid, SpeedometerPTD[0], 0x80808080);
    PlayerTextDrawSetShadow(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawSetOutline(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawBackgroundColor(playerid, SpeedometerPTD[0], 0x00000083);
    PlayerTextDrawFont(playerid, SpeedometerPTD[0], 3);
    PlayerTextDrawSetProportional(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawSetSelectable(playerid, SpeedometerPTD[0], 0);

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0
7 hours ago, TheGodfather said:

Salut, cand cineva se urca in masina si conduce, scad 5 tickuri. Stiu ca este de la taskul acesta pentru ca daca il comentez cu // si se urca cineva in masina si conduce nu mai scad tickuri.

task newspeed[500]() {
    foreach(new i : Player) if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER) Checkvehinfo2(i);
}

function Checkvehinfo2(i) {
    new str2[10], spe = Carspeed(GetPlayerVehicleID(i));
    format(str2, sizeof(str2), "%s%d", spe < 100 ? ("~g~") : spe >= 150 ? ("~r~") : ("~y~"), spe);
    PlayerTextDrawSetString(i, SpeedometerPTD[0], str2);
}

SpeedometerPTD[0] = CreatePlayerTextDraw(playerid, 510.333801, 342.652039, "~g~0");
    PlayerTextDrawLetterSize(playerid, SpeedometerPTD[0], 0.628332, 2.603848);
    PlayerTextDrawTextSize(playerid, SpeedometerPTD[0], 1280.000000, 1280.000000);
    PlayerTextDrawAlignment(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawColor(playerid, SpeedometerPTD[0], 0xFFFFFFFF);
    PlayerTextDrawUseBox(playerid, SpeedometerPTD[0], 0);
    PlayerTextDrawBoxColor(playerid, SpeedometerPTD[0], 0x80808080);
    PlayerTextDrawSetShadow(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawSetOutline(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawBackgroundColor(playerid, SpeedometerPTD[0], 0x00000083);
    PlayerTextDrawFont(playerid, SpeedometerPTD[0], 3);
    PlayerTextDrawSetProportional(playerid, SpeedometerPTD[0], 1);
    PlayerTextDrawSetSelectable(playerid, SpeedometerPTD[0], 0);

Foloseste iteratori daca vr un timer global. sau pur si simplu fa timer la fiecare player.

Link to comment
Share on other sites

  • 0
new Iterator:in_vehicle<MAX_PLAYERS>;

hook OnPlayerDisconnect(playerid, reason) {
	Iter_Remove(in_vehicle, playerid);
}

hook OnPlayerStateChange(playerid, newstate, oldstate) {
	if(newstate == PLAYER_STATE_DRIVE || newstate == PLAYER_STATE_PASSENGER) Iter_Add(in_vehicle, playerid);
	else if(newstate == PLAYER_STATE_ONFOOT) Iter_Remove(in_vehicle, playerid);
}

task UpdateSpeedometer[500]() {
	foreach(new playerid : in_vehicle) {
		Checkvehinfo2(playerid);
	}
}

 

Link to comment
Share on other sites

  • 0
57 minutes ago, irinelbro69 said:
new Iterator:in_vehicle<MAX_PLAYERS>;

hook OnPlayerDisconnect(playerid, reason) {
	Iter_Remove(in_vehicle, playerid);
}

hook OnPlayerStateChange(playerid, newstate, oldstate) {
	if(newstate == PLAYER_STATE_DRIVE || newstate == PLAYER_STATE_PASSENGER) Iter_Add(in_vehicle, playerid);
	else if(newstate == PLAYER_STATE_ONFOOT) Iter_Remove(in_vehicle, playerid);
}

task UpdateSpeedometer[500]() {
	foreach(new playerid : in_vehicle) {
		Checkvehinfo2(playerid);
	}
}

 

Inca tot scad, nu mai scad 5 dar scad 3

Edited by TheGodfather
Link to comment
Share on other sites

  • 0
3 minutes ago, qSorin_ said:

probabil sa fie si de la host. daca nu incerca sa optimizezi gamemode ul. uita te la timere.

Doar de la taskul acela face, cum am mentionat si in primul mesaj. Daca comentez taskul acela nu mai scad deloc tickuri cand sunt in masina si conduc.

Link to comment
Share on other sites

  • 0
2 minutes ago, TheGodfather said:

Doar de la taskul acela face, cum am mentionat si in primul mesaj. Daca comentez taskul acela nu mai scad deloc tickuri cand sunt in masina si conduc.

probabil sa fie problema si de la YSI, incerca un update.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.