Hallo Community,
ich habe mir vor paar Tagen ein Tacho gescriptet, aber mein Server wird davon irgendwie langsamer...
Es ist ein komplettes Selfmade und es laufen fast keine Timer.. Liegt es an OnPlayerUpdate?
Wenn ich fahre bewegen sich die kilometer schnell aber sie spinnen weil irgendetwas laggt.
public OnPlayerUpdate(playerid)
{
if(GetPlayerMoney(playerid) > 0){Ban(playerid); format(str,sizeof(str),"%s wurde gebannt! Grund: Geldhack!",pname);SendClientMessageToAll(COLOR_ROT,str);}
new fahrzeugstring[64],Kilometerstring[64], Tachozus[64],kmhxd[28], litertacho[64];
if(IsPlayerInAnyVehicle(playerid))
{
TextDrawShowForPlayer(playerid,TachoBox1[playerid]); TextDrawShowForPlayer(playerid,TachoBox2[playerid]);
TextDrawShowForPlayer(playerid,TachoFahrzeug[playerid]); TextDrawShowForPlayer(playerid,TachoZustand[playerid]);
TextDrawShowForPlayer(playerid,Tachokilo[playerid]); TextDrawShowForPlayer(playerid,TachoLicht[playerid]);
TextDrawShowForPlayer(playerid,TachoHP[playerid]); TextDrawShowForPlayer(playerid,Kundendienst[playerid]);
TextDrawShowForPlayer(playerid,TachoTank[playerid]); TextDrawShowForPlayer(playerid,Tachokmh[playerid]);
TextDrawShowForPlayer(playerid,TachoLiter[playerid]); TextDrawShowForPlayer(playerid,TachoTur[playerid]);
TextDrawShowForPlayer(playerid,TachoMotor[playerid]); TextDrawShowForPlayer(playerid,Tachokmh[playerid]);
new veh = GetPlayerVehicleID(playerid);
new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,final_speed_int;
GetVehicleVelocity(veh, speed_x, speed_y, speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*120.0;
final_speed_int = floatround(final_speed,floatround_round);
new geschw = final_speed_int;
new Float:Zust;
GetVehicleHealth(GetPlayerVehicleID(playerid), Zust);
format(kmhxd,sizeof(kmhxd),"~w~Geschw.: %d km/h",geschw);
TextDrawSetString(Tachokmh[playerid], kmhxd);
if((GetPlayerVehicleID(playerid)!=INVALID_VEHICLE_ID) && (GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
{
//if(geschw > 180){Kick(playerid);format(str,sizeof(str),"%s wurde gebannt! Grund: Speedhack!",pname);SendClientMessageToAll(COLOR_ROT,str); }
}
format(fahrzeugstring,sizeof(fahrzeugstring),"~w~%s",VehicleName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
TextDrawSetString(TachoFahrzeug[playerid], fahrzeugstring);
format(litertacho,sizeof(litertacho),"~w~%.1fl",Tank[veh]);
TextDrawSetString(TachoLiter[playerid], litertacho);
format(Tachozus,sizeof(Tachozus),"~w~%.0f%",Zust);
TextDrawSetString(TachoHP[playerid], Tachozus);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == VEHICLE_PARAMS_ON){TextDrawSetString(TachoMotor[playerid], "~g~[Motor]");}else{
TextDrawSetString(TachoMotor[playerid], "~r~[Motor]");}
if(doors == VEHICLE_PARAMS_ON){TextDrawSetString(TachoTur[playerid], "~g~[Tueren]");}else{
TextDrawSetString(TachoTur[playerid], "~r~[Tueren]");}
if(lights == VEHICLE_PARAMS_ON){ TextDrawSetString(TachoLicht[playerid], "~g~[Licht]");}else{
TextDrawSetString(TachoLicht[playerid], "~r~[Licht]");}
if(kmstand[veh] <= 5000.0){ kmstand[veh] += final_speed;}
else
{
kmstand[veh] = 0; kmstandges[veh] += 0.1;
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(Tank[veh] >= 0.2)
{
Tank[veh] -= 0.2;
}
else
{
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,0,lights,alarm,doors,bonnet,boot,objective);
GetPlayerName(playerid,pname,sizeof(pname));
format(str, sizeof(str), "%s sein Tank ist leer!", pname);
ProxDetector(10.0, playerid, str, 0x009B9DFF,0x009B9DFF,0x009B9DFF,0x009B9DFF,0x009B9DFF);
SCM(playerid,COLOR_ROT,"Verlasse das Fahrzeug mit /exit.");
Tankleer[playerid] = 1;
Freeze(playerid);
}
}
}
format(Kilometerstring,sizeof(Kilometerstring),"~w~KM Stand: %.1fkm",kmstandges[veh]);
TextDrawSetString(Tachokilo[playerid], Kilometerstring);
}
else{
TextDrawHideForPlayer(playerid,TachoBox1[playerid]); TextDrawHideForPlayer(playerid,TachoBox2[playerid]);
TextDrawHideForPlayer(playerid,TachoFahrzeug[playerid]); TextDrawHideForPlayer(playerid,TachoZustand[playerid]);
TextDrawHideForPlayer(playerid,Tachokilo[playerid]); TextDrawHideForPlayer(playerid,TachoLicht[playerid]);
TextDrawHideForPlayer(playerid,TachoHP[playerid]); TextDrawHideForPlayer(playerid,Kundendienst[playerid]);
TextDrawHideForPlayer(playerid,TachoTank[playerid]); TextDrawHideForPlayer(playerid,Tachokmh[playerid]);
TextDrawHideForPlayer(playerid,TachoLiter[playerid]); TextDrawHideForPlayer(playerid,TachoTur[playerid]);
TextDrawHideForPlayer(playerid,TachoMotor[playerid]);
}
return 1;
}
Soll ich die Textdraws lieber unter ongamemodeinit erstellen?
Bisher erstelle ich sie für jeden Spieler in einem public... und soll ich auch lieber einen eigenen Timer dafür machen?
LG
//e brauche immer noch hilfe....