help me with command spam - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help me with command spam (
/showthread.php?tid=396371)
help me with command spam -
Hugoca - 30.11.2012
I make the command to work but now it's spam the chat
pawn Код:
if(strcmp(cmd, "/givelp", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givelp [1000] [LP]");
return 1;
}
new para1;
new level;
para1 = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
level = strval(tmp);
if (PlayerInfo[playerid][pAdmin] >= 4 || IsPlayerAdmin(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerInfo[i][Exp] += level;
format(string, sizeof(string), "%s даде на всички играчи %d LP", PlayerName(playerid), level); // this spam the chat
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Нямаш достатъчно админ права!");
}
}
return 1;
}
Re: help me with command spam -
NumbSkull - 30.11.2012
you are sending client msg to all as many times as you have max players xD
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerInfo[i][Exp] += level;
format(string, sizeof(string), "%s даде на всички играчи %d LP", PlayerName(playerid), level); // this spam the chat
SendClientMessage(i,COLOR_LIGHTBLUE, string);
}
Re: help me with command spam -
Hugoca - 30.11.2012
code need to be:
pawn Код:
if(strcmp(cmd, "/givelp", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givelp [1000] [LP]");
return 1;
}
new para1;
new level;
para1 = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
level = strval(tmp);
if (PlayerInfo[playerid][pAdmin] >= 4 || IsPlayerAdmin(playerid))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerInfo[i][Exp] += level;
}
format(string, sizeof(string), "%s даде на всички играчи %d LP", PlayerName(playerid), level);
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Нямаш достатъчно админ права!");
}
}
return 1;
}
Re: help me with command spam -
Hugoca - 30.11.2012
solved
Re: help me with command spam -
NumbSkull - 30.11.2012
you have to tab in the format and the clientmsg lines one but yeah that would do basicly the same