Trace player continuously
#1

Hi, I have a small find player script but im wondering how i could make it so that it will trace the player continuously instead of just a marker that will be placed.

Код:
CMD:find(playerid,params[])
{
	new id,str[128];
	new pname[MAX_PLAYER_NAME+1];
	if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /find [playerid]");
	if(Finding[id] == 0) return SendClientMessage(playerid,COLOR_LIGHTRED,"You Are not finding that player");
    if(Finding[id] == 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Player Already being found");
	if(playerid == id) return SendClientMessage(playerid,COLOR_LIGHTRED,"You Cannot Find your self.");
	if(IsACop(playerid) && PlayerInfo[playerid][pSwat] >= 1)
	{
		GetPlayerName(id,pname,sizeof(pname));
		format(str,sizeof(str),"You are now finding %s - they are marked on your map!",id);
    	SendClientMessage(playerid, COLOR_WHITE,str);
		SetPlayerMarkerForPlayer(playerid,id,0xFF0000FF);
    	Finding[id] = 1;
	}
	else
	{
	    SendClientMessage(playerid,COLOR_LIGHTRED,"You are not a cop or swat member !.");
	}
	return 1;
}

CMD:cfind(playerid,params[]) // Cancels the marker
{
	new id,str[128];
	new pname[MAX_PLAYER_NAME+1];
	if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /canclefindplayer [playerid]");
	if(Finding[id] == 0) return SendClientMessage(playerid,COLOR_LIGHTRED,"Player Not being found");
	GetPlayerName(id,pname,sizeof(pname));
	format(str,sizeof(str),"You have stopped finding %s - they have been removed from your map!",id);
	SendClientMessage(playerid, COLOR_WHITE,str);
	SetPlayerMarkerForPlayer(playerid,id,0xFFFFFF00);
	Finding[id] = 0;
	return 1;
}
Reply
#2

by using a timer
pawn Код:
new findtimer[MAX_PLAYERS];//on top

forward Trace(playerid, targetid);
public Trace(playerid, targetid)
{
SetPlayerMarkerForPlayer(playerid,targetid,0xFFFFFF00);
SetPlayerMarkerForPlayer(playerid,targetid,0xFF0000FF);
return 1;
}

CMD:find(playerid,params[])
{
    new id,str[128];
    new pname[MAX_PLAYER_NAME+1];
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /find [playerid]");
    if(Finding[id] == 0) return SendClientMessage(playerid,COLOR_LIGHTRED,"You Are not finding that player");
    if(Finding[id] == 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Player Already being found");
    if(playerid == id) return SendClientMessage(playerid,COLOR_LIGHTRED,"You Cannot Find your self.");
    if(IsACop(playerid) && PlayerInfo[playerid][pSwat] >= 1)
    {
        GetPlayerName(id,pname,sizeof(pname));
        format(str,sizeof(str),"You are now finding %s - they are marked on your map!",id);
        SendClientMessage(playerid, COLOR_WHITE,str);
        SetPlayerMarkerForPlayer(playerid,id,0xFF0000FF);
             findtimer[playerid] = SetTimerEx("Trace", 1000*5/*5secs*/, true, "ii",playerid, id);
        Finding[id] = 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_LIGHTRED,"You are not a cop or swat member !.");
    }
    return 1;
}

CMD:cfind(playerid,params[]) // Cancels the marker
{
    new id,str[128];
    new pname[MAX_PLAYER_NAME+1];
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /canclefindplayer [playerid]");
    if(Finding[id] == 0) return SendClientMessage(playerid,COLOR_LIGHTRED,"Player Not being found");
    GetPlayerName(id,pname,sizeof(pname));
    format(str,sizeof(str),"You have stopped finding %s - they have been removed from your map!",id);
    SendClientMessage(playerid, COLOR_WHITE,str);
         KillTimer(findtimer[playerid]);
    SetPlayerMarkerForPlayer(playerid,id,0xFFFFFF00);
    Finding[id] = 0;
    return 1;
}
Reply
#3

Thanks BroZeus, +rep for helping me out !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)