Admin Scripting Help
#1

Hello, I'm a new scripter so this might be a bit of a nooby question. However, I couldn't find it anywhere else when searching.

So, for my admin system (I'm using Y_INI and if it helps, when allowing a certain level of administrator to a command I use
pawn Код:
if(AdminLevel[playerid] >= 1)
)
I want level 1 - 3 admins to have a command like /requestban. I want this to send a message to all the level 4 + administrators online(Overall there are 5 levels of administrator plus level 10 which is Community Owner). I want it to say something like "[Ban Request] %s %s(%d) has requested to ban %s(%d) for %s!"
I want the first string to be what rank the admin is.
I have no idea how to code this.

All your help is greatly appreciated!

Thanks,
anjh.
Reply
#2

I am assuming that you have basic coding knowledge.

pawn Код:
CMD:requestban(playerid, params[])
{
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, color, "YOU NO ADMIN!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, color, "/requestban [id] [reason]"); //Define these variables (id, reason)

    for(new a; a<MAX_PLAYERS; a++)
    {
     if(AdminLevel[playerid] >= 4)
     {
            format(str, sizeof(str), "%d requested ban on %d for %s", playerid, id, reason); //Use GetPlayerName for names.
            SendClientMessage(a, color, str); //define str somewhere
     }
    }
    return 1;
}
This is just a layout of what your command will look like.
Reply
#3

On top of your script , near the other ones
pawn Код:
forward ReqBan(playerid);
On the bottom of your script
pawn Код:
public ReqBan(playerid,tobanid,reason[])
{
    new themsg[128];
    new nume[MAX_PLAYER_NAME];
    GetPlayerName(playerid, nume, sizeof(nume));
    format(themsg, sizeof(themsg), "Admin %s requests a player ban on %s ,reason %s",nume,tobanid,reason);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(AdminLevel[playerid] >= 4)
            {
                SendClientMessage(playerid, 0x347235FF, themsg);
            }
        }
    }
    return 1;
}
And the command (zcmd + sscanf )
pawn Код:
COMMAND:requestban(playerid, params[])
{
    new idtoban;
    new reason[32];
    if (!sscanf(params, "us[32]",idtoban,reason ))
    {
        if (AdminLevel[playerid] >= 1)
        {
            if(idtoban != INVALID_PLAYER_ID)
            {
                ReqBan(playerid,idtoban,reason);
                return 1;
            }
            else{ return SendClientMessage(playerid,culoare,"Invalid ID"); }
        }
         else{ return SendClientMessage(playerid,culoare,"Not autorized to use that"); }
    }
    else { return SendClientMessage(playerid,culoare,"USE : /requestban playerid reason"); }
}
PS : If you dont use zcmd and sscanf yet you should start now , its easier and faster and better .
Reply
#4

Quote:
Originally Posted by emokidx
Посмотреть сообщение
I am assuming that you have basic coding knowledge.

pawn Код:
CMD:requestban(playerid, params[])
{
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, color, "YOU NO ADMIN!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, color, "/requestban [id] [reason]"); //Define these variables (id, reason)

    for(new a; a<MAX_PLAYERS; a++)
    {
     if(AdminLevel[playerid] >= 4)
     {
            format(str, sizeof(str), "%d requested ban on %d for %s", playerid, id, reason); //Use GetPlayerName for names.
            SendClientMessage(a, color, str); //define str somewhere
     }
    }
    return 1;
}
This is just a layout of what your command will look like.
Thank you very much for your response. After a bit of fiddling around with it, I got it to work, apart from one error. I've added 2 GetPlayerName's, and only one works. I cannot work out if there is any visible mistakes, but my new code is:
pawn Код:
CMD:requestban(playerid, params[])
{
    new id[128], reason[128];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOR_SILVER, "You must be atleast a level 1 administrator (Moderator) to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SILVER, "/requestban [id] [reason]"); //Define these variables (id, reason)

    for(new a; a<MAX_PLAYERS; a++)
    {
     if(AdminLevel[playerid] >= 4)
     {
            new str[128], PlayerName[MAX_PLAYER_NAME], PlayerName2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
            GetPlayerName(id, PlayerName2, sizeof(PlayerName2));
            format(str, sizeof(str), "[Ban Request] %s(%d) requested a ban on %s(%d) for %s", PlayerName, playerid, PlayerName2, id, reason); //Use GetPlayerName for names.
            SendClientMessage(a, COLOR_RED, str);
     }
    }
    return 1;
}
Sorry if I have messed up the code, but I'm new, and trying to get better independently.
My error is
Код:
C:\Users\XPS\Desktop\Current Projects\Scripting\SAMP Scripting\Real Life Role Play\RLRP Server\gamemodes\RLRP0.1b.pwn(947) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Thank you in advance for your help,
anjh.
Reply
#5

Show us which line is 947
Reply
#6

