A SendClientMessageToAll spam, any idea?
#1

Here is my code that is my derby, with the "endDerby" function which should spawn a player, Destroy the derby car, and send a message to all that the derby is ended, and it will start again soon. Anyhow, here is my code:

When he joins the derby, this is started:

pawn Код:
timerr[i][EDERBY] = SetTimer("EndDerby", 60*1000, false);
endderby here:

pawn Код:
forward EndDerby(playerid);
public EndDerby(playerid)
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(GetPVarInt(playerid,"derby") == 1)
        {
        DestroyVehicle(GetPlayerVehicleID(playerid));
        SpawnPlayer(playerid);
        EnableDerby = 0;
        SetPVarInt(playerid,"derby", 0);
        }
    else
    {
    EnableDerby = 0;
    SetPVarInt(playerid,"derby", 0);
    SetPVarInt(playerid, "HasSpawnedCar",0);
    timerr[playerid][DTIMER] = SetTimer("StartDerby", 120000, false);
    SendClientMessageToAll(COLOR_GREEN,"[SERVER] Derby has been ended!"cyellow" Everyone in derby has been spawned!");
    SendClientMessageToAll(COLOR_GREEN,"[SERVER] New derby will be there in "cred"2 minutes!"cgreen" Kindly stay connected!");
    KillTimer(timerr[playerid][EDERBY]);
    KillTimer(timerr[playerid][STIMER]);
    }
}
return 1;
}
That was the code, Why is this happening: ?




And another problem, when other players are driving their cars, suddenly all used cars are getting destroyed when the derby ends? I have struggled with that a long time now, i think it was time to get some help ^^


Thanks!
Reply
#2

pawn Код:
forward EndDerby(playerid);
public EndDerby(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPVarInt(playerid,"derby") == 1)
        {
            DestroyVehicle(GetPlayerVehicleID(playerid));
            SpawnPlayer(playerid);
            EnableDerby = 0;
            SetPVarInt(playerid,"derby", 0);
        }
        else
        {
            EnableDerby = 0;
            SetPVarInt(playerid,"derby", 0);
            SetPVarInt(playerid, "HasSpawnedCar",0);
            timerr[playerid][DTIMER] = SetTimer("StartDerby", 120000, false);
            SendClientMessage(i, COLOR_GREEN,"[SERVER] Derby has been ended!"cyellow" Everyone in derby has been spawned!");
            SendClientMessage(i, COLOR_GREEN,"[SERVER] New derby will be there in "cred"2 minutes!"cgreen" Kindly stay connected!");
            KillTimer(timerr[playerid][EDERBY]);
            KillTimer(timerr[playerid][STIMER]);
        }
    }
    return 1;
}
try this
Reply
#3

Still the same Anything to do with my loop at top ?
Reply
#4

It sends a message to all 'MAX_PLAYERS' times.

Put it out of the loop.

pawn Код:
forward EndDerby(playerid);
public EndDerby(playerid)
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(GetPVarInt(playerid,"derby") == 1)
        {
        DestroyVehicle(GetPlayerVehicleID(playerid));
        SpawnPlayer(playerid);
        EnableDerby = 0;
        SetPVarInt(playerid,"derby", 0);
        }
    else
    {
    EnableDerby = 0;
    SetPVarInt(playerid,"derby", 0);
    SetPVarInt(playerid, "HasSpawnedCar",0);
    timerr[playerid][DTIMER] = SetTimer("StartDerby", 120000, false);
    KillTimer(timerr[playerid][EDERBY]);
    KillTimer(timerr[playerid][STIMER]);
    }
}
    SendClientMessageToAll(COLOR_GREEN,"[SERVER] Derby has been ended!"cyellow" Everyone in derby has been spawned!");
    SendClientMessageToAll(COLOR_GREEN,"[SERVER] New derby will be there in "cred"2 minutes!"cgreen" Kindly stay connected!");
return 1;
}
Reply
#5

Still spamming me. Any other suggestions? Thanks!
Reply
#6

Buuuuuump. Anyone?
Reply
#7

Use SetTimerEx for function with parameters, and not SetTimer

Ex:
pawn Код:
SetTimerEx("EndDerby",60*1000,false, "i", playerid);
Reply
#8

The timer works well, its just that the SendClientMessageToAll lines that spams the chat in game. 100 times within 5 -6 seconds.
Reply
#9

Try ?

pawn Код:
new string[265]
format(string,sizeof(string),"[SERVER] Derby has been ended!"cyellow" Everyone in derby has been spawned!",tmp);*
Reply
#10

Sorry, still spamming me down when it ends :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)