SA-MP Forums Archive
bugged Sendclientmessage? - 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: bugged Sendclientmessage? (/showthread.php?tid=280616)



bugged Sendclientmessage? - uprp - 02.09.2011

i've recently added an agency for ad's, and when someone is out of it, i scripted this:

pawn Код:
for(new i = 0; i < sizeof(BizInfo); i++)
            {
                if(!IsPlayerInRangeOfPoint(playerid,25.0,822.1263,2.8237,1004.1797))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You are not in an advertising agency or at the desk");
                }
But it ends up bugging your whole screen with

Example: Sorry 4 the spam

You are not in an advertising agency or at the desk
You are not in an advertising agency or at the desk
You are not in an advertising agency or at the desk
And your whole chatbox gets filled up.. any solutions?


Re: bugged Sendclientmessage? - [MWR]Blood - 02.09.2011

pawn Код:
for(new i = 0; i < sizeof(BizInfo); i++)
            {
                if(!IsPlayerInRangeOfPoint(i,25.0,822.1263,2.8237,1004.1797))
                {
                    SendClientMessage(i, COLOR_WHITE, "You are not in an advertising agency or at the desk");
                }



Re: bugged Sendclientmessage? - Basicz - 02.09.2011

variables, obviously

pawn Код:
new
    bool: sendMsg[ MAX_PLAYERS ]
;

public OnPlayerConnect( playerid )
{
    sendMsg[ playerid ] = true;

    return 1;
}

// ...

for(new i = 0; i < sizeof(BizInfo); i++)
            {
                if(!IsPlayerInRangeOfPoint(playerid,25.0,822.1263,2.8237,1004.1797))
                {
                    if ( sendMsg[ playerid ] ) {
                    SendClientMessage(playerid, COLOR_WHITE, "You are not in an advertising agency or at the desk");
                    sendMsg[ playerid ] = false;
                    } }
EDIT: wtf? loop?
Why do you even need that loop?

pawn Код:
if ( !IsPlayerInRangeOfPoint( ... ) )
    return SendClientMessage( playerid, COLOR_WHITE, "You are not in an advertising agency or at the desk." );



Re: bugged Sendclientmessage? - FireCat - 02.09.2011

Wrong.
Imagine bizinfo is 25.
It will loop 25 times to check if he's in range of point, if he is, send 25 times.
So I'd just do
pawn Код:
if(!IsPlayerInRangeOfPoint(playerid,25.0,822.1263,2.8237,1004.1797))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You are not in an advertising agency or at the desk");
                }



Re: bugged Sendclientmessage? - [MWR]Blood - 02.09.2011

Quote:
Originally Posted by Basicz
Посмотреть сообщение
variables, obviously

pawn Код:
new
    bool: sendMsg[ MAX_PLAYERS ]
;

public OnPlayerConnect( playerid )
{
    sendMsg[ playerid ] = true;

    return 1;
}

// ...

for(new i = 0; i < sizeof(BizInfo); i++)
            {
                if(!IsPlayerInRangeOfPoint(playerid,25.0,822.1263,2.8237,1004.1797))
                {
                    if ( sendMsg[ playerid ] ) {
                    SendClientMessage(playerid, COLOR_WHITE, "You are not in an advertising agency or at the desk");
                    sendMsg[ playerid ] = false;
                    } }
Try it.
No, I don't see how would that help.
His mistake was, doing a loop but still using the player's id.


Re: bugged Sendclientmessage? - Basicz - 02.09.2011

You got the weird thing.

HIS MISTAKE WAS : Running an unused loop.


Re: bugged Sendclientmessage? - FireCat - 02.09.2011

Quote:
Originally Posted by Basicz
Посмотреть сообщение
You got the weird thing.

HIS MISTAKE WAS : Running an unused loop.
So what did I just explained?


Re: bugged Sendclientmessage? - [MWR]Blood - 02.09.2011

Quote:
Originally Posted by Basicz
Посмотреть сообщение
You got the weird thing.

HIS MISTAKE WAS : Running an unused loop.
Yes.
And why did you just make some vars to send a message?


Re: bugged Sendclientmessage? - Basicz - 02.09.2011

Sorry for being off topic,

@ FireCat,
Sorry, didn't see your post, and I was talking to [MWR]Blood.

@ [MWR]Blood
I misunderstood it. I didn't see he runs a unused loop. Sorry.


Re: bugged Sendclientmessage? - uprp - 02.09.2011

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
pawn Код:
for(new i = 0; i < sizeof(BizInfo); i++)
            {
                if(!IsPlayerInRangeOfPoint(i,25.0,822.1263,2.8237,1004.1797))
                {
                    SendClientMessage(i, COLOR_WHITE, "You are not in an advertising agency or at the desk");
                }
Thank you. + rep.