Problem with Spamming
#1

That is my code:
Код:
if(strcmp(cmd, "/command", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if (!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /service [police/fbi/rescue/taxi]");
		else if (strcmp(tmp, "police", true) == 0)
		{
		new Float:p[3];
    GetPlayerPos(playerid,p[0],p[1],p[2]);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    //OnPlayerCommandText(playerid, "/me55252205525220 takes out his phone and presses on some numbers");
    DisablePlayerCheckpoint(i);
    CallRemoteFunction("OnPlayerCommandText", "is", playerid, "/me action");
    SetPlayerCheckpoint(i,p[0],p[1],p[2],3.0);
    }
		}
		else SendClientMessage(playerid, COLOR_GREY, "USAGE: /service [police/fbi/rescue/taxi]");
		return 1;
	}
When I do /command police - everything works fine except the thing that it spamming me with the command /me action over all the chat..
How to fix that?
Thanks
Reply
#2

pawn Код:
if(strcmp(cmd, "/command", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if (!strlen(tmp))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /service [police/fbi/rescue/taxi]");

    if (strcmp(tmp, "police", true) == 0)
    {
        new Float:p[3];
        GetPlayerPos(playerid,p[0],p[1],p[2]);
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            //OnPlayerCommandText(playerid, "/me55252205525220 takes out his phone and presses on some numbers");
            DisablePlayerCheckpoint(i);
            CallRemoteFunction("OnPlayerCommandText", "is", playerid, "/me action");
            SetPlayerCheckpoint(i,p[0],p[1],p[2],3.0);
        }
        return 1;
    }

    SendClientMessage(playerid, COLOR_GREY, "USAGE: /service [police/fbi/rescue/taxi]");
    return 1;
}
Reply
#3

Still spamming...
Anyone else?
Reply
#4

You have this inside a loop, what else do you think it would do than spam it for you?
pawn Код:
CallRemoteFunction("OnPlayerCommandText", "is", playerid, "/me action");
If you want the /me cmd appear for everyone, not only for playerid, you gotta use i instead of playerid:
pawn Код:
CallRemoteFunction("OnPlayerCommandText", "is", i, "/me action");
Reply
#5

nah, you need to completely rewrite that..

pawn Код:
stock SendClientActionToRange(radi,playerid,string[])
{
    new Float:posx, Float:posy, Float:posz;
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);

    for (new i = 0; i <= SLOTS; i++)
        if (IsPlayerConnected(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i) && GetPlayerInterior(playerid) == GetPlayerInterior(i))
        {
                GetPlayerPos(i, posx, posy, posz);
                tempposx = (oldposx - posx);
                tempposy = (oldposy - posy);
                tempposz = (oldposz - posz);

                if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                     SendClientMessage(i, COLOR_PLAYERACTION, string);
        }
    return 1;
}
pawn Код:
if(strcmp(cmd, "/command", true) == 0)
{
    tmp = strtok(cmdtext, idx);
    if (!strlen(tmp))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /service [police/fbi/rescue/taxi]");

    if (strcmp(tmp, "police", true) == 0)
    {
        new Float:p[3], playername[32], string[64];

        GetPlayerPos(playerid,p[0],p[1],p[2]);
        GetPlayerName(playerid, playername, 32);

        format(string, sizeof(string), "%s takes out his phone and dials 911", playername);
        SendClientActionToRange(15, playerid, string)

        for(new i=0;i<MAX_PLAYERS;i++)
        {
            DisablePlayerCheckpoint(i);
            SetPlayerCheckpoint(i,p[0],p[1],p[2],3.0);
        }
        return 1;
    }

    SendClientMessage(playerid, COLOR_GREY, "USAGE: /service [police/fbi/rescue/taxi]");
    return 1;
}
Reply
#6

No you don't.

Edit: You do notice that your SendClientActionToRange() does exactly the same thing as CallRemoteFunction("/me")?
Reply
#7

no it doesn't, my code only sends the text to a certain range of the player that calls the command, and only once.. /me is most likely to be global, and the way you did your code every player that it's called for also sees his/her own name
Reply
#8

I tried to do what "rab" has said, and there is some errors:


Код:
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\TomNidi(FilterScript).pwn(2877) : error 017: undefined symbol "SLOTS"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\TomNidi(FilterScript).pwn(2886) : error 017: undefined symbol "COLOR_PLAYERACTION"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\TomNidi(FilterScript).pwn(12424) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\TomNidi(FilterScript).pwn(15115) : warning 204: symbol is assigned a value that is never used: "gender"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\TomNidi(FilterScript).pwn(21206) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\1.pwn(21214) : error 001: expected token: ";", but found "for"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\1.pwn(21224) : error 017: undefined symbol "playername"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\1.pwn(21226) : error 017: undefined symbol "playername"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\1.pwn(21228) : error 001: expected token: ";", but found "for"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\1.pwn(15111) : warning 204: symbol is assigned a value that is never used: "weapname"
C:\Documents and Settings\XPPRESP3\Desktop\ссссс\filterscripts\1.pwn(25082) : warning 203: symbol is never used: "slowmopill"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#9

learn to script.. half those errors aren't even related to what I posted, the others are really easy to fix..

Quote:

TomNidi(FilterScript).pwn(2877) : error 017: undefined symbol "SLOTS"

replace SLOTS with MAX_PLAYERS, or another define

Quote:

TomNidi(FilterScript).pwn(2886) : error 017: undefined symbol "COLOR_PLAYERACTION"

define that colour, or use another one

Quote:

1.pwn(21214) : error 001: expected token: ";", but found "for"
1.pwn(2122 : error 001: expected token: ";", but found "for"

add a ; in the previous line

Quote:

1.pwn(21224) : error 017: undefined symbol "playername"
1.pwn(21226) : error 017: undefined symbol "playername"

define the 'playername' symbol (new playername[32]; )
Reply
#10

Ok the message is ok now.. But the checkpoint doesn't appet
?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)