SendClientMessage Loop - 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: SendClientMessage Loop (
/showthread.php?tid=370109)
SendClientMessage Loop Problem -
Emrets61 - 19.08.2012
I'm using SendClientMessage at Pickups. When I was wait on a pickup, the SendClientMessage is looping. How can I solve this? I want to display it only once.
Code:
Код:
if(pickupid == test)
{
SendClientMessage(playerid, COLOR_RED, "TEST");
}
How is it work:
TEST
TEST
TEST
TEST
TEST
... loop
Re: SendClientMessage Loop -
RedJohn - 19.08.2012
Make a bool.
Re: SendClientMessage Loop -
[MM]RoXoR[FS] - 19.08.2012
pawn Код:
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid,"PickupTime",0);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == test)
{
new time = GetPVarInt(playerid,"PickupTime");
if((gettime()-time)>10)//10 is no of seconds
{
SendClientMessage(/*Message*/);
SetPVarInt(playerid,"PickupTime",gettime());
}
}
return 1;
}
Re: SendClientMessage Loop -
RedJohn - 19.08.2012
RoXoR, i made this with bool and its same as your code, if i'm standing on pickup, it's always show:
TEST
TEST
TEST
TEST
Re: SendClientMessage Loop -
[MM]RoXoR[FS] - 19.08.2012
It will SendMessage after 10 seconds if you are standing on pickup.
If you want server to send Message only once, irrespective of time you stay on pickup, I would suggest to use a streamer.
Create a circular area around pickup,
pawn Код:
area1 = CreateDynamicCircle(Float:x, Float:y, Float:size, worldid = -1, interiorid = -1, playerid = -1);
when player leave area
pawn Код:
public OnPlayerLeaveDynamicArea(playerid, areaid)
{
if(areaid == area1) {
SetPVarInt(playerid,"SendMessage",1); }
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == test)
{
switch(GetPVarInt(playerid,"SendMessage")
{
case 1:
{
SendClientMessage(/*Message*/);
SetPVarInt(playerid,"SendMessage",0);
}
}
}
return 1;
}
Re: SendClientMessage Loop -
Universal - 19.08.2012
https://sampwiki.blast.hk/wiki/PickupTypes
Just use another pickup type (I suggest using 2).
Re: SendClientMessage Loop -
Emrets61 - 20.08.2012
Any suggestions?