/whisper command problem
#1

hello,
i've one problem with my /whisper command so i want help please.
when i use this command near a player it keep spams near players instead of sending only one message. and crash the server
reason for crashing.... asckslimit exceeded.

pawn Код:
COMMAND:whisper(playerid, params[])
{
    if (PlayerInfo[playerid][pSpawn] == 1){

        new COLOR = GetPlayerColor(playerid);

        new idx,string[512],length = strlen(params);
        while ((idx < length) && (params[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[512];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = params[idx];
            idx++;
        }
        result[idx - offset] = EOS;

        if (PlayerInfo[playerid][pMute] == 1)
        {
            SCM(playerid,COLOR_ERROR,"#Error: You Muted.");
            return 1;
        }

        if (!strlen(result))
        {
            SendClientMessage(playerid, COLOR_ERROR, "USAGE: /whisper (message).");
            return 1;
        }

        format(string, sizeof(string), "(WHISPER) %s (%d): %s",PlayerInfo[playerid][pName],playerid,result);
        SendClientMessage(playerid,COLOR, string);
        for (new i = 0; i < GetMaxPlayers(); i++)
        {

            i = GetClosestPlayer(playerid);
            if (IsPlayerConnected(i))
            {
                if (i != playerid)
                {
                    if (GetDistanceBetweenPlayers(playerid, i) < 10)
                    {
                        SendClientMessage(i,COLOR, string);
                    }
                }
            }
        }

    }else{
        SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
    }

    return 1;
}
Reply
#2

Just download this include: https://sampforum.blast.hk/showthread.php?tid=124428
It's quick and easy.
Reply
#3

pawn Код:
COMMAND:whisper(playerid, params[])
{
    if(PlayerInfo[playerid][pSpawn] != 1) SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
    else if(PlayerInfo[playerid][pMute] == 1) SCM(playerid,COLOR_ERROR,"#Error: You Muted.");
    else if(isnull(params)) SendClientMessage(playerid, COLOR_ERROR, "USAGE: /whisper (message).");
    else{
        new string[145],count;
        new COLOR = GetPlayerColor(playerid);
        format(string, sizeof(string), "(WHISPER) %s (%d): %s",PlayerInfo[playerid][pName],playerid,params);
        SendClientMessage(playerid,COLOR, string);
        for(new i = 0, g = GetMaxPlayers(); i < g; i++)
            if(IsPlayerConnected(i) && i != playerid)
                if(GetDistanceBetweenPlayers(playerid, i) < 10.0)
                    SendClientMessage(i, COLOR, string),count++;

        if(count == 0)
            SendClientMessage(playerid, COLOR_ERROR, "No players near you");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)