Spam issue
#1

How can I make this stop spamming like hell ?

Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    if(IsPlayerConnectedEx(i))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, -111.3551,1566.8140,17.5715))
		{
			if(IsGov(i) && duty[i])
			{
			
				SendClientMessageA(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");
				
			}
			
		}

    }
    return 1;
}
Reply
#2

if an extra variable

new bool:value[MAX_PLAYERS char];
Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    if(IsPlayerConnectedEx(i))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, -111.3551,1566.8140,17.5715) && value{playerid})
		{
			if(IsGov(i) && duty[i])
			{

				SendClientMessageA(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");
                value{playerid}= false;
			}

		}else value{playerid} = true;

    }
    return 1;
}
Reply
#3

Looping through all players on -every- OnPlayerUpdate is a stupid thing to do, it will only cause stress on your server.

You should use foreach by ****** https://sampforum.blast.hk/showthread.php?tid=92679 which loops only through online players.

And remember that on foot, OnPlayerUpdate is called something like 6-8 times a second and in a car like 20-30 times.

Why not simply use Incognito's streamer and create an area? https://sampforum.blast.hk/showthread.php?tid=102865

This would mean you can use the callback OnPlayerEnterDynamicArea.

But if you don't want to rely on that, atleast whack it in a 5-10 second timer as you really don't need to be checking something as petty as that 30 times a second.
Reply
#4

Quote:
Originally Posted by IPrototypeI
Посмотреть сообщение
if an extra variable

new bool:value[MAX_PLAYERS char];
Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    if(IsPlayerConnectedEx(i))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, -111.3551,1566.8140,17.5715) && value{playerid})
		{
			if(IsGov(i) && duty[i])
			{

				SendClientMessageA(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");
                value{playerid}= false;
			}

		}else value{playerid} = true;

    }
    return 1;
}
Still alot of spam.
Reply
#5

i am sry
Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    if(IsPlayerConnectedEx(i))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, -111.3551,1566.8140,17.5715))
		{
			if(IsGov(i) && duty[i] &&  value{playerid})
			{

				SendClientMessageA(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");
                value{playerid}= false;
			}

		}else value{playerid} = true;

    }
    return 1;
}
the problem on the code i posted before is that if the player is at the point the variable
is set for the player to false then if the timer call this statement again it call the else -statement because
the variable is set to false.
But to work with the Streamerplugin and the funktion CreateDynamicRectangle is a better idea
Reply
#6

Even though someone already posted some, I don't really recommend placing a function like,[pawn]SendClientMessage or print("Message");[/b] inside a loop

inside a MAX_PLAYERS variable = 500, if you put a SendClientMessage function inside the loop it will send the message 500 message, i'd rather use this, if i were you


pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, -111.3551,1566.8140,17.5715))  
    {
        if(IsGov(i) && duty[i]})
        {
            SendGovMessage(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");      
        }

    }
    return 1;
}

SendGovMessage(color, string[]);
{
    for(new i = 0; i < MAX_PLAYERS; i ++)  
    {
        if(IsPlayerConnectedEx(i)) 
        {
            SendClientMessageA(i, color, string);
        }
    }
}
Reply
#7

pawn Код:
new bool:PlayerInPoint[MAX_PLAYERS char];
connect
pawn Код:
PlayerInPoint{playerid} = false;
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10.0, -111.3551, 1566.8140, 17.5715))
    {
        if(!PlayerInPoint{playerid})
        {
            PlayerInPoint{playerid} = true;
            for(new i = 0; i < MAX_PLAYERS; i++)
                if(IsPlayerConnectedEx(i))
                    if(IsGov(i) && duty[i])
                        SendClientMessageA(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");
        }
        return 1;
    }
    PlayerInPoint{playerid} = false;
    return 1;
}
Reply
#8

use something like...

TOP OF SCRIPT:
pawn Код:
new messagesent[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    if(IsPlayerConnectedEx(i))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, -111.3551,1566.8140,17.5715) && value{playerid})
        {
            if(IsGov(i) && duty[i])
            {
                                if(messagesent[playerid] == 0)//added this
                                {
                SendClientMessageA(i,COLOR_FACTION,"[Ground Detector] We have detected a vehicle heading towards Area 51! Intercept it!");
                                messagesent[playerid] =1;//this too
                                }
                value{playerid}= false;
            }

        }else value{playerid} = true;

    }
    return 1;
}
You would need something to reset that variable after there is no player or w/e
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
You could use something like the streamer plugin or y_areas, which provide nice callbacks for when a player arrives near a point - to guarantee it only being called once.
A'right. I'll use streamer plugin.

Could you give me an exemple of what should I put ?
Reply
#10

Quote:
Originally Posted by Eugene.
Посмотреть сообщение
A'right. I'll use streamer plugin.

Could you give me an exemple of what should I put ?
pawn Код:
OnPlayerEnterDynamicArea(playerid, areaid)
CreateDynamicCube(Float:minx, Float:miny, Float:minz, Float:maxx, Float:maxy, Float:maxz, worldid = -1, interiorid = -1, playerid = -1);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)