PHP - Kick user with Rcon API
#1

How can i kick some player from this code: https://sampforum.blast.hk/showthread.php?tid=104299

I want under kick to write "Kick" and when someone click to kick him..


Reply
#2

Use the sockets plugin. Best method, in my opinion.
Reply
#3

Yeah, but i dont know how, lol.
Reply
#4

with westie's RCON API, write like the following:

PHP код:
<?php
$rcon 
= new SampRconAPI('server_ip'server_port'server_rcon_pass');
$rcon->Call('kickdatguy ' $playerid_here);
?>
then somewhere in your gm

pawn Код:
public OnRconCommand(cmd[])
{
    if(strfind(cmd, "kickdatguy") != -1)
    {
        //your msgs & Kick() goes here
       return 1;
    }
    return 0;
}
EDIT: you can still use:

PHP код:
<?php
$rcon 
= new SampRconAPI('server_ip'server_port'server_rcon_pass');
$rcon->playerKick($playerid_here);
?>
Reply
#5

And how to kick a player? I must have a hyper link, dont I? If u can write example..

Код:
require "SampQueryAPI.php";
require "SampRconAPI.php";
$query = new SampQueryAPI('193.192.59.30', '7784');
$rcon = new SampRconAPI('193.192.59.30', 7784, '123'); 
 
if($query->isOnline())
{
	$aInformation = $query->getInfo();
	$aServerRules = $query->getRules();
	
	?><center>
	<b>General Information</b>
	<table width="400">
		<tr>
			<td>Hostname</td>
			<td><?= htmlentities($aInformation['hostname']) ?></td>
		</tr>
		<tr>
			<td>Gamemode</td>
			<td><?= htmlentities($aInformation['gamemode']) ?></td>
		</tr>
		<tr>
			<td>Igraca</td>
			<td><?= $aInformation['players'] ?> / <?= $aInformation['maxplayers'] ?></td>
		</tr>
		<tr>
			<td>Map</td>
			<td><?= htmlentities($aInformation['mapname']) ?></td>
		</tr>
		<tr>
			<td>Vreme</td>
			<td><?= $aServerRules['weather'] ?></td>
		</tr>
		<tr>
			<td>World Time</td>
			<td><?= $aServerRules['worldtime'] ?></td>
		</tr>
		<tr>
			<td>Verzija</td>
			<td><?= $aServerRules['version'] ?></td>
		</tr>
		<tr>
			<td>Sifra</td>
			<td><?= $aInformation['password'] ? 'Da' : 'Ne' ?></td>
		</tr>
	</table>
 
	<br />
	<b>Online Igraci</b>
	<?php
	
	$aPlayers = $query->getDetailedPlayers();
	
	if(!is_array($aPlayers) || count($aPlayers) == 0)
	{
		echo '<br /><i>None</i>';
	}
	else
	{
		?>
		<table width="400">
			<tr>
				<td><b>Player ID</b></td>
				<td><b>Ime_Prezime</b></td>
				<td><b>Level</b></td>
				<td><b>Ping</b></td>
				<td><b>Kick</b></td>
			</tr>
		<?php
		foreach($aPlayers as $sValue)
		{
			?>
			<tr>
				<td><?= $sValue['playerid'] ?></td>
				<td><?= htmlentities($sValue['nickname']) ?></td>
				<td><?= $sValue['score'] ?></td>
				<td><?= $sValue['ping'] ?></td>
				<td><?= $rcon->playerKick($playerid_here);  ?></td>

			</tr></center>
			<?php
		}
	
		echo '</table>';
	}
}

}
Reply
#6

make a button or hyperlink that uses onclick event in it which uses "$rcon->playerKick($playerid_here)"
Reply
#7

What to write on $playerid_here?
Reply
#8

The in-game ID of the clicked player.
Reply
#9

Код:
<td><a href="<?$rcon->playerKick['playerid']?>">Kick</a></td>
This is it ^^
Reply
#10

Код:
<td><a href="#" on‌click="<? $rcon->playerKick($sValue['playerid']); ?>">Click to kick</a></td>
I think it will be ok.

@up you can't redirect to function :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)