Help me
#1

I'm back again with this problem.
So if it's just me, however, goes well, but if there are more than 2 from round to round everything is spam, increasingly more, How can I do so in how not to be spam?



pawn Код:
if(strcmp(cmd, "/paintball", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerToPoint(5.0, playerid, 1328.6179, -1557.9896, 13.8794))
            {

                SetPlayerPos(playerid, -973.7964, 1077.2219, 1345.0875);
                SetPlayerInterior(playerid, 10), SetPlayerHealth(playerid, 100);
                SendClientMessage(playerid, COLOR_WHITE, "Pentru a vota o mapa sau o arma foloseste comanda {0976B0}/vote.");
                pPlayers ++, PlayerKills[playerid] = 0, InPaintball[playerid] = 1, pVoted = 1, VotedMap[playerid] = 0, VotedGun[playerid] = 0;
                if(pRound == 1)
                {
                    if(pGun[1] == 1) { GivePlayerWeapon(playerid, 24, 500); }
                    if(pGun[2] == 1) { GivePlayerWeapon(playerid, 25, 500); }
                    if(pGun[3] == 1) { GivePlayerWeapon(playerid, 31, 500); }
                    if(pGun[4] == 1) { GivePlayerWeapon(playerid, 27, 500); }
                    if(pGun[5] == 1) { GivePlayerWeapon(playerid, 4, 500); }
                    if(pGun[6] == 1) { GivePlayerWeapon(playerid, 5, 500); }
                }
                SetTimer("StartPaintball", 20000, false);
            }
        }
        return 1;
    }

forward StartPaintball();
public StartPaintball()
{
    if(pPlayers == 1)
    {
        SetTimer("StartPaintball", 20000, 0);
        pRound = 0;
    }
    else if(pPlayers >= 2) { pRound = 1; }
   
    if(pRound == 1)
    {
        pRound = 1, pVoted = 0, pWinner = -1, pWinnerScore = -1; new string[256];
        if(VoteGuns[1] > VoteGuns[2] && VoteGuns[1] > VoteGuns[3] && VoteGuns[1] > VoteGuns[4] && VoteGuns[1] > VoteGuns[5] && VoteGuns[1] > VoteGuns[6])
        {
            format(string, sizeof(string), "Cea mai votata arma a fost: Deagle. (%d voturi)", VoteGuns[1]);
            PaintMessage(COLOR_WHITE, string);
            PaintWeapon(24, 500);
            pGun[1] = 1;
        }
        else if(VoteGuns[2] > VoteGuns[1] && VoteGuns[2] > VoteGuns[3] && VoteGuns[2] > VoteGuns[4] && VoteGuns[2] > VoteGuns[5] && VoteGuns[2] > VoteGuns[6])
        {
            format(string, sizeof(string), "Cea mai votata arma a fost: Shotgun. (%d voturi)", VoteGuns[2]);
            PaintMessage(COLOR_WHITE, string);
            PaintWeapon(25, 500);
            pGun[2] = 1;
        }
        else if(VoteGuns[3] > VoteGuns[1] && VoteGuns[3] > VoteGuns[2] && VoteGuns[3] > VoteGuns[4] && VoteGuns[3] > VoteGuns[5] && VoteGuns[3] > VoteGuns[6])
        {
            format(string, sizeof(string), "Cea mai votata arma a fost: M4. (%d voturi)", VoteGuns[3]);
            PaintMessage(COLOR_WHITE, string);
            PaintWeapon(31, 500);
            pGun[3] = 1;
        }
        else if(VoteGuns[4] > VoteGuns[1] && VoteGuns[4] > VoteGuns[2] && VoteGuns[4] > VoteGuns[3] && VoteGuns[4] > VoteGuns[5] && VoteGuns[4] > VoteGuns[6])
        {
            format(string, sizeof(string), "Cea mai votata arma a fost: Combat Shotgun. (%d voturi)", VoteGuns[4]);
            PaintMessage(COLOR_WHITE, string);
            PaintWeapon(27, 500);
            pGun[4] = 1;
        }
        else if(VoteGuns[5] > VoteGuns[1] && VoteGuns[5] > VoteGuns[2] && VoteGuns[5] > VoteGuns[3] && VoteGuns[5] > VoteGuns[4] && VoteGuns[5] > VoteGuns[6])
        {
            format(string, sizeof(string), "Cea mai votata arma a fost: Knife. (%d voturi)", VoteGuns[5]);
            PaintMessage(COLOR_WHITE, string);
            PaintWeapon(4, 500);
            pGun[5] = 1;
        }
        else if(VoteGuns[6] > VoteGuns[1] && VoteGuns[6] > VoteGuns[2] && VoteGuns[6] > VoteGuns[3] && VoteGuns[6] > VoteGuns[4] && VoteGuns[6] > VoteGuns[5])
        {
            format(string, sizeof(string), "Cea mai votata arma a fost: Baseball Bat. (%d voturi)", VoteGuns[6]);
            PaintMessage(COLOR_WHITE, string);
            PaintWeapon(5, 500);
            pGun[6] = 1;
        }
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(InPaintball[i] == 1 && pRound == 1)
            {
                SetPlayerHealth(i, 100);
            }
        }
        SetTimer("StopPaintball", 180000, false);
    }
    return 1;
}

