public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
if(pInfo[playerd][Adminlevel] || IsPlayerAdmin[playerid]) return 1;
ShowPlayerDialog(playerid,6,DIALOG_STYLE_LIST,"Action","Kick /n Ban","Ok","Close");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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;
}
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;
}
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 код:
https://sampwiki.blast.hk/wiki/GetPVarInt |