Ban command problem
#1

I was fixing my ban command, i made this:

pawn Код:
CMD:ban(playerid, params[])
{
    new target_id, hours, minutes, seconds, reason[128], name[MAX_PLAYER_NAME];
    if(sscanf(params, "uddds[128]", target_id, hours, minutes, seconds, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban (playerid) (hours) (mins) (secs) (reason)");
    if(!IsPlayerConnected( target_id ) ) return SendClientMessage(playerid, -1, "ERROR: Requested player is offline.");
    {
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        PlayerInfo[target_id][Banned] = 1;
        PlayerInfo[target_id][BannedTime] = gettime();
        format( PlayerInfo[target_id][BanReason], 128, "%s", reason );
        format( PlayerInfo[target_id][BannedBy], MAX_PLAYER_NAME, "%s", name);
        new total_banned_seconds_from_now = seconds + ( minutes * 60 ) + (hours * 60 * 60);
        PlayerInfo[target_id][UnbanTime] = total_banned_seconds_from_now + gettime();

        new query[200], TARGETname[MAX_PLAYER_NAME];
        GetPlayerName(target_id, TARGETname, 24);

        format(query, sizeof(query), "UPDATE `playerdata` SET Banned = 1, BanReason = '%s', BannedBy  = '%s', BannedTime = %d, UnbanTime = %d WHERE user = '%s'",  reason, name, gettime(), PlayerInfo[target_id][UnbanTime], TARGETname);

        mysql_function_query(mysqlc, query, false, "", "");

        SendClientMessage(target_id, -1, "You have been banned.");
        SendClientMessage(playerid, -1, "You have banned the requested player successfully.");
    }
        return 1;
}
But, in the "playerdata" table at "BanReason", "BannedBy", "BannedTim", "UnbanTim" it shows random numbers, not the correct params.

Also when i login i get this:



What's wrong?

The fields in the database are all "varchar( 128 )".
Reply
#2

Try changing them (bantime, unbantime) into integers instead of varchars; you're not using ' ' when saving into a varchar which might be the cause of it.

Make sure you're not using the R35 version of the plugin as it has shifted data issues, use R34 instead and wait for R36

Also, why using brackets after the !IsPlayerConnected check? If it passes then it'll stop at the return and there's no need for those brackets.

Also a pic of the database fields could be usefull..
Reply
#3

Meh, doesn't work. Gonna backup to the old ban system i was using. Thanks for helping tho.
Reply
#4

Use a printf statement and print the query, post it here.

Secondly, make sure your fields are so -

1) BannedBy - VARCHAR( 24 )
2) BannedFor - VARCHAR( MAX_LENGTH_OF_REASON )
3) BannedTime - INT(11)
4) UnbanTime - INT(11)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)