Dialog Help
#3

The easiest way would be to use PVars. You could also use a global variable if you really want to, but again, PVars are good for the lazy person who doesn't like making lots of variables

PHP код:
public OnPlayerClickPlayer(playeridclickedplayeridsource
{
    if(
pInfo[playerid][Adminlevel] || IsPlayerAdmin(playerid)) return 1;
    
SetPVarInt(playerid"ClickedPlayer"clickedplayerid); // Save the clicked player's ID into the PVar 'ClickedPlayer'.
    
ShowPlayerDialog(playeridDIALOG_STYLE_LIST"Action""Kick /n Ban""Ok""Close");
    
// Shouldn't dialogid be 'Click', not '6'? Meh...
    
return 1
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if((
dialogid == Click//response for the showplayerdialog
    
{
        if(
response)
        {
            switch(
listitem)
            {
                case 
0://Kick
                
{
                    new 
target GetPVarInt(playerid"ClickedPlayer"); // Get the ID stored in the PVar 'ClickedPlayer'.
                    
if(!IsPlayerConnected(target)) // If the player that the admin clicked on is no longer connected...
                    
{
                        
SendClientMessage(playerid, -1"That player is no longer connected.");
                        
SetPVarInt(playerid"ClickedPlayer"INVALID_PLAYER_ID); // Reset the ClickedPlayer to an invalid player ID.
                    
}
                    else 
Kick(target);
                }
                case 
1//Ban
                
{
                    new 
target GetPVarInt(playerid"ClickedPlayer"); // Get the ID stored in the PVar
                    
if(!IsPlayerConnected(target)) // If the player that the admin clicked on is no longer connected...
                    
{
                        
SendClientMessage(playerid, -1"That player is no longer connected.");
                        
SetPVarInt(playerid"ClickedPlayer"INVALID_PLAYER_ID); // Reset the ClickedPlayer to an invalid player ID.
                    
}
                    else 
Ban(target);
                }
            }
        }
        return 
1;
    }
    return 
0;

https://sampwiki.blast.hk/wiki/SetPVarInt
https://sampwiki.blast.hk/wiki/GetPVarInt
Reply


Messages In This Thread
Dialog Help - by oktokt1 - 02.09.2016, 04:55
Re: Dialog Help - by SickAttack - 02.09.2016, 05:28
Re: Dialog Help - by Threshold - 02.09.2016, 05:32
Re: Dialog Help - by oktokt1 - 02.09.2016, 08:32

Forum Jump:


Users browsing this thread: 1 Guest(s)