Could this work? please answer!
#1

Hey guys... i am at school and i have no gta here... I made this ban code and i wanna know if it cvould work....
Please give a look, it compile without erros/warmnings...

pawn Код:
Command_ban(playerid, params[])
{
    if(IsPlayerConnected(id))
    {
        if(IsPlayerAdmin(playerid))
        {
            new id;
            if(!sscanf(params, "ui", id))
            {
                new string[64];
                new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], text[PLAYER_TEXT];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(id, PlayerName, sizeof(PlayerName));
                GetPlayerText(playerid, text, sizeof(text));
                format(string, sizeof(string), "You has been banned by %s, reason %d", name, text);
                SendClientMessage(playerid, 0x0259EAAA, string);
                format(string, sizeof(string), "You banned %s.)
                SendClientMessage(playerid, 0x0259EAAA, string);
                BanPlayer(id);
            }
            else return SendClientMessage(playerid, 0x0259EAAA, "
USAGE: /ban [PlayerId/PartOfName] [Reason]");
        }
        else return SendClientMessage(playerid, 0x0259EAAA, "
You are not admin.");
    }
    else return SendClientMessage(playerid, 0x0259EAAA, "
Player is not connected.");
}
Reply
#2

No, it wouldn't work.
Reply
#3

Use this:
pawn Код:
CMD:ban( playerid, params[ ] )
{
    new ID, string[128], reason[66];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0x0259EAAA, "You are not admin.");
    if(sscanf(params, "uS(No Reason Given)[65]", ID, reason)) return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /ban [PlayerID] [reason]");
    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, 0x0259EAAA, string);
        format(string, sizeof(string), "You have Banned \"%s\" Reason: %s", pName(ID), reason);
        SendClientMessage(playerid, 0x0259EAAA , string);
        format(string, sizeof(string), "Administrator \"%s\" has Banned \"%s\" Reason: %s",pName(playerid),pName(ID),reason);
        SendClientMessageToAll( 0x0259EAAA , string );
        TogglePlayerControllable(ID, false);
        Ban(ID);
    }
    else return SendClientMessage(playerid, -1, "Player is not connected or is yourself");
    return 1;
}
Somewhere in your script:
pawn Код:
stock pName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
Reply
#4

Clive, your example wouldn't let administrators execute the command, but non-administrators could.
Reply
#5

pawn Код:
CMD:ban(playerid, params[])
{
    //Is Player Admin script here
    {
        new pID, Msg[128];
        if(sscanf(params, "us[60]", pID, params)) return SendClientMessage(playerid, COLOR_RED, "* Usage: /Ban < Player ID > < Reason >");

        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "That user is not connected!");

        format(Msg, sizeof(Msg), "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(pID), pID, params);
        SendClientMessageToAll(COLOR_GREY, Msg);

        return BanEx(pID, "Admin Ban!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "This command is for admin lvl 3 + only!");
}
Reply
#6

Quote:
Originally Posted by Macluawn
Посмотреть сообщение
Clive, your example wouldn't let administrators execute the command, but non-administrators could.
+1. :P
Srry i was frgt "!"

i've edited ma post.

Edit: i lol'd @ Markx.
Reply
#7

Hey guys!!! The only think that shouldn't work is the reazon...
If i remove the reazon i am sure it work! I just wanna know, how do the server get the reazon!
I used GetPlayerText and i have no idea if this exist!
Reply
#8

ok, this work well, but don't ask for reazon... just ban! I want this to tell the reazin too! But in my script form... Or just tell me what to add! THANKS

pawn Код:
COMMAND:iban(playerid, params[])
{
    new id;
    if(IsPlayerConnected(id))
    {
        if(IsPlayerAdmin(playerid))
        {
            if(!sscanf(params, "ui", id))
            {
                new string[64];
                new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(id, PlayerName, sizeof(PlayerName));
                format(string, sizeof(string), "You has been banned by %s.", name);
                SendClientMessage(playerid, 0x0259EAAA, string);
                format(string, sizeof(string), "You banned %s.", id);
                SendClientMessage(playerid, 0x0259EAAA, string);
                Ban(id);
                return 1;
            }
            else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /ban [PlayerId/PartOfName]");
        }
        else return SendClientMessage(playerid, 0x0259EAAA, "You are not admin.");
    }
    else return SendClientMessage(playerid, 0x0259EAAA, "Player is not connected.");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)