pawn Код:
new SavePlayerPos[SLOTS][SavePlayerPosEnum];
new distance1[MAX_PLAYERS];
public UpdateSpeed(playerid)
{
new Float:x,Float:y,Float:z;
new Float:distance,value;
for(new i=0; i<SLOTS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(i, x, y, z);
distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
value = floatround(distance * 3600);
if(UpdateSeconds > 1)
{
value = floatround(value / UpdateSeconds);
}
distance1[i] = floatround(value/1600);
SavePlayerPos[i][LastX] = x;
SavePlayerPos[i][LastY] = y;
SavePlayerPos[i][LastZ] = z;
AddFlitsPaal(i, 2600, 2153.0537,-1104.5266,25.3871, 25, 100);
AddFlitsPaal(i, 2600, 1978.0360,-1752.1967,13.3828, 25, 100);
AddFlitsPaal(i, 2600, 1566.7903,-1732.3861,13.3828, 25, 100);
AddFlitsPaal(i, 2600, 591.5465,-1731.4254,13.5286, 25, 60);
AddFlitsPaal(i, 2600, 1849.4377,-1285.5669,13.3828, 25, 100);
AddFlitsPaal(i, 2600, 1706.9758,-508.3388,34.1688, 25, 100);
}
}
}
GetPlayerDistanceToPoint1(playerid,Float:x,Float:y)
{
new Float:x1,Float:y1,Float:z1; GetPlayerPos(playerid,x1,y1,z1);
new Float:tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+
floatpower(floatabs(floatsub(y,y1)),2));
return floatround(tmpdis);
}
IsPlayerInCircle(playerid,Float:x,Float:y,radius)
{
if(GetPlayerDistanceToPoint1(playerid,Float:x,Float:y) < radius)
{
return 1;
}
return 0;
}
stock AddFlitsPaal(playerid, modelid, Float:xx, Float:yy, Float:zz, radius, speed)
{
new fine[MAX_PLAYERS];
new str[256];
if(objectcreated!=maxobject)
{
CreateObject(modelid, xx, yy, zz, 0.0, 0.0, 10);
objectcreated++;
}
if((distance1[playerid])>speed)
{
if(IsPlayerInCircle(playerid, xx, yy, radius) && GetPlayerState(playerid)== PLAYER_STATE_DRIVER)
{
fine[playerid]=((distance1[playerid]*17/10)-speed);
GameTextForPlayer(playerid, "~r~MULTADO!", 3000, 0);
format(str,sizeof(str), "Limite ultrapassado:{D50000}%d{FFFFFF}km/h!",speed, distance1[playerid] ,fine[playerid]);
SendClientMessage(playerid, 0xFFFFFFAA, str);
SendClientMessage(playerid, 0xFFFFFFAA, "O valor de sua multa foi de {16EB43}425 reais{FFFFFF}!");
GivePlayerMoneyEx(playerid, -425);
SetTimerEx("Radarxx", 10000, false, "i", playerid);
PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
}
}
}