radar causando rt -
Felpz - 04.03.2019
Coloquei meu sistema de radar em uma verificaзгo do velocнmetro, e toda vez que passo ao lado da uma travada no servidor. Alguйm sabe porquк isto esta causando ?
PHP код:
task Velocimetro[500]()
{
foreach(new i: Player)
{
if(!gPlayerLogged[i])continue;
if(IsPlayerInAnyVehicle(i))
{
new Float:_hp;
new playervehicle;
new _v = GetPlayerVehicleID(i);
if ( (playervehicle = GetPlayerVehicleID(i)) != INVALID_VEHICLE_ID)
{
new string_velo[15];
format(string_velo, sizeof (string_velo), "%02d km/h", GetVehicleSpeed(playervehicle));
PlayerTextDrawSetString(i, textPlayerVelocimetro[1][i], string_velo);
GetVehicleHealth(_v, _hp);
format(string_velo, sizeof (string_velo), "%.0f%%", _hp/10);
PlayerTextDrawSetString(i, textPlayerVelocimetro[3][i], string_velo);
format(string_velo, sizeof (string_velo), "%02d Litros", Gas[playervehicle]);
PlayerTextDrawSetString(i, textPlayerVelocimetro[2][i], string_velo);
}
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(i)) ^ 510 && GetVehicleModel(GetPlayerVehicleID(i)) ^ 481 && GetVehicleModel(GetPlayerVehicleID(i)) ^ 509)
{
for(new u; u < 120; ++ u)
{
if(IsPlayerInRangeOfPoint(i, 40.0, RADAR[u][rPosX], RADAR[u][rPosY], RADAR[u][rPosZ]))
{
if(GetPlayerVehicleSpeed(i) > RADAR[u][rSpeed])
{
SendClientMessageEx(i, -1, "MULTADO!");
}
}
}
}
}
}
return true;
}
Re: radar causando rt -
Felipealves - 04.03.2019
Deve ta sendo chamada a cada 500ms menos de 1s, e nгo tem um tempo definido para prox detecзгo, entгo ele fica chamando em 500s.
edit: e tambйm o loop foreach vai verificar cada player atй chegar em vocк e vai verificar todos os radar...
Crie um timer apenas para o player e me diga o que mudou.
Re: radar causando rt -
ChavesS - 04.03.2019
Testa aн men, eu nгo testei.
Codigo:
task Velocimetro[500](playerid)
{
if(!gPlayerLogged[playerid]) continue;
if(IsPlayerInAnyVehicle(playerid))
{
static Float:_hp;
static playervehicle;
new _v = GetPlayerVehicleID(playerid);
if ( (playervehicle = GetPlayerVehicleID(playerid)) != INVALID_VEHICLE_ID)
{
static string_velo[15];
format(string_velo, sizeof (string_velo), "%02d km/h", GetVehicleSpeed(playervehicle));
PlayerTextDrawSetString(playerid, textPlayerVelocimetro[1][playerid], string_velo);
GetVehicleHealth(_v, _hp);
format(string_velo, sizeof (string_velo), "%.0f%%", _hp/10);
PlayerTextDrawSetString(playerid, textPlayerVelocimetro[3][playerid], string_velo);
format(string_velo, sizeof (string_velo), "%02d Litros", Gas[playervehicle]);
PlayerTextDrawSetString(playerid, textPlayerVelocimetro[2][playerid], string_velo);
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) ^ 510 && GetVehicleModel(GetPlayerVehicleID(playerid)) ^ 481 && GetVehicleModel(GetPlayerVehicleID(playerid)) ^ 509)
{
if(IsPlayerInRangeOfPoint(playerid, 40.0, RADAR[u][rPosX], RADAR[u][rPosY], RADAR[u][rPosZ]))
{
if(GetPlayerVehicleSpeed(playerid) > RADAR[u][rSpeed])
{
SendClientMessageEx(playerid, -1, "MULTADO!");
}
}
}
}
return true;
}
Re: radar causando rt -
ipsLuan - 04.03.2019
Quando for usar task com parвmetros, tem que usar ptask.