Identify Player...
#5

pawn Код:
#include <a_samp>
#include <YSI\y_hooks>
#include <OPTP>

new aimid[MAX_PLAYERS];
new aimtime[MAX_PLAYERS];
new aimtimer[MAX_PLAYERS];

hook OnPlayerSpawn(playerid)
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        ShowPlayerNameTagForPlayer(playerid,i,false); //DISABLES EVERYONES NAMETAGS FOR THE PLAYER
        ShowPlayerNameTagForPlayer(i,playerid,false); //DISABLES THE PLAYERS NAMETAG FOR EVERYONE ELSE.
    }
    return 1;
}

/*public OnPlayerTargetPlayer(playerid,newtarget,oldtarget)
{
    if(newtarget != INVALID_PLAYER_ID && aimtime[playerid] == 0)
    {
        aimtimer = SetTimerEx("Aimtime",500,1,"dd",playerid,newtarget); // START THE TIMER TO CHECK IF THE PLAYER SIMULTANEOUSLY AIMS AT THE TARGET FOR 2,5 SECONDS
        aimid[playerid] = newtarget; //DEFINES THAT PLAYER IS AIMING, USED FOR PREVENTING TIMER REPEAT
        aimtime[playerid] = 1;
    }
    return 1;
}*/


hook OnPlayerUpdate(playerid)
{
    new aimID = GetPlayerTargetPlayer(playerid); //GET THE PLAYER'S TARGET
    if(aimID == aimid[playerid]) return 1; //PREVENT THE TIMER FROM STARTING IF ALREADY STARTED, CREATING 1247375735 DIFFERENT TIMERS
    if(aimID != INVALID_PLAYER_ID && aimtime[playerid] == 0) //CHECK IF PLAYER IS AMAING ON SOMEONE AND IF PLAYER ISNT AIMING AT SOMEONE ELSE
    {
        aimtimer[playerid] = SetTimerEx("Aimtime",500,1,"dd",playerid); // START THE TIMER TO CHECK IF THE PLAYER SIMULTANEOUSLY AIMS AT THE TARGET FOR 2,5 SECONDS
        aimid[playerid] = aimID; //DEFINES THAT PLAYER IS AIMING, USED FOR PREVENTING TIMER REPEAT
        aimtime[playerid] = 1;
    }
    return 1;
}

forward Aimtime(playerid);
public Aimtime(playerid)
{
    if(GetPlayerTargetPlayer(playerid) != aimid[playerid])
    {
        KillTimer(aimtimer[playerid]); //CHECK IF PLAYER HAS STOPPED AIMING ON THE TARGET, IF SO, CANCEL TIMER.
        aimtime[playerid] = 0;
        aimid[playerid] = -1;
        return 1;
    }
    if(aimtime[playerid] == 5) //IF THE PLAYER HAS AIMED ON THE TARGET SIMULTANEOUSLY FOR 2,5 SECONDS, SHOW THE TARGETS NAMETAG FOR 5 SECONDS.
    {
        ShowPlayerNameTagForPlayer(playerid,aimid[playerid],true); //SHOWS THE TARGETS NAMETAG
        SetTimerEx("Hidenametag",5000,0,"dd",playerid,aimid[playerid]); //SETS A TIMER TO DISABLE THE NAMETAG AFTER 5 SECONDS.
        KillTimer(aimtimer[playerid]);
        return 1;
    }
    aimtime[playerid] ++; //IF THE PLAYER HASNT AIMED FOR 2,5 SECONDS YET, COUNT +1.
    return 1;
}

forward Hidenametag(playerid,aimID);
public Hidenametag(playerid,aimID)
{
    ShowPlayerNameTagForPlayer(playerid,aimID,false); //HIDES THE NAMETAG FOR THE PLAYER
    aimtime[playerid] = 0; //SETS AIMTIME TO 0, MAKING IT POSSIBLE FOR THE PLAYER TO IDENTIFY SOMEONE ELSE.
    aimid[playerid] = -1; //SETS THE AIMID TO -1, = NO PLAYER.
    return 1;
}
Fixed up the variable, resetted aimid and aimtime on timerkill. And removed AimID passing through the timer.

Still doesn't work :/
Reply


Messages In This Thread
Identify Player... - by introzen - 03.07.2013, 13:33
Re: Identify Player... - by Stylock - 03.07.2013, 14:18
Re: Identify Player... - by introzen - 03.07.2013, 14:28
Re: Identify Player... - by Stylock - 03.07.2013, 16:38
Re: Identify Player... - by introzen - 03.07.2013, 17:06
Re: Identify Player... - by Stylock - 03.07.2013, 17:22
Re: Identify Player... - by Ejikin91 - 02.12.2017, 19:52

Forum Jump:


Users browsing this thread: 1 Guest(s)