[HELP] OnPlayerClickPlayer
#1

When i press at a ID then i want it to Force the ID to change class, but lets say i am ID_1 then i click at ID_5, Then it force me to change class instead of ID_5

pawn Код:
#include <a_samp>

new tmp[128];

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "blablabla", "Force change class", "Ok", "Cancel");
   
    new id = strval(tmp);
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
   
    new message[128];
    format(message, 128, "You clicked on player %d", clickedplayerid);
    SendClientMessage(playerid, 0xFFFFFFFF, message);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
    {
    switch(dialogid)
        {
        case 1:
            {
            switch(listitem)
                {   //---------------------------------
                    case 0:
                    {
                        for (new i = 0; i < MAX_PLAYERS; i++)
                        {
                            if(IsPlayerConnected(i)) ForceClassSelection(playerid);
                            if(IsPlayerConnected(i)) SetPlayerHealth(playerid,0);
                            if(IsPlayerConnected(i)) SendClientMessage(playerid, 0xFF0000FF,"You have been forced by server admin to change class.");
                        }
                    }
                    //---------------------------------
                }
            }
       }
   }
return 1;
}
Reply
#2

pawn Код:
if(IsPlayerConnected(i)) ForceClassSelection(i);
                            if(IsPlayerConnected(i)) SetPlayerHealth(i,0);
                            if(IsPlayerConnected(i)) SendClientMessage(i, 0xFF0000FF,"You have been forced by server admin to change class.");
There we go. You put in playerid instead of 'i'.
Reply
#3

pawn Код:
#include <a_samp>

new ForeClass[MAX_PLAYERS];

new tmp[128];
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "blablabla", "Force change class", "Ok", "Cancel");
    ForceClass[playerid] = clickedplayerid;
    new id = strval(tmp);
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
    new message[128];
    format(message, 128, "You clicked on player %d", clickedplayerid);
    SendClientMessage(playerid, 0xFFFFFFFF, message);
    return 1;
}

publicOnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        {
            case 1:
            {
                switch(listitem)
                {//---------------------------------
                    case 0:
                    {
                        ForceClassSelection(ForceClass[playerid]);
                        SetPlayerHealth(ForceClass[playerid],0);
                        SendClientMessage(ForceClass[playerid], 0xFF0000FF,"You have been forced by server admin to change class.");
                        ForceClass[playerid] = 999;
                    }
                }//---------------------------------
            }
        }
    }
    return 1;
}
Reply
#4

Thanks to both of you
Reply
#5

or... it didnt work, When i clicked at a player, then the dialog opned for that player i clicked on =/
Reply
#6

Quote:
Originally Posted by Larsey123IsMe
Посмотреть сообщение
or... it didnt work, When i clicked at a player, then the dialog opned for that player i clicked on =/
You are trying to make it so when a player clicks a player in the online players list, it shows the player who clicked the player a dialog of things which they can do to/with them?
Reply
#7

i have cahanged the cobe a vit, maybe more easy to understand then

...
1. Admin click on TAB
2. Then Admin click on a player
3. Then Admin click on "Force change class"
4. Then the player Admin clicked on will be forced to change class

ok, its kinda like a /akill

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(clickedplayerid, 1, DIALOG_STYLE_LIST, "blablabla", "Force change class", "Ok", "Cancel");

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

        new message[128];
        format(message, 128, "You clicked on player %d", clickedplayerid);
        SendClientMessage(playerid, 0xFFFFFFFF, message);
        return 1;
    }
    return 0;
}
Reply
#8

http://forum.sa-mp.com/showpost.php?...39&postcount=3
Reply
#9

You had it set to show the dialog to the player which the admin clicked on. You also had something above the "IsPlayerConnected" check which didn't make any sense to be there - so I removed it and changed the "IsPlayerConnected" to what it should be.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(playerid, DIALOG_STYLE_LIST, "blablabla", "Force change class", "Ok", "Cancel");

        if(!IsPlayerConnected(clickedplayerid)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");

        new message[128];
        format(message, 128, "You clicked on player %d", clickedplayerid);
        SendClientMessage(playerid, 0xFFFFFFFF, message);
        return 1;
    }
    return 0;
}
Reply
#10

ok, it works now, but...

How to add an reason to the Force Player To Change Class?
like: You have been forced by server admin to change class. Reason:


Example:
You have been forced by server admin to change class. Reason: Dont use that skill, it is not finniced yet.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)