Jump to content
  • 0

pomoc (HELP)Písanie z webu na SA-MP Server


LukikeX

Dotaz

Zdravím,

 

Mám menší problém: potreboval by som script, ktorý by umožnil hráčom, ktorí navštívili môj server odpovedať do chatu aj cez web, že by na webe bolo políčko, do ktorého by hráč musel napísať nick, druhé políčko na napísanie heslo, ktoré zadal pri registrácií na servery a tretie políčko, ktoré by slúžilo na písanie do chatu, text sa zobrazí aj na servery aj na webe.Keby niekto nebol zaregistrovaný na servery a by na web nenapísal heslo, ktoré zadal pri registrácií, aby nemohol písať do chatu cez web.

 

Ak ste niekto skúsený PAWNER alebo PHP kóder, prosím napíšte mi sem kód na tento script, za vaše návrhy a pomoc budem veľmi vďačný :)

 

Ďakujem Vám za každú pomoc ... :)

Link to comment
Share on other sites

5 odpovědí na tuto otázku

Recommended Posts

  • 0

 

class QueryServer

{

private $szServerIP;

private $rSocketID;

 

function VerifyAddress( $szServerIP )

{

if (ip2long( $szServerIP ) !== false &&

long2ip( ip2long( $szServerIP ) ) == $szServerIP )

{

return $szServerIP;

}

 

$szAddress = gethostbyname( $szServerIP );

if ($szAddress == $szServerIP) {

return "";

}

 

return $szAddress;

}

 

function __construct( $szServerIP, $iPort )

{

$this->szServerIP = $this->VerifyAddress( $szServerIP );

$this->iPort = $iPort;

 

if (empty( $this->szServerIP ) || !is_numeric( $iPort )) {

throw new QueryServerException( 'Either the ip-address or the port isn\'t filled in correctly.' );

}

 

$this->rSocketID = @fsockopen( 'udp://' . $this->szServerIP, $iPort, $iErrorNo, $szErrorStr, 5 );

if (!$this->rSocketID) {

throw new QueryServerException( 'Cannot connect to the server: ' . $szErrorStr );

}

 

socket_set_timeout( $this->rSocketID, 0, 500000 );

$this->bStatus = true;

}

 

function SendPacket( $cPacket )

{

$szPacket = 'SAMP';

$aIpChunks = explode( '.', $this->szServerIP );

 

foreach( $aIpChunks as $szChunk )

{

$szPacket .= chr( $szChunk );

}

 

$szPacket .= chr( $this->iPort & 0xFF );

$szPacket .= chr( $this->iPort >> 8 & 0xFF );

$szPacket .= $cPacket;

 

return fwrite( $this->rSocketID, $szPacket, strlen( $szPacket ) );

}

 

function RCON($rcon, $command)

{

echo 'Password '.$rcon.' with '.$command;

if ($this->SendPacket('x '.$rcon.' '.$command) === false)

{

throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );

}

$aReturnArray = fread( $this->rSocketID, 11 );

echo fread( $this->rSocketID, 11 );

return $aReturnArray;

}

 

}

}

 

class QueryServerException extends Exception

{

private $szMessage;

function __construct( $szMessage )

{

$this->szMessage = $szMessage;

}

function toString( )

{

return $this->szMessage;

}

}

 

Jednoduché použití např.:

RCON('rcon_heslo', 'kick '.$ID.'');

By sa-mp.com :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...