Strange issue with SendClientMessage
#1

I don't know whether I am just being a noob or what but in this specific command and a stock associated with it the SendClientMessage's seem to not be outputting to the client and they are just kicked.

I have other instances of SendClientMessage through out the script but they work fine just these two places.

I have printf()'d the formatted messages and they output in the console fine. Any idea?

Command:
pawn Код:
command(tban, playerid, params[])
{
    new tid, reason[64], Reason[64], Mins, Hours, Days;
    if(pVariables[playerid][AdminLevel] >= 1)
    {
        if(sscanf(params, "uiiis[64]", tid, Days, Hours, Mins, reason)) return SendClientMessage(playerid, WHITE, "Server: /tban [playerid] [Days] [Hours] [Minutes] [Reason]");
        if(IsPlayerConnected(tid))
        {
            if(strlen(reason) <= 64)
            {
                new timeform = ((Mins*60) + (Hours*3600) + (Days*86400) + 16);
                mysql_real_escape_string(reason, Reason);
                format(smallQuery, sizeof(smallQuery), "INSERT INTO `bans` (PlayerBanned, BanLength, BannedBy, BanReason, BanIP) VALUES ('%s', '%d', '%s', '%s', '%s')", pName(tid), (timeform+gettime()),pName(playerid), Reason, GetIP(tid));
                mysql_query(smallQuery);
                format(szMessage, sizeof(szMessage), "[Banned:] You have been temporarily banned from Las Venturas Roleplay by Administrator %s for %s", RemoveUnderScore(playerid), timeca(gettime()+timeform));
                SendClientMessage(tid, RED, szMessage);
                format(szMessage, sizeof(szMessage), "Reason: %s. If you feel you have been wrongly banned, appeal on the forums.", reason);
                SendClientMessage(tid, RED, szMessage);
                format(szMessage, sizeof(szMessage), "AdmMsg: %s has been banned by Administrator %s for %s [Reason: %s] ", RemoveUnderScore(tid), RemoveUnderScore(playerid), timeca(gettime()+timeform), reason);
                SendClientMessageToAll(RED, szMessage);
                Kick(tid);
            }
            else return SendClientMessage(playerid, RED, "[Error:]{FFFFFF} The ban reason cannot exceed 64 characters.");
        }
        else return SendClientMessage(playerid, RED, "[Error:]{FFFFFF}That player is not connected.");
    }
    return 1;
}
Stock:
pawn Код:
stock IsPlayerBanned(playerid)
{
    new reason[64], admin[32], d[128], seconds;
    format(smallQuery, sizeof(smallQuery), "SELECT * FROM bans WHERE BanIP = '%s' OR PlayerBanned = '%s'", GetIP(playerid), pName(playerid));
    mysql_query(smallQuery);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_fetch_row_format(smallQuery, "|"))
        {
            mysql_fetch_field_row(d, "BanLength"); seconds = strval(d);
            mysql_fetch_field_row(d, "BannedBy"); format(admin, sizeof(admin), d);
            mysql_fetch_field_row(d, "BanReason"); format(reason, sizeof(reason), d);
        }
        if(seconds > gettime())
        {
            format(szMessage, sizeof(szMessage), "[Banned:]{FFFFFF} You are currently banned for: %s, You were banned by %s.", reason, admin);
            SendClientMessage(playerid, WHITE, szMessage);
            format(szMessage, sizeof(szMessage), "[Banned:]{FFFFFF} Your ban expires in %s.", timec(gettime()-(gettime()-seconds)));
            SendClientMessage(playerid, WHITE, szMessage);
            Kick(playerid);
        }
        else
        {
            format(smallQuery, sizeof(smallQuery), "DELETE FROM `bans` WHERE `PlayerBanned` = '%s'", pName(playerid));
            mysql_query(smallQuery);
        }
    }
    mysql_free_result();
    return 1;
}
Reply
#2

Make a timer for Kick(): http://forum.sa-mp.com/showpost.php?...3&postcount=65


Quote:
Originally Posted by Kalcor
Посмотреть сообщение
It's not a bug. It's intended behaviour. Kick() will cancel all pending packets and ignore any further messages from the player.

This had to be done for security reasons.
Reply
#3

not sure but i think u missed
Quote:

for(new tid = 0; tid < MAX_PLAYERS; tid++)

Reply
#4

I have just seen that 0.3x weird delay... Thanks Pooh.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)