Kick command showing an unwanted error.
#10

Quote:
Originally Posted by OsteeN
Посмотреть сообщение
That would attempt to create a dialog for each administrator, wouldn't it? (edit: Noticed you had a return; that will only show the first administrator it finds, yes?)

This might be sloppy written, but I'm in a bit of a hurry so here's something you can try, OP:
pawn Код:
CMD:admin(playerid, params[])
{
    new string[512], admin[126], pName[MAX_PLAYER_NAME]; // Edit this to the size you'll prefer and based on how much you think you need
    format(string, sizeof(string), "Administrators Online:\n\n"); // Title of your dialog
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0) // For each player, check if they're an administrator
        {
            GetPlayerName(i, pName, sizeof(pName)); // Get the administrators name
            format(admin, sizeof(admin), "Name: %s | Level: %d\n", pName, PlayerInfo[i][pAdmin]);
            strcat(string, admin); // Attach the formatted text to the string
        }
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Administrators", string, "Close", "");
    return 1;
}
Haven't tested it tho.
it was a quick edit, i see my errors now lol.

Kick Command:
pawn Код:
//Use this to start the timer to kick the player, thus showing the message before kicking them.
forward kickplayer(playerid);
public kickplayer(playerid)
{
    Kick(playerid);
    return 1;
}

CMD:kick(playerid,params[])
{
    new id,string[128],PlayerName[MAX_PLAYER_NAME],TargetName[MAX_PLAYER_NAME],reason[100];//Added TargetName[MAX_PLAYER_NAME] to hold the name of the player (id).
    if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, -1,"{FF0000}You are not authorized to use this command.");
    if(sscanf(params,"us[100]",id,reason)) return SCM(playerid, -1,"{FF0000}/kick [ID] [reason]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id))) return SCM(playerid, -1,"{FF0000}Player is not connected.");
    if(playerid == id) return SCM(playerid, -1,"{FF0000}You cannot kick yourself,fool");
    GetPlayerName(playerid, PlayerName,sizeof(PlayerName));
    GetPlayerName(id,TargetName,sizeof(TargetName));//Added this to get the name of the player kicked.
    format(string,sizeof(string),"{FF0000}Player %s has been kicked by Admin %s for %s",TargetName,PlayerName,reason);
    SendClientMessageToAll(COL_WHITE,string);
    SetTimerEx("kickplayer", 1000, false, "i", id);//This is the timer used to kick the player so they will see the string above.
    return 1;
}
//try this
Reply


Messages In This Thread
Kick command showing an unwanted error. - by Accent - 17.11.2014, 07:03
Re: Kick command showing an unwanted error. - by OsteeN - 17.11.2014, 07:10
Re: Kick command showing an unwanted error. - by Zex Tan - 17.11.2014, 07:38
Re: Kick command showing an unwanted error. - by Accent - 17.11.2014, 07:40
Re: Kick command showing an unwanted error. - by OsteeN - 17.11.2014, 08:00
Re: Kick command showing an unwanted error. - by Accent - 17.11.2014, 08:11
Re: Kick command showing an unwanted error. - by Banana_Ghost - 17.11.2014, 08:52
Re: Kick command showing an unwanted error. - by OsteeN - 17.11.2014, 09:08
Re: Kick command showing an unwanted error. - by Accent - 17.11.2014, 11:51
Re: Kick command showing an unwanted error. - by Banana_Ghost - 18.11.2014, 03:53

Forum Jump:


Users browsing this thread: 1 Guest(s)