Creating a textdraw is player is in range -
Ahrim - 15.09.2013
Hello SAMPians :P,
Is there a way to create a textdraw if player is in range of point and destroys the textdraw as soon as the player leaves the point?
If so, can you tell me how to do so, and where do I put the script at? Thanks.
Here's for example,
pawn Код:
for(new i = 0; i < MAX_STADIUMS; ++i)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, StadiumInfo[i][sEX], StadiumInfo[i][sEY], StadiumInfo[i][sEZ]))
{
DefinedVar[playerid] = TextDrawCreate(85.000000, 322.000000, "Stadium Entrance, You Are At.");
textdrawscount++;
TextDrawAlignment(DefinedVar[playerid], 2);
TextDrawBackgroundColor(DefinedVar[playerid], 255);
TextDrawFont(DefinedVar[playerid], 0);
TextDrawLetterSize(DefinedVar[playerid], 0.809998, 1.500000);
TextDrawColor(DefinedVar[playerid], -1);
TextDrawSetOutline(DefinedVar[playerid], 1);
TextDrawSetProportional(DefinedVar[playerid], 1);
TextDrawShowForPlayer(playerid, DefinedVar[playerid]);
}
}
(P/S: The code is just for an example, it might not work :P)
So.. The part where it checks if IsPlayerInRangeOfPoint is done, but how to delete it after player isnt in it anymore?
Re: Creating a textdraw is player is in range -
NeroX98 - 15.09.2013
You must have any timer who repeats every 1-2 second, put the code for deleting the textdraw under the timer
Re: Creating a textdraw is player is in range -
Ahrim - 15.09.2013
What do you mean? Did you mean like, Add a Timer for 2 seconds
And checks if the player is still in the same coord after the timer ends, continue the timer again?
If the player isnt, destroy the Textdraw?
Re: Creating a textdraw is player is in range -
Finn - 15.09.2013
I'd use the Streamer plugin for that.
https://sampforum.blast.hk/showthread.php?tid=102865
pawn Код:
new stadium_areaids[MAX_STADIUMS];
public OnGameModeInit()
{
for(new i = 0; i < MAX_STADIUMS; ++i)
{
stadium_areaids[i] = CreateDynamicSphere(StadiumInfo[i][sEX], StadiumInfo[i][sEY], StadiumInfo[i][sEZ], 2.0);
}
return 1;
}
pawn Код:
public OnPlayerEnterDynamicArea(playerid, areaid)
{
for(new i = 0; i < MAX_STADIUMS; ++i)
{
if(stadium_areaids[i] == areaid)
{
// Show textdraw
return 1;
}
}
return 1;
}
pawn Код:
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
for(new i = 0; i < MAX_STADIUMS; ++i)
{
if(stadium_areaids[i] == areaid)
{
// Hide textdraw
return 1;
}
}
return 1;
}
Re: Creating a textdraw is player is in range -
NeroX98 - 15.09.2013
The user above has better solution for this problem... Creating sphere is much better than creating timer on 2 seconds...
Re: Creating a textdraw is player is in range -
Ahrim - 15.09.2013
Why thank you.