Help with /tempban command
#1

Guys please help with reason problem in tempban command i created it with strcmp bec my script supports strcmp commands so help me problem is when i put reason in tempban it only showing first word reason like i used /tempban 0 10 Ban Evader then only show reason: Ban here is my command

pawn Код:
if (strcmp(string, "/tempban", true) == 0)
    {
        if (adlvl[playerid] < 3) return 0;

        new pnames[64],playernam[64],str[150];
        new player1 ,days, string1[100],string2[100];
        new tmp3[2048];
       
        new unbandate,unbanmonth,unbanyear; getdate(unbanyear, unbanmonth, unbandate);
        new year,month,day; getdate(year, month, day);


        tmp = strtok(cmdtext, idx);
        tmp2 = strtok(cmdtext, idx);
        tmp3 = strtok(cmdtext, idx);
       
        if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /tempban [playerid] [days] [reason]");
        if (!strlen(tmp2))  return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /tempban [playerid] [days] [reason]");
        if (!strlen(tmp3))  return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /tempban [playerid] [days] [reason]");
       
        player1 = strval(tmp);
        days = strval(tmp2);
       
        GetPlayerName(player1, pnames, MAX_PLAYER_NAME);
        GetPlayerName(playerid, playernam, MAX_PLAYER_NAME);


        if (!IsPlayerConnected2(player1) || !isNumeric(tmp)) return SendClientMessage2(playerid, COLOR_RED, "Error: Inactive player id!");

        if (orcl[player1][0] != 0) return SendPlayerFormattedText(playerid, COLOR_WHITE, "Please wait until %s has spawned.", pnames, "");

        if(!isNumeric(tmp2)) return SendClientMessage2(playerid, COLOR_RED, "Error: Days must be in numbers.");

        if(days > 10) return SendClientMessage2(playerid, COLOR_RED, "Error: You can not temp banned players more then 10 days.");

        if (player1 == playerid)  return SendClientMessage2(playerid, COLOR_RED, "Error: You can't temp ban yourself!");

        if (adlvl[player1] >= adlvl[playerid] && adminuc[player1] == 0) return SendPlayerFormattedText(playerid, COLOR_RED, "Error: You cannot temp ban %s.", giveplayer, "");

        dini_IntSet(AddDirFile(dir_userfiles, giveplayer), "bannedby", dini_Int(AddDirFile(dir_userfiles, playername), "account"));

        dini_IntSet(AddDirFile(dir_userfiles, pnames), "Days",gettime()+60 * 60 * (24*days));

        unbandate += days;
        if(unbandate > DInM(unbanmonth))
        {
            unbandate -= DInM(unbanmonth);
            unbanmonth ++;
        }
        if(unbanmonth > 12)
        {
            unbanmonth -= 12;
            unbanyear ++;
        }
        format(string1,sizeof(string1),"~%s has been banned from the server for '%s'.",pnames,tmp3);
        SendClientMessageToAll(COLOR_RED,string1);

        format(str,sizeof(str),"You have been banned from the server for '%s'.",tmp3);
        SendClientMessage(player1,COLOR_WHITE,str);


        format(string2,sizeof(string2),"Admin Log: %s has Temporarily banned %s for reason %s for %d day(s).", playernam, pnames,tmp3,days);
        SendMessageToAdmins(COLOR_ADMIN, string2);

        dini_IntSet(AddDirFile(dir_userfiles, pnames), "TempBan", 1);
        dini_Set(AddDirFile(dir_userfiles, pnames), "Reason", tmp3);
        dini_Set(AddDirFile(dir_userfiles, pnames), "Banner", playernam);
        dini_IntSet(AddDirFile(dir_userfiles, pnames), "BannedDate", day);
        dini_IntSet(AddDirFile(dir_userfiles, pnames), "BannedMonth", month);
        dini_IntSet(AddDirFile(dir_userfiles, pnames), "BannedYear", year);
        dini_IntSet(AddDirFile(dir_userfiles, pnames), "UnbannedDate",unbandate);
        dini_IntSet(AddDirFile(dir_userfiles, pnames), "UnbannedMonth",unbanmonth);
        dini_IntSet(AddDirFile(dir_userfiles, pnames), "UnbannedYear",unbanyear);
        Kick(player1);
        return 1;
    }
Reply
#2

replace tmp3 = strtok(cmdtext, idx); to tmp3 = strtok(cmdtext, idx, '\0');
Reply
#3

Thank you very much bro +1 rep for you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)