PDA

View Full Version : A SendClientMessageToAll spam, any idea?


denNorske
04/10/2012, 03:42 PM
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:

timerr[i][EDERBY] = SetTimer("EndDerby", 60*1000, false);

endderby here:

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: ?

http://imageshack.us/a/img837/5788/samp092hf.png


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!

Danyal
04/10/2012, 03:45 PM
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

denNorske
04/10/2012, 04:01 PM
Still the same :( Anything to do with my loop at top ?

C00K13M0N$73R
04/10/2012, 04:20 PM
It sends a message to all 'MAX_PLAYERS' times.

Put it out of the loop.


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;
}

denNorske
04/10/2012, 04:25 PM
Still spamming me. Any other suggestions? Thanks!

denNorske
09/10/2012, 04:50 AM
Buuuuuump. Anyone?

ViniBorn
09/10/2012, 04:56 AM
Use SetTimerEx for function with parameters, and not SetTimer

Ex:

SetTimerEx("EndDerby",60*1000,false, "i", playerid);

denNorske
09/10/2012, 05:44 AM
The timer works well, its just that the SendClientMessageToAll lines that spams the chat in game. 100 times within 5 -6 seconds.

BlueGames
09/10/2012, 06:00 AM
Try ?



new string[265]
format(string,sizeof(string),"[SERVER] Derby has been ended!"cyellow" Everyone in derby has been spawned!",tmp);*

denNorske
09/10/2012, 06:02 AM
Sorry, still spamming me down when it ends :/

BlueGames
09/10/2012, 06:16 AM
Try ??

else
{
SendClientMessageToAll(COLOR_GREEN,"[SERVER] Derby has been ended!"cyellow" Everyone in derby has been spawned!");
return 1;
}

denNorske
09/10/2012, 06:21 AM
Nope, nothing appears.

BlueGames
09/10/2012, 06:24 AM
Sorry mate i dont know...

denNorske
09/10/2012, 06:25 AM
Okay, thanks for trying :) Anyone else?

zSuYaNw
09/10/2012, 06:25 AM
Remove the loop.


forward EndDerby(playerid); public EndDerby(playerid)
{
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;
}

denNorske
09/10/2012, 06:27 AM
Ahhhhhh, ofcourse!

Thankyou!

[SOLVED]