Nem teszteltem, de valószínűleg működni fog. Ha probléma van, szólj.
#include <a_samp>
#include <zcmd>
new Timer[MAX_PLAYERS];
new Float:DistanceTravelled[MAX_PLAYERS];
new Float:TPos[MAX_PLAYERS][3];
new bool:Duty[MAX_PLAYERS];
CMD:munka(playerid, params[])
{
if(Duty[playerid] == false)
{
GetPlayerPos(playerid, TPos[playerid][0], TPos[playerid][1], TPos[playerid][2]);
Timer[playerid] = SetTimerEx(\"Counter\", 800, true, \"i\", playerid);
SendClientMessage(playerid, 0, \"Elkezdtél doglozni...\");
}
else
{
new msg[128];
KillTimer(Timer[playerid]);
GivePlayerMoney(playerid, floatround(DistanceTravelled[playerid], floatround_round));
format(msg, sizeof(msg), \"Befejezted a munkát, kaptál %d dollárt %d megtett km-ért!\", floatround(DistanceTravelled[playerid], floatround_round), DistanceTravelled[playerid]);
SendClientMessage(playerid, 0, msg);
DistanceTravelled[playerid] = 0;
}
return 1;
}
forward Counter(playerid);
public Counter(playerid)
{
new Float:dist, msg[32];
dist = GetPlayerDistanceFromPoint(playerid, TPos[playerid][0], TPos[playerid][1], TPos[playerid][2]);
GetPlayerPos(playerid, TPos[playerid][0], TPos[playerid][1], TPos[playerid][2]);
DistanceTravelled[playerid] += dist;
format(msg, sizeof(msg), \"%f km\", DistanceTravelled[playerid]);
GameTextForPlayer(playerid, msg, 1000, 2);
return 1;
}