[HELP] Ban - Kick Command
#1

Hey Guys,
I have had some problems with the /kick and ban command because everytime i get this:
http://s1180.photobucket.com/albums/...t=Kick-Ban.png

Here is the Ban code:
pawn Код:
dcmd_ban(playerid, params[])
{
    if(IsAdmin[playerid] >= 1) {
        new
            id,
            reason[24],
            string[64];
        if (sscanf(params, "us", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/ban <playerid> <reason>\"");
        else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        else if (id == playerid) SendClientMessage(playerid, COLOR_RED, "You cant ban your self. ");
        else {
            Ban(id);
            format(string,sizeof(string),"%s has been ban from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string,sizeof(string),"You have banned %s for %s.",ReturnPlayerName(playerid), reason );
            SendClientMessage(playerid, COLOR_YELLOW, string);
        }
    }
    else {
        SendClientMessage(playerid, 0x00FF00AA, "Your not admin");
    }
    return 1;
}
Kick Command:
pawn Код:
dcmd_kick(playerid, params[])
{
    if(IsAdmin[playerid] >= 1) {
        new
            id,
            reason[24],
            string[64];
        if (sscanf(params, "us", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <playerid> <reason>\"");
        else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        else if (id == playerid) SendClientMessage(playerid, COLOR_RED, "You cant kick your self. ");
        else {
            Kick(id);
            format(string,sizeof(string),"%s has been kicked from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string,sizeof(string),"You have kicked %s for %s.",ReturnPlayerName(playerid), reason );
            SendClientMessage(playerid, COLOR_YELLOW, string);
        }
    }
    else {
        SendClientMessage(playerid, 0x00FF00AA, "Your not a server admin");
    }
    return 1;
If you need anymore bits of the script please ask.

Kind Regards
Tessar
Reply
#2

when im on admin mode it says SERVER: Unknown Command xd
Reply
#3

Quote:

when im on admin mode it says SERVER: Unknown Command xd

Lol. Are your codes the same as mine? Or Slightly Different?
Reply
#4

Try
pawn Код:
dcmd_kick(playerid, params[])
{
    new
        id,
        reason[24],
        string[64];
    if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <playerid> <reason>\"");
    if(IsAdmin[playerid] < 1) return SendClientMessage(playerid, 0x00FF00AA, "Your not a server admin");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cant kick your self. ");
   
    format(string,sizeof(string),"%s has been kicked from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
    SendClientMessageToAll(COLOR_YELLOW, string);
    format(string,sizeof(string),"You have kicked %s for %s.",ReturnPlayerName(playerid), reason );
    SendClientMessage(playerid, COLOR_YELLOW, string);
    Kick(id);
   
    return 1;
}

dcmd_ban(playerid, params[])
{
    new
        id,
        reason[24],
        string[64];
    if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/ban <playerid> <reason>\"");
    if(IsAdmin[playerid] < 1) return SendClientMessage(playerid, 0x00FF00AA, "Your not a server admin");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cant ban your self. ");
   
    format(string,sizeof(string),"%s has been ban from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
    SendClientMessageToAll(COLOR_YELLOW, string);
    format(string,sizeof(string),"You have banned %s for %s.",ReturnPlayerName(playerid), reason );
    SendClientMessage(playerid, COLOR_YELLOW, string);
    Ban(id);
   
    return 1;
}
Reply
#5

Quote:

Try
pawn Code:
dcmd_kick(playerid, params[])
{
new
id,
reason[24],
string[64];
if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <playerid> <reason>\"");
if(IsAdmin[playerid] < 1) return SendClientMessage(playerid, 0x00FF00AA, "Your not a server admin");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cant kick your self. ");

format(string,sizeof(string),"%s has been kicked from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
SendClientMessageToAll(COLOR_YELLOW, string);
format(string,sizeof(string),"You have kicked %s for %s.",ReturnPlayerName(playerid), reason );
SendClientMessage(playerid, COLOR_YELLOW, string);
Kick(id);

return 1;
}

dcmd_ban(playerid, params[])
{
new
id,
reason[24],
string[64];
if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/ban <playerid> <reason>\"");
if(IsAdmin[playerid] < 1) return SendClientMessage(playerid, 0x00FF00AA, "Your not a server admin");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cant ban your self. ");

format(string,sizeof(string),"%s has been ban from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
SendClientMessageToAll(COLOR_YELLOW, string);
format(string,sizeof(string),"You have banned %s for %s.",ReturnPlayerName(playerid), reason );
SendClientMessage(playerid, COLOR_YELLOW, string);
Ban(id);

return 1;
}

Still does it :S
Reply
#6

pawn Код:
dcmd_ban(playerid, params[])
{
    if(IsAdmin[playerid] >= 1)
    {
        new
            id,
            reason[24],
            string[64];
        if (sscanf(params, "us", id, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/ban <playerid> <reason>\"");
        if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        if (id == playerid) SendClientMessage(playerid, COLOR_RED, "You cant ban your self. ");

        Ban(id);
        format(string,sizeof(string),"%s has been ban from the server (REASON: %s)",ReturnPlayerName(playerid), reason );
        SendClientMessageToAll(COLOR_YELLOW, string);
        format(string,sizeof(string),"You have banned %s for %s.",ReturnPlayerName(playerid), reason );
        SendClientMessage(playerid, COLOR_YELLOW, string);
        return 1;
    }
    else return SendClientMessage(playerid, 0x00FF00AA, "Your not admin");
}
Try this version ^
Reply
#7

It still doesn't work I think it might be down to my register system thats also on my gamemode.
Reply
#8

Did you set your admin level to 1 in the script files?
Reply
#9

Quote:

Did you set your admin level to 1 in the script files?

Yea - But i think it has something to do with the register system that i made.

Here is the code:
pawn Код:
#define SERVER_USER_FILE "Tsystem/Users/%s.ini"

enum pInfo
{
    pLevel,
    pCash,
    pScore,
}

new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];
new IsAdmin[MAX_PLAYERS];
new OnlineCheck[MAX_PLAYERS];
new Hours[MAX_PLAYERS];
new Minutes[MAX_PLAYERS];
new TRank[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if (!dini_Exists(file))
    Hours[playerid] = dini_Int(file,"Hours");
    Minutes[playerid] = dini_Int(file,"Minutes");
    TRank[playerid] = dini_Int(file,"Rank");
    SetPlayerScore(playerid,TRank[playerid]);
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hello There! It Seems You are not registered.", "Enter a password below to create an account...", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hello There! You are registered.", "Type your password below to login to your account...", "Login", "Leave");
    }
    OnlineCheck[playerid] = SetTimerEx("TimePlayed",60000,1,"playerid",playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(gPlayerLogged[playerid] == 1)
    KillTimer(OnlineCheck[playerid]);
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel]);
        dini_IntSet(file, "Hours",Hours[playerid]);
        dini_IntSet(file, "Minutes",Minutes[playerid]);
        dini_IntSet(file, "Rank",TRank[playerid]);
    }
    gPlayerLogged[playerid] = 0;
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hello There! You are not registered.", "Please imput a password below to create an account...", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        format(string, 128, "[Login-System]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        gPlayerLogged[playerid] = 1;
    }
    else if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Your account is registered", "Type in your password below to log in", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong Password mate! ~ If you have forgotten your password go to the server forums!.");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hello There! You are registered.", "Please type in your password below to login to your account...", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pLevel] = dini_Int(file, "Level");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SendClientMessage(playerid,COLOR_YELLOW, "[System]: You Have Been Successfully logged in!");
        }
    }
    return 1;
}
Hope Somebody can help me

Thanks
Reply
#10

COUGH!! ^ Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)