Player Loop Question ? -
Mr.Fames - 06.07.2012
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;
}
Re: Player Loop Question ? -
MP2 - 06.07.2012
Use Incognito's streamer's OnPlayerEnterDynamicArea.
Re: Player Loop Question ? -
iggy1 - 06.07.2012
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;
}
Re: Player Loop Question ? -
Mr.Fames - 06.07.2012
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
Re: Player Loop Question ? -
iggy1 - 06.07.2012
I edited my post.
It will still spam though.
Re: Player Loop Question ? -
Mr.Fames - 06.07.2012
Quote:
Originally Posted by iggy1
I edited my post.
|
No really dont u have a solution ?
Re: Player Loop Question ? -
iggy1 - 06.07.2012
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.
Re: Player Loop Question ? -
Roko_foko - 06.07.2012
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;
}
Re: Player Loop Question ? -
Mr.Fames - 06.07.2012
Quote:
Originally Posted by iggy1
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
Re: Player Loop Question ? -
Mr.Fames - 06.07.2012
Quote:
Originally Posted by Roko_foko
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.