Nearby TextDraw
#1

How to PlayerTextDrawShow for nearby players??
Reply
#2

PHP код:
new Float:xFloat:yFloat:z;
GetPlayerPos(playeridxyz);
for(new 
nearbyid 0maxid GetPlayerPoolSize(); nearbyid <= maxidnearby++)
     if(
IsPlayerConnected(nearbyid) && IsPlayerInRangeOfPoint(nearby5/* Nearby radius*/xyz))
          
PlayerTextDrawShow(playeridPlayerText:ID); 
Reply
#3

PHP код:
CMD:houselights(playeridparams[])
{
    new 
idx PlayerInfo[playerid][pHouse]; new string[128];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playeridCOLOR_GREY"You don't own a house.");
    if(
GetPlayerVirtualWorld(playerid)-500 != idx && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playeridCOLOR_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(playeridCOLOR_GREY"You are not inside your house.");
    }
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    for(new 
nearbyid 0maxid GetPlayerPoolSize(); nearbyid <= maxidnearbyid++)
    if(
HouseInfo[idx][hLights] == 1)
    {
        
format(stringsizeof(string), "* %s presses a button, turns the lights on."RPN(playerid));
        
SendNearbyMessage(playerid20stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
        
PlayerTextDrawHide(nearbyidHouseLights[nearbyid]);
        
HouseInfo[idx][hLights] = 0;
    }
    else
    {
        
format(stringsizeof(string), "* %s presses a button, turns the lights off."RPN(playerid));
        
SendNearbyMessage(playerid20stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
        
PlayerTextDrawShow(nearbyidHouseLights[nearbyid]);
        
HouseInfo[idx][hLights] = 1;
    }    
    return 
1;

Now this is the whole cmd, it still shows to every single person in the server, and the message of the on/off turning sends nearby like 3 times or smth..

EDIT: Sorry, i forgot to add the IsPlayerInRangeOfPoint, I've added it now and testing..
Reply
#4

Have you got any idea at all what you've done with your code? ..

I can't bother fixing your code for you, it's too awful, just read the code and use common sense to resolve your issue.
Reply
#5

I still have got a problem in here.. And the loop which u sent me at the beginning won't work, It just sends the message with the number of online players, as well it will be checking every single player, no other method / A fix for the code you sent?
Reply
#6

Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)