02.09.2016, 05:32
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
https://sampwiki.blast.hk/wiki/SetPVarInt
https://sampwiki.blast.hk/wiki/GetPVarInt
PHP код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
if(pInfo[playerid][Adminlevel] || IsPlayerAdmin(playerid)) return 1;
SetPVarInt(playerid, "ClickedPlayer", clickedplayerid); // Save the clicked player's ID into the PVar 'ClickedPlayer'.
ShowPlayerDialog(playerid, 6 , DIALOG_STYLE_LIST, "Action", "Kick /n Ban", "Ok", "Close");
// Shouldn't dialogid be 'Click', not '6'? Meh...
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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/GetPVarInt