Dialog Help
#1

if i want to make dialog with : OnPlayerClickPlayer
its a DIALOG_STYLE_LIST
then on DialogRespond
what should be clickedplayerid
PHP код:
public OnPlayerClickPlayer(playeridclickedplayeridsource)
{
    if(
pInfo[playerd][Adminlevel] || IsPlayerAdmin[playerid]) return 1;
    
ShowPlayerDialog(playerid,6,DIALOG_STYLE_LIST,"Action","Kick /n Ban","Ok","Close");
    return 
1;

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
if(
dialogid == Click//response for the showplayerdialog
{
    if(
response)
    {
        switch(
listitem)
        {
            case 
0://Kick
            
{
                    
Kick(clickedplayerid); //How to make this??
            
}
            case 
1//Ban
            
{
                    
Ban(clickedplayerid); //And this....
            
}
        }
    }
    return 
1;
}
    return 
0;
  } 
Reply
#2

Save the player's ID you clicked on via the scoreboard in a variable, and use that in OnDialogResponse instead of clickedplayerid.
Reply
#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
#4

Quote:
Originally Posted by Threshold
Посмотреть сообщение
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
Thnx Alot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)