SendClientMessage Loop
#1

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
Reply
#2

Make a bool.
Reply
#3

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;
}
Reply
#4

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
Reply
#5

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;
}
Reply
#6

https://sampwiki.blast.hk/wiki/PickupTypes

Just use another pickup type (I suggest using 2).
Reply
#7

Any suggestions?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)