TheGodfather Posted October 27, 2022 Posted October 27, 2022 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);
0 qSorin_ Posted October 27, 2022 Posted October 27, 2022 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.
0 sunkie Posted October 27, 2022 Posted October 27, 2022 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); } }
0 TheGodfather Posted October 27, 2022 Author Posted October 27, 2022 (edited) 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 October 27, 2022 by TheGodfather
0 MiritaXD Posted October 27, 2022 Posted October 27, 2022 (edited) incerca sa pui in loc de "500" ms "1000" Edited October 27, 2022 by MiritaXD
0 TheGodfather Posted October 27, 2022 Author Posted October 27, 2022 24 minutes ago, MiritaXD said: incerca sa pui in loc de "500" ms "1000" Am pus 500 pentru ca vreau sa se actualizeze la un interval mai mic de timp
0 qSorin_ Posted October 28, 2022 Posted October 28, 2022 15 hours ago, TheGodfather said: Am pus 500 pentru ca vreau sa se actualizeze la un interval mai mic de timp probabil sa fie si de la host. daca nu incerca sa optimizezi gamemode ul. uita te la timere.
0 TheGodfather Posted October 28, 2022 Author Posted October 28, 2022 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.
0 qSorin_ Posted October 28, 2022 Posted October 28, 2022 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.
0 HPQ123 Posted October 28, 2022 Posted October 28, 2022 Nu e trb doar de speedometer, dă-l drq că nu are cum să scadă atât doar de la speedometer doar nu ai 200 jucători
0 TheGodfather Posted October 28, 2022 Author Posted October 28, 2022 4 hours ago, HPQ123 said: Nu e trb doar de speedometer, dă-l drq că nu are cum să scadă atât doar de la speedometer doar nu ai 200 jucători Si la o singura persoana se intampla, deci ceva e. Si e de la acel task 100%
0 HPQ123 Posted October 28, 2022 Posted October 28, 2022 37 minutes ago, TheGodfather said: Si la o singura persoana se intampla, deci ceva e. Si e de la acel task 100% Da-mi mesaj pe HPQ123#8114 sa vad și eu
0 TheGodfather Posted October 31, 2022 Author Posted October 31, 2022 Vad ca scad si cand sunt in masina cu speedometerul dezactivat din /hud, se intampla doar cand tin w apasat. Aveti idee cum se numeste tasta w, clic stanga e KEY_FIRE spre exemplu.
0 Banditul Posted October 31, 2022 Posted October 31, 2022 52 minutes ago, TheGodfather said: Vad ca scad si cand sunt in masina cu speedometerul dezactivat din /hud, se intampla doar cand tin w apasat. Aveti idee cum se numeste tasta w, clic stanga e KEY_FIRE spre exemplu. https://open.mp/docs/scripting/resources/keys KEY_SPRINT aparent
0 TheGodfather Posted October 31, 2022 Author Posted October 31, 2022 M-am uitat si e foarte putin cod unde am KEY_SPRINT si e doar in 2 locuri in gamemode. Nush ce are de scad tickuri...
Question
TheGodfather
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);
15 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now