forward StopPaintball();
public StopPaintball()
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(InPaintball[i] == 1)
        {
            new string[256];
            ResetPlayerWeapons(i);
            SetTimer("StartPaintball", 30000, 0);
            pGun[1] = 0, pGun[2] = 0, pGun[3] = 0, pGun[4] = 0, pGun[5] = 0, pGun[6] = 0;
            pRound = 0, PlayerKills[i] = 0, VotedMap[i] = 0, VotedGun[i] = 0, pVoted = 1;
            format(string, sizeof(string), "Castigatorul acestei runde de paintball este: %s - %d kills", GetName(pWinner), pWinnerScore);
            PaintMessage(COLOR_YELLOW, string);
            SetTimer("StartPaintball", 20000, false);
        }
    }
    return 1;
}

PHP код:
forward PaintMessage(colorstring[]);
public 
PaintMessage(colorstring[])
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
InPaintball[i] == 1)
            {
                
SendClientMessage(icolorstring);
            }
        }
    }

Reply
#2

upppp!
Reply
#3

Use the normal SendClientMessage in your StopPaintBall timer instead of PaintMessage.

You're already looping through all players inside StopPaintBall, and you're looping through them again in PaintMessage.
With 50 players online, you'll get 2500 messages like that for all players in total, every player will see 50 messages.
Reply
#4

i was having this problem just yesterday with randomly vehicles spawning in AIR and i have just 1 vehicle

you need to understand this one

PHP код:
forward PaintMessage(colorstring[]); 
public 
PaintMessage(colorstring[]) 

    for(new 
0MAX_PLAYERSi++) 
    { 
        if(
IsPlayerConnected(i)) 
        { 
            if(
InPaintball[i] == 1
            { 
                
SendClientMessage(icolorstring); 
            } 
        } 
    } 

You're telling hem I = 0 and he'll start from ZERO to ++ Times non stop, directly that's waht you're doing here SendClientMessage(i, color, string);

so as PowerPC603 says , use normal send client message instead of doing this.

Good luck
Reply
#5

The solution would be? How can I send a message to all players of paintball without using loop.
An example please.
Reply
#6

As far as i see it you need to change:

pawn Код:
forward StopPaintball();
public StopPaintball()
{
    for(new i = 0; i < MAX_PLAYERS; i ++) // #1 Loop
    {
        if(InPaintball[i] == 1)
        {
            new string[256];
            ResetPlayerWeapons(i);
            SetTimer("StartPaintball", 30000, 0);
            pGun[1] = 0, pGun[2] = 0, pGun[3] = 0, pGun[4] = 0, pGun[5] = 0, pGun[6] = 0;
            pRound = 0, PlayerKills[i] = 0, VotedMap[i] = 0, VotedGun[i] = 0, pVoted = 1;
            format(string, sizeof(string), "Castigatorul acestei runde de paintball este: %s - %d kills", GetName(pWinner), pWinnerScore);
            PaintMessage(COLOR_YELLOW, string); // This line to regular SendClientMessage as you are already looping at #1
            SetTimer("StartPaintball", 20000, false);
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
As far as i see it you need to change:

pawn Код:
forward StopPaintball();
public StopPaintball()
{
    for(new i = 0; i < MAX_PLAYERS; i ++) // #1 Loop
    {
        if(InPaintball[i] == 1)
        {
            new string[256];
            ResetPlayerWeapons(i);
            SetTimer("StartPaintball", 30000, 0);
            pGun[1] = 0, pGun[2] = 0, pGun[3] = 0, pGun[4] = 0, pGun[5] = 0, pGun[6] = 0;
            pRound = 0, PlayerKills[i] = 0, VotedMap[i] = 0, VotedGun[i] = 0, pVoted = 1;
            format(string, sizeof(string), "Castigatorul acestei runde de paintball este: %s - %d kills", GetName(pWinner), pWinnerScore);
            PaintMessage(COLOR_YELLOW, string); // This line to regular SendClientMessage as you are already looping at #1
            SetTimer("StartPaintball", 20000, false);
        }
    }
    return 1;
}
I do not understand. What can I do, what can replace that lop to send that message at all.
Reply
#8

uppp.
Reply
#9

Quote:
Originally Posted by Edw
Посмотреть сообщение
I do not understand. What can I do, what can replace that lop to send that message at all.
You did notice that part the i quoted out with "// This line to regular SendClientMessage as you are already looping at #1"

You were supposed to edit that line and make it send the message with regular SendClientMessage and not PaintMessage.

Like this:

pawn Код:
forward StopPaintball();
public StopPaintball()
{
    for(new i = 0; i < MAX_PLAYERS; i ++) // #1 Loop
    {
        if(InPaintball[i] == 1)
        {
            new string[256];
            ResetPlayerWeapons(i);
            SetTimer("StartPaintball", 30000, 0);
            pGun[1] = 0, pGun[2] = 0, pGun[3] = 0, pGun[4] = 0, pGun[5] = 0, pGun[6] = 0;
            pRound = 0, PlayerKills[i] = 0, VotedMap[i] = 0, VotedGun[i] = 0, pVoted = 1;
            format(string, sizeof(string), "Castigatorul acestei runde de paintball este: %s - %d kills", GetName(pWinner), pWinnerScore);
            SendClientMessage(i, COLOR_YELLOW, string); // See how this simple line of code changed?
            SetTimer("StartPaintball", 20000, false);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)