Help me make this work better?
#1

I have a problem with a automatic gate I created, although it works, sometimes it spams even though I created something to stop it, anyway is there a better way to make this?

pawn Код:
if(IsPlayerInRangeOfPoint(playerid,10,1549.59997559,-1630.00000000,12.60000038))
    {
        if(PlayerInfo[playerid][pFaction] == 2 && PlayerInfo[playerid][pSpam] == 0)
        {
            PlayerInfo[playerid][pSpam] = 1; // To stop spam (.. && PlayerInfo[playerid][pSpam] == 0))
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s uses their remote to open the gates.", name);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            MoveObject(Gate, 1549.59997559,-1630.00000000,12.60000038, 10);
            SetTimer("LSPDGateClose",5000,1); // closes the gate after the time set
            SetTimer("SpamStop",5000,1); // Sets a timer to avoid spam
        }
    }
I cant find any way to do it, setting the time longer doesn't help either, sometimes it still spams.
Reply
#2

pawn Код:
public SpamStop(playerid)
{
PlayerInfo[playerid][pSpam] = 0;
}

// ...
pawn Code:
if(IsPlayerInRangeOfPoint(playerid,10,1549.59997559,-1630.00000000,12.60000038))
    {
        if(PlayerInfo[playerid][pFaction] == 2 && PlayerInfo[playerid][pSpam] == 0)
        {
            PlayerInfo[playerid][pSpam] = 1; // To stop spam (.. && PlayerInfo[playerid][pSpam] == 0))
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s uses their remote to open the gates.", name);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            MoveObject(Gate, 1549.59997559,-1630.00000000,12.60000038, 10);
            SetTimer("LSPDGateClose",5000,1); // closes the gate after the time set
            SetTimerEx("SpamStop",5000,false, "i", playerid); // Sets a timer to avoid spam
        }
    }
Here, try that one. I haven't tested it though.
Reply
#3

Already have the public spam stop.
pawn Код:
public SpamStop(playerid)
{
    PlayerInfo[playerid][pSpam] = 0;
    return 1;
}
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
How is this code called? If it is being spammed there's a loop somewhere outside the code you posted, or something being reset when it shouldn't be.
Hmm Im not sure what you mean, Ill post the whole code:
pawn Код:
public OnPlayerUpdate(playerid)
{
    new name[MAX_PLAYER_NAME];
    new string[50 + MAX_PLAYER_NAME];
    if(IsPlayerInRangeOfPoint(playerid,10,1549.59997559,-1630.00000000,12.60000038))
    {
        if(PlayerInfo[playerid][pFaction] == 2 && PlayerInfo[playerid][pSpam] == 0)
        {
            PlayerInfo[playerid][pSpam] = 1;
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s uses their remote to open the gates.", name);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            MoveObject(Gate, 1549.59997559,-1630.00000000,12.60000038, 10);
            SetTimer("LSPDGateClose",7000,1);
            SetTimer("SpamStop",7000,1);
        }
    }
Everything after that point is for something else..

pawn Код:
public SpamStop(playerid)
{
    PlayerInfo[playerid][pSpam] = 0;
    return 1;
}
pawn Код:
public LSPDGateClose(playerid)
{
    MoveObject(Gate, 1549.59997559,-1623.00000000,12.60000038, 10);
    return 1;
}
That is everything that is relevant to the gate, there is nothing else.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)