ProxDetector problem
#1

I've made my ProxDetector, but whenever i type something, it shows up for myself, but it doesn't show up for others...

And whenever my friend types something, it shows up for me, but it doesnt for him...
help would be much appriciated..

Код:
stock SendLocalMessage(playerid, range, string[])
{
	new Float:proxX, Float:proxY, Float:proxZ;
	GetPlayerPos(playerid, proxX, proxY, proxZ);
	
	for (new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
		{
			if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/3)
			{
				SendClientMessage(i, COLOR_FADE_1, string);
				return 1;
			}
			if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.9)
			{
				SendClientMessage(i, COLOR_FADE_2, string);
				return 1;
			}
			if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.5)
			{
				SendClientMessage(i, COLOR_FADE_3, string);
				return 1;
			}
			if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.2)
			{
				SendClientMessage(i, COLOR_FADE_4, string);
				return 1;
			}
			if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range)
			{
				SendClientMessage(i, COLOR_FADE_5, string);
				return 1;
			}
		}
	}
	return 1;
}
Reply
#2

the problem was it stopped the script( return 1; ) the first time it went through the loop.
pawn Код:
stock SendLocalMessage(playerid, range, string[])
{
    new Float:proxX, Float:proxY, Float:proxZ;
    GetPlayerPos(playerid, proxX, proxY, proxZ);
   
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/3)
            {
                SendClientMessage(i, COLOR_FADE_1, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.9)
            {
                SendClientMessage(i, COLOR_FADE_2, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.5)
            {
                SendClientMessage(i, COLOR_FADE_3, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.2)
            {
                SendClientMessage(i, COLOR_FADE_4, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range)
            {
                SendClientMessage(i, COLOR_FADE_5, string);
            }
        }
    }
    return 1;
}
that should work.
Reply
#3

Does anyone know, if its possible to make: SendLocalMessage(playerid, range, string[], format) like SendLocalMessage(playerid, 20.0, "%s is stupid", playername(playerid)); ?
Reply
#4

Quote:
Originally Posted by MeDaKewlDude
Посмотреть сообщение
the problem was it stopped the script( return 1; ) the first time it went through the loop.
pawn Код:
stock SendLocalMessage(playerid, range, string[])
{
    new Float:proxX, Float:proxY, Float:proxZ;
    GetPlayerPos(playerid, proxX, proxY, proxZ);
   
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/3)
            {
                SendClientMessage(i, COLOR_FADE_1, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.9)
            {
                SendClientMessage(i, COLOR_FADE_2, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.5)
            {
                SendClientMessage(i, COLOR_FADE_3, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range/1.2)
            {
                SendClientMessage(i, COLOR_FADE_4, string);
            }
            else if(GetPlayerDistanceFromPoint(i, proxX, proxY, proxZ) <= range)
            {
                SendClientMessage(i, COLOR_FADE_5, string);
            }
        }
    }
    return 1;
}
that should work.
Yep, worked, thanks!
Reply
#5

Quote:
Originally Posted by ddnbb
Посмотреть сообщение
Does anyone know, if its possible to make: SendLocalMessage(playerid, range, string[], format) like SendLocalMessage(playerid, 20.0, "%s is stupid", playername(playerid)); ?
yes.
pawn Код:
#if !defined FMsg
new stock FMsg[400];
#endif

#define SendLocalMessagef(%0,%1,%2) format(FMsg, sizeof(FMsg), %2), SendLocalMessage(%0,%1,FMsg)
Код:
Usage: SendLocalMessagef(playerid, 20.0, "%s is stupid", playername(playerid));
Reply
#6

Quote:
Originally Posted by MeDaKewlDude
Посмотреть сообщение
yes.
pawn Код:
#if !defined FMsg
new stock FMsg[400];
#endif

#define SendLocalMessagef(%0,%1,%2) format(FMsg, sizeof(FMsg), %2), SendLocalMessage(%0,%1,FMsg)
Код:
Usage: SendLocalMessagef(playerid, 20.0, "%s is stupid", playername(playerid));
Isn't [400] too much? How about without the range, can you give me that code? Thank you so much i have been looking this for long time.
Reply
#7

no, there is no limit to array lengths. i have 400 because of longer strings, but i guess you could have it as something more like 200.
pawn Код:
#if !defined FMsg
new stock FMsg[200];
#endif

#define SendClientMessagef(%0,%1,%2) format(FMsg, sizeof(FMsg), %2), SendClientlMessage(%0,%1,FMsg)
#define SendClientMessageToAllf(%0,%1) format(FMsg, sizeof(FMsg), %1), SendClientlMessage(%0,FMsg)
theres SendClientMessagef and SendClientMessageToAllf if you want, i could give you the code that Sends a message to all if the playerid is -1, or you could just use SendClientMessageToAllf.
Reply
#8

Quote:
Originally Posted by MeDaKewlDude
Посмотреть сообщение
no, there is no limit to array lengths. i have 400 because of longer strings, but i guess you could have it as something more like 200.
pawn Код:
#if !defined FMsg
new stock FMsg[200];
#endif

#define SendClientMessagef(%0,%1,%2) format(FMsg, sizeof(FMsg), %2), SendClientlMessage(%0,%1,FMsg)
#define SendClientMessageToAllf(%0,%1) format(FMsg, sizeof(FMsg), %1), SendClientlMessage(%0,FMsg)
theres SendClientMessagef and SendClientMessageToAllf if you want, i could give you the code that Sends a message to all if the playerid is -1, or you could just use SendClientMessageToAllf.
I want it like this, but i get a warning:
pawn Код:
#if !defined FMsg
new stock FMsg[256];
#endif

#define SendLocalMessagef(%0,%1) format(FMsg, sizeof(FMsg), %1), SendLocalMessage(%0,FMsg)
Usage: stock SendLocalMessage(playerid, string[])
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)