Player Loop Question ?
#1

Hello guys i have a script here and inside i am checking for if a player is in area or not if he is in then send him a message, my problem is the message keeps spamming my screen and crashes the game so how can i make it so when i enter the area the message appears once only once not more here's the code :
pawn Code:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(/* My Area Check */)
        {
            SendClientMessage(playerid, -1, "you are in");
        }
    }
    return 1;
}
Reply
#2

Use Incognito's streamer's OnPlayerEnterDynamicArea.
Reply
#3

Also don't put player loops in OnPlayerUpdate.

It can be thought of a loop itself. It gets called several times each second, for each player.

pawn Code:
public OnPlayerUpdate(playerid)
{
    if(/* My Area Check(playerid) */)
    {
        SendClientMessage(playerid, -1, "you are in");
    }
    return 1;
}
Reply
#4

Quote:

Use Incognito's streamer's OnPlayerEnterDynamicArea.

I already have my area checking system it is working i tried, i just need a way to send that message 1 time not spam the screen
Quote:

Also don't put player loops in OnPlayerUpdate.

It can be thought of a loop itself. It gets called several times each second, for each player.

An Example will be nice
Reply
#5

I edited my post.

It will still spam though.
Reply
#6

Quote:
Originally Posted by iggy1
View Post
I edited my post.
No really dont u have a solution ?
Reply
#7

Like MP2 said.

pawn Code:
new some_area = CreateDynamicRectangle(...);

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == some_area)
    {
        SendClientMessage(playerid, -1, "you are in");//this will be sent once and wont spam
    }
    return 1;
}
It would require a lot more code to do it properly inside OnPlayerUpdate which i haven't got the time to write and test.
Reply
#8

pawn Code:
public OnPlayerUpdate(playerid)
{
    static flag=0;
    if(/* My Area Check(playerid) */)
    {
        if(flag!=1){
             flag=1;
             SendClientMessage(playerid, -1, "you are in");
             }
    }
    else flag=0;
    return 1;
}
Reply
#9

Quote:
Originally Posted by iggy1
View Post
Like MP2 said.

pawn Code:
new some_area = CreateDynamicRectangle(...);

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(areaid == some_area)
    {
        SendClientMessage(playerid, -1, "you are in");//this will be sent once and wont spam
    }
    return 1;
}
It would require a lot more code to do it properly inside OnPlayerUpdate which i haven't got the time to write and test.
Yes ok thanks but i really dont want to use streamer i have my own
Reply
#10

Quote:
Originally Posted by Roko_foko
View Post
pawn Code:
public OnPlayerUpdate(playerid)
{
    static flag=0;
    if(/* My Area Check(playerid) */)
    {
        if(flag!=1){
             flag=1;
             SendClientMessage(playerid, -1, "you are in");
             }
    }
    else flag=0;
    return 1;
}
It will be good if you explain it more, like what are the flags please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)