[HELP] Dialog - OnPlayerClickPlayer
#1

When i click on someone, then i get kicked and not him i clicked at -.-'



pawn Код:
#include <a_samp>

new Player[20];
new tmp[128];

//-------------------------------Dialog-----------------------------------------
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Admin Menu", "Kick Player", "Select", "Cancel");

        new id = strval(tmp);
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
        Player[playerid] = clickedplayerid;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new name[MAX_PLAYER_NAME], string[44];
    GetPlayerName(playerid, name, sizeof(name));

//List of commands--------------------------------------------------------------
    if(dialogid == 1)
    {
        if(!response)return SendClientMessage(playerid, 0xFF0C29FF,"You have cancelled.");
        {
            if(listitem == 0) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Kick Player", "Type in the kick reason", "Kick Player", "Cancel");
        }
    }
//Kick Player-------------------------------------------------------------------
    if(dialogid == 2)
    {
        if(!response)return SendClientMessage(playerid, 0xFF0C29FF,"You have cancelled.");
        {
            format (string, sizeof(string), "{Admin Kick} %s(%d) %s", name, playerid, inputtext); //ClickedPlayerName, ClickedPlaterID, inputtext
            SendClientMessageToAll(0x0080A1FF, string);

            Player[playerid] = 0;
            //SendClientMessage(playerid, 0xFF0C29FF,"REPLACE WITH KICK...");
            Kick(Player[playerid]);
            return 1;
        }
    }
    return 1;
}
Reply
#2

Kick ( Player [ playerid ] );
Player [ playerid ] = 0;
Reply
#3

Problem SOLVED, Thx for help
Reply
#4

Oh damm, i was eating and i didn't pushed the 'post quick replay' button.

Retardedwolf posted the answer..
Reply
#5

Quote:
Originally Posted by mmrk
Посмотреть сообщение
Oh damm, i was eating and i didn't pushed the 'post quick replay' button.

Retardedwolf posted the answer..
or... The bug is still here :P it worked just one time -.-

Code edited:
pawn Код:
#include <a_samp>

new ClickedPlayer[20];
new tmp[128];

//-------------------------------Dialog-----------------------------------------
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Admin Menu", "Kick Player", "Select", "Cancel");

        new id = strval(tmp);
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
        ClickedPlayer[playerid] = clickedplayerid;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[MAX_PLAYER_NAME];
    new tName[MAX_PLAYER_NAME];
    new string[128];
    new targetid = GetPVarInt(playerid,"ClickedPlayer");
    GetPlayerName(playerid,pName,sizeof pName);
    GetPlayerName(targetid,tName,sizeof tName);

//List of commands--------------------------------------------------------------
    if(dialogid == 1)
    {
        if(!response)return SendClientMessage(playerid, 0xFF0C29FF,"You have cancelled.");
        {
            if(listitem == 0) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Kick Player", "Type in the kick reason", "Kick Player", "Cancel");
        }
    }
//Kick Player-------------------------------------------------------------------
    if(dialogid == 2)
    {
        if(!response)return SendClientMessage(playerid, 0xFF0C29FF,"You have cancelled.");
        {
            format(string,sizeof(string), "{Admin Kick} %s(%d) %s", tName, targetid, inputtext); //ClickedPlayerName, ClickedPlaterID, inputtext
            SendClientMessageToAll(0x0080A1FF, string);

            Kick(ClickedPlayer[playerid]);
            ClickedPlayer[playerid]=0;
            return 1;
        }
    }
    return 1;
}
Reply
#6

You don't need to check if player is connected.
pawn Код:
#include <a_samp>

new ClickedPlayer[MAX_PLAYERS];

//-------------------------------Dialog-----------------------------------------
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Admin Menu", "Kick Player", "Select", "Cancel");
        ClickedPlayer[playerid] = clickedplayerid;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[MAX_PLAYER_NAME];
    new tName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid,pName,sizeof(pName));
    GetPlayerName(ClickedPlayer[playerid],tName,sizeof(tName));

//List of commands--------------------------------------------------------------
    if(dialogid == 1)
    {
        if(!response) return SendClientMessage(playerid, 0xFF0C29FF,"You have cancelled.");
        else
        {
            if(listitem == 0) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Kick Player", "Type in the kick reason", "Kick Player", "Cancel");
        }
    }
//Kick Player-------------------------------------------------------------------
    if(dialogid == 2)
    {
        if(!response)return SendClientMessage(playerid, 0xFF0C29FF,"You have cancelled.");
        else
        {
            format(string,sizeof(string), "{Admin Kick} %s(%d) %s", tName, ClickedPlayer[playerid], inputtext); //ClickedPlayerName, ClickedPlaterID, inputtext
            SendClientMessageToAll(0x0080A1FF, string);

            Kick(ClickedPlayer[playerid]);
            return 1;
        }
    }
    return 1;
}
Reply
#7

Thanks, it works, but i also have an problem with mute =/

pawn Код:
Mute[playerid] = 1; //<--- Mutes me and not the player i clicked on.
Mute(ClickedPlayer[playerid] = 1; //<--- Gives me an error
Reply
#8

Try with this
pawn Код:
Mute[ClickedPlayer[playerid]] = 1;
Reply
#9

Instead of setting it to 0, Put it to INVALID_PLAYER_ID.
Reply
#10

Quote:
Originally Posted by mmrk
Посмотреть сообщение
Try with this
pawn Код:
Mute[ClickedPlayer[playerid]] = 1;
THANK YOU
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)