PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <sockets> // sockets include
#include <amxmisc>
new sckSTREAM //var socket name
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
/* Init CVars for the socket "STREAM" */
if (cvar_exists("amx_STREAM_socket")) {
sckSTREAM = get_cvar_num("amx_STREAM_socket") //value number
read_STREAM()
}
else
register_cvar("amx_STREAM_socket", "0", FCVAR_PROTECTED&FCVAR_UNLOGGED)
/* up u change to readable value End */
}
/* Socket STREAM */
public connect_STREAM() { // called if you connect to ur socket connection
new error = 0
sckSTREAM = socket_open("servecounterstrike.com", 80, SOCKET_TCP, error) // the info (site, port usage, type)
if (sckSTREAM > 0) {
/* Connect successful */
read_STREAM()
}
else {
switch (error) {
case 1: { /* Error creating socket */ } //in cases when fails..
case 2: { /* Could not resolve hostname */ }
case 3: { /* Could not connect to given host:port */ }
}
}
}
public read_STREAM() { //called while socket is in use
if (socket_change(sckSTREAM, 100)) {
new buf[512], lines[30][100], count = 0
socket_recv(sckSTREAM, buf, 511)
count = ExplodeString(lines, 29, 99, buf, 13)
for(new i=0;i<count;i++) {
/* Process items here (functions etc..)*/
}
}
if (sckSTREAM != 0)
set_task(0.5, "read_STREAM")
else {
set_cvar_num("amx_STREAM_socket", 0)
disconnect_STREAM()
}
}
public write_STREAM(text[512]) {
socket_send(sckSTREAM, text, 511)
}
public disconnect_STREAM() {
/* Disconnected */
}
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter ) { // Function by xeroblood
new nIdx = 0, l = strlen(p_szInput)
new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
while( (nLen < l) && (++nIdx < p_nMax) )
nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
return nIdx
}
__________________
[IMG]http://img24.**************/img24/3333/92810204.png[/IMG]