Kick player with dialogs
#1

Hi , i want to make a dialog to kick a player , for example i type /kickplayer , i will got a dialog when i type the playername or playerid, the player will be kicked , if anyone have a idea , please help
Reply
#2

easy,here:
pawn Код:
CMD:kickplayer(playerid, params[])
{
    if(put the admin thingy here,like pInfo[playerid][admin])
    {
        ShowPlayerDialog(playerid,8888, DIALOG_STYLE_INPUT, "Kick Player", "Enter Player ID", "Kick", "Cancel"); //i made dialog id 8888 to not have other dialogs with same id which will cause a bug
    }
    return 1;
}
and:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 8888)
    {
        if(!response)  return 1;
        else
        {
            new id = strval(inputtext);
            if(IsPlayerConnected(id))
            {
                Kick(id);
            }
            else
            {
                SendClientMessage(playerid, -1, "Invalid player ID");
            }
        }
        return 1;
    }
}
Reply
#3

Hello!

You have to work with strval.

Mencent
Reply
#4

Quote:
Originally Posted by R0
Посмотреть сообщение
easy,here:
pawn Код:
CMD:kickplayer(playerid, params[])
{
    if(put the admin thingy here,like pInfo[playerid][admin])
    {
        ShowPlayerDialog(playerid,8888, DIALOG_STYLE_INPUT, "Kick Player", "Enter Player ID", "Kick", "Cancel"); //i made dialog id 8888 to not have other dialogs with same id which will cause a bug
    }
    return 1;
}
and:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 8888)
    {
        if(!response)  return 1;
        else
        {
            new id = strval(inputtext);
            if(IsPlayerConnected(id))
            {
                Kick(id);
            }
            else
            {
                SendClientMessage(playerid, -1, "Invalid player ID");
            }
        }
        return 1;
    }
}
Thank's , but if i want to make it with the playername , or a part of playername
Reply
#5

PHP код:
ShowPlayerDialog(playerid,8777,DIALOG_STYLE_INPUT,"Kick","ID or Name","Next","Back");
if(
dialogid == 8777)
{
    if(
response)
    {
        if(!
strlen(inputtext))return ShowPlayerDialog(playerid,8777,DIALOG_STYLE_INPUT,"Kick","ID or Name","Next","Back");
        if(!
IsNumeric(inputtext))
        {
            new 
pID gPlayerID(inputtext);
            if(!
IsPlayerConnected(pID))return SendClientMessage(playerid,-1,"not online!");
            
Kick(pID);
        }
        else
        {
            if(!
IsPlayerConnected(strval(inputtext))return SendClientMessage(playerid,-1,"not online");
            
Kick(strval(inputtext));
        }
        return 
1;
    }

You need this functions:
PHP код:
gPlayerID(Name[])
{
    new 
pPlayerName[MAX_PLAYER_NAME],i;
    for(;
i<MAX_PLAYERS;i++){
        
GetPlayerName(i,pPlayerName,MAX_PLAYER_NAME);
        if(!
strcmp(Name,pPlayerName,true))return i;
    }
    for(;
i<MAX_PLAYERS;i++){
        
GetPlayerName(i,pPlayerName,MAX_PLAYER_NAME);
        if(
strfind(pPlayerName,Name)!=-1)return i;
    }
    return -
1;

PHP код:
IsNumeric(const string[])
{
        for (new 
0strlen(string); ji++)
        {
                if (
string[i] > '9' || string[i] < '0') return 0;
        }
        return 
1;

Mencent
Reply
#6

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)