SA-MP Forums Archive
GameTextForPlayer Issue. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: GameTextForPlayer Issue. (/showthread.php?tid=283744)



GameTextForPlayer Issue. - Dokins - 16.09.2011

pawn Code:
new playerid = MAX_PLAYERS;
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 321.1703,308.9879,999.1484) && Faction[playerid] == 1)
    GameTextForPlayer(playerid, "~b~Police Health ~n~~w~ /health", 3000, 5);
This doesnt work the way it should, this is posted under OnGameModeInit.

If I post it under

CMD:health

it only displays when the command is executed, where do I place the GTFP so that it displays when the person is in the range of that point?


Re: GameTextForPlayer Issue. - [MWR]Blood - 16.09.2011

Do a new callback and place it there.
Set a timer to call that callback.


Re: GameTextForPlayer Issue. - Sinner - 16.09.2011

pawn Code:
new timer;

public OnGameModeInit() {
    timer = SetTimer("CheckPlayer", 2000, true); // your timer, checks every 2 seconds
}

public OnGameModeExit() {
    KillTimer(timer);
}

forward CheckPlayer();
public CheckPlayer() {
    // For loop, you can also use "foreach" for this (include by Y_Less)
    for(new i=0;i<MAX_PLAYERS;i++) {
        if(IsPlayerInRangeOfPoint(i, 5.0, 321.1703,308.9879,999.1484) && Faction[i] == 1))
            GameTextForPlayer(i, "~b~Police Health ~n~~w~ /health", 3000, 5);
    }
}



Re: GameTextForPlayer Issue. - Dokins - 18.09.2011

Thanks! + rep!