This should work fine :

pawn Код:
CMD:requestban(playerid, params[])
{
    new id[128], reason[128];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOR_SILVER, "You must be atleast a level 1 administrator (Moderator) to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SILVER, "/requestban [id] [reason]"); //Define these variables (id, reason)
    for(new a; a<MAX_PLAYERS; a++)
    {
        if(AdminLevel[a] >= 4)
        {
            new str[128], PlayerName[MAX_PLAYER_NAME], PlayerName2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
            GetPlayerName(id, PlayerName2, sizeof(PlayerName2));
            format(str, sizeof(str), "[Ban Request] %s(%d) requested a ban on %s(%d) for %s", PlayerName, playerid, PlayerName2, id, reason); //Use GetPlayerName for names.
            SendClientMessage(a, COLOR_RED, str);
        }
    }
    return 1;
}
Reply
#7

Oh, I'm very sorry. I forgot you'd need to know that.
pawn Код:
CMD:requestban(playerid, params[])
{
    new id[128], reason[128];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOR_SILVER, "You must be atleast a level 1 administrator (Moderator) to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SILVER, "/requestban [id] [reason]"); //Define these variables (id, reason)

    for(new a; a<MAX_PLAYERS; a++)
    {
     if(AdminLevel[playerid] >= 4)
     {
            new str[128], PlayerName[MAX_PLAYER_NAME], PlayerName2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
            GetPlayerName(id, PlayerName2, sizeof(PlayerName2));
            format(str, sizeof(str), "[Ban Request] %s(%d) requested a ban on %s(%d) for %s", PlayerName, playerid, PlayerName2, id, reason); //Use GetPlayerName for names.
            SendClientMessage(a, COLOR_RED, str);
     }
    }
    return 1;
}
Line 947 is:
pawn Код:
GetPlayerName(id, PlayerName2, sizeof(PlayerName2));
Reply
#8

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
This should work fine :

pawn Код:
CMD:requestban(playerid, params[])
{
    new id[128], reason[128];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOR_SILVER, "You must be atleast a level 1 administrator (Moderator) to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SILVER, "/requestban [id] [reason]"); //Define these variables (id, reason)
    for(new a; a<MAX_PLAYERS; a++)
    {
        if(AdminLevel[a] >= 4)
        {
            new str[128], PlayerName[MAX_PLAYER_NAME], PlayerName2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
            GetPlayerName(id, PlayerName2, sizeof(PlayerName2));
            format(str, sizeof(str), "[Ban Request] %s(%d) requested a ban on %s(%d) for %s", PlayerName, playerid, PlayerName2, id, reason); //Use GetPlayerName for names.
            SendClientMessage(a, COLOR_RED, str);
        }
    }
    return 1;
}
When I use that, I get the same error.
However, thank you very much fro your response!

anjh.
Reply
#9

I suggest you to use a stock for all "GetPlayerName" functions, example:

pawn Код:
stock NAME(playerid) // Put it in the last line of your script
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    return pname;
}
in other words, try using this:
pawn Код:
CMD:requestban(playerid, params[])
{
    new id[128], reason[128];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOR_SILVER, "You must be atleast a level 1 administrator (Moderator) to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SILVER, "/requestban [id] [reason]"); //Define these variables (id, reason)

    for(new a; a<MAX_PLAYERS; a++)
    {
        if(AdminLevel[playerid] >= 4)
        {
            new str[128];
            format(str, sizeof(str), "[Ban Request] %s(%d) requested a ban on %s(%d) for %s", NAME(playerid), playerid, NAME(id), id, reason);
            SendClientMessage(a, COLOR_RED, str);
        }
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by L.Hudson
Посмотреть сообщение
I suggest you to use a stock for all "GetPlayerFunctions" example:

pawn Код:
stock NAME(playerid) // Put it in the last line of your script
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    return pname;
}
in other words, try using this:
pawn Код:
CMD:requestban(playerid, params[])
{
    new id[128], reason[128];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOR_SILVER, "You must be atleast a level 1 administrator (Moderator) to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_SILVER, "/requestban [id] [reason]"); //Define these variables (id, reason)

    for(new a; a<MAX_PLAYERS; a++)
    {
        if(AdminLevel[playerid] >= 4)
        {
            new str[128];
            format(str, sizeof(str), "[Ban Request] %s(%d) requested a ban on %s(%d) for %s", NAME(playerid), playerid, NAME(id), id, reason);
            SendClientMessage(a, COLOR_RED, str);
        }
    }
    return 1;
}
First, thank you very much for your response.

I don't really like to use stocks, as I've had trouble with them in the past.



Quote:

Try :

pawn Код:
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
GetPlayerName(id, PlayerName2, MAX_PLAYER_NAME);
should work.

EDIT : too late.

Thanks again for your help, but I'm still getting the same error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)