Help with ban system.
#1

Hi.I need some help.I don't know how to do if player have no reason write,then will be text:no reason.
Reply
#2

.... if(string == null) ?
Reply
#3

No i need full command.
Reply
#4

I did it for you .


pawn Код:
//Put in the OnPlayerCommandText callback:

if(!strcmp("/ban",cmdtext,true,4))
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFAA,"Only RCON Admins can use the /ban command.");
        new focus1[4], focus2[128], text[128], NickName1[MAX_PLAYER_NAME], NickName2[MAX_PLAYER_NAME];
        strcat(focus1, KcmD(1, cmdtext));
        focus2 = KcmD(2, cmdtext);
        if(!strlen(focus1)) return SendClientMessage(playerid, 0xFFFFFFAA,"Type: /ban [id] [reason]");
        if(!strlen(focus2)) focus2 = "no reason";
        GetPlayerName(playerid, NickName1, MAX_PLAYER_NAME);
        GetPlayerName(strval(focus1), NickName2, MAX_PLAYER_NAME);
        format(text,128,"[Admin] %s was banned by the admin %s. Reason: %s.",NickName1, NickName2, focus2);
        SendClientMessageToAll(0x33CCFFAA,text);
        Ban(strval(focus1));
        return true;
    }



//And, put in the end of your GameMode:

stock KcmD(param, cmdtext[])
{
    new string[128], pos, var;
    format(string, sizeof(string), "%s ", cmdtext);

    while((pos = strfind(string, " ", true)) != -1)
    {
        if(var == param) return string;
        var++;

        strdel(string, 0, pos + 1);
        if(strcmp(string, " ", true, pos) == 0) goto end;
    }

end:
    string[0] = '\0';
    return string;
}


I hope that i have helped .
Reply
#5

Better use sscanf - it's a lot better and easier to use!
Reply
#6

Yes how to make with sscanf?
Reply
#7

@rjjj

Ehm, but you haven' got an unban command for this! When a player is banned and u want him to get unbanned, what do u wanna do?^^
Reply
#8

Quote:
Originally Posted by budelis
Посмотреть сообщение
Yes how to make with sscanf?
pawn Код:
// Ban command created with zcmd and sscanf2.
CMD:ban( playerid, params[ ] )
{
    new ID, string[128], reason[64];
    if(!IsPlayerAdmin(playerid)) return 0; // Only rcon admins can use this command.
    if(sscanf(params, "uS(No Reason)[64]", ID, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [PlayerID] [reason]");
    else
    {
        if(IsPlayerConnected(ID) && ID != INVALID_PLAYER_ID && ID != playerid)
        {
            format(string,sizeof(string), "You have been Banned by Administrator \"%s\" Reason: %s", pName(playerid),reason);
            SendClientMessage(ID , -1, string);
            format(string, sizeof(string), "You have Banned \"%s\" Reason: %s", pName(ID), reason);
            SendClientMessage(playerid, -1 , string);
            format(string, sizeof(string), "Administrator \"%s\" has Banned \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
            SendClientMessageToAll( -1 , string );
            Ban(ID);
        }
        else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
    }
    return 1;
}
// Somewhere in your script.
stock pName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Reply
#9

or u can use it just like this:
pawn Код:
CMD:banid(playerid, params[])
{
    if(IsPlayerAdmin2[playerid] == 2)
    {
        new targetid, reason[64], name[24], msg[64];
        if(sscanf(params, "us[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /banid <playerid> <reason>");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "That player is not connected");
        GetPlayerName(targetid, name, sizeof(name));
        format(msg, sizeof(msg), "%s (%d) was banned. Reason: %s", name, targetid, reason);
        SendClientMessageToAll(COLOR_RED, msg);
        if(GetPVarInt(targetid, "Logged"))
        {
            new filename[64];
            format(filename, sizeof(filename), "MaceRP/users/%s.ini", PlayerName(targetid));
            dini_IntSet(filename, "Banned", 1);
        }
        BanEx(targetid, reason);
        GameTextForPlayer(targetid, "You has been banned", 4000, 3);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "You can't use this command.");
        return 1;
    }
}
if u have not tuped any word after playerid u cant ban that player xD
ignore the dini xD
Reply
#10

Thank for you all.Now i need to do that thing:when player get ban first time,he get ban only for his name,another time,when player get ban then he get ban for his ip.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)