05.07.2017, 18:48
How to PlayerTextDrawShow for nearby players??
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new nearbyid = 0, maxid = GetPlayerPoolSize(); nearbyid <= maxid; nearby++)
if(IsPlayerConnected(nearbyid) && IsPlayerInRangeOfPoint(nearby, 5/* Nearby radius*/, x, y, z))
PlayerTextDrawShow(playerid, PlayerText:ID);
CMD:houselights(playerid, params[])
{
new idx = PlayerInfo[playerid][pHouse]; new string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
if(GetPlayerVirtualWorld(playerid)-500 != idx && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
if(GetPlayerVirtualWorld(playerid)-500 != idx && PlayerInfo[playerid][pVHouse])
{
idx = PlayerInfo[playerid][pVHouse];
if(GetPlayerVirtualWorld(playerid)-500 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new nearbyid = 0, maxid = GetPlayerPoolSize(); nearbyid <= maxid; nearbyid++)
if(HouseInfo[idx][hLights] == 1)
{
format(string, sizeof(string), "* %s presses a button, turns the lights on.", RPN(playerid));
SendNearbyMessage(playerid, 20, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerTextDrawHide(nearbyid, HouseLights[nearbyid]);
HouseInfo[idx][hLights] = 0;
}
else
{
format(string, sizeof(string), "* %s presses a button, turns the lights off.", RPN(playerid));
SendNearbyMessage(playerid, 20, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerTextDrawShow(nearbyid, HouseLights[nearbyid]);
HouseInfo[idx][hLights] = 1;
}
return 1;
}
COMMAND:houselights(playerid, params[])
{
new string[128];
new idx = PlayerInfo[playerid][pHouse];
if(!IsPlayerLoggedIn(playerid))
return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse])
return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
if(GetPlayerVirtualWorld(playerid)-500 != idx && !PlayerInfo[playerid][pVHouse])
return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
if(GetPlayerVirtualWorld(playerid)-500 != idx && PlayerInfo[playerid][pVHouse])
{
idx = PlayerInfo[playerid][pVHouse];
if(GetPlayerVirtualWorld(playerid)-500 != idx)
return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
}
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if (IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 7.0, x, y, z))
{
if(HouseInfo[idx][hLights] == 1)
{
format(string, sizeof(string), "* %s presses a button, turns the lights on.", RPN(playerid));
SendNearbyMessage(playerid, 20, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerTextDrawHide(i, HouseLights[i]);
HouseInfo[idx][hLights] = 0;
}
else
{
format(string, sizeof(string), "* %s presses a button, turns the lights off.", RPN(playerid));
SendNearbyMessage(playerid, 20, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerTextDrawShow(i, HouseLights[i]);
HouseInfo[idx][hLights] = 1;
}
}
}
return 1;
}