AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Need help: Socket On CS:GO? (https://forums.alliedmods.net/showthread.php?t=209160)

wwzw 02-21-2013 22:52

Need help: Socket On CS:GO?
 
I need a socket extensions, I found Socket3.0.1 at http://forums.alliedmods.net/showthread.php?t=67640 . But that can not work on CS:GO.
Can someone help me? Thanks!

Mathias. 02-22-2013 12:02

Re: Need help: Socket On CS:GO?
 
As far as I know, it should work on cs:go at 100%, simply because the extension do not interract with any game part, a bit like SQL, if I am not wrong. Why it wouldnt work? Any error message?

wwzw 02-22-2013 19:48

Re: Need help: Socket On CS:GO?
 
I use listenexample.sp example:

PHP Code:

// listening socket example for the socket extension
#include <sourcemod>
#include <socket>
public Plugin:myinfo = {
 
name "listen socket example",
 
author "Player",
 
description "This example provides a simple echo server",
 
version "1.0.1",
 
url "http://www.player.to/"
};
 
public 
OnPluginStart() {
 
SocketSetOption(INVALID_HANDLEDebugMode1);
 new 
Handle:socket SocketCreate(SOCKET_TCPOnSocketError);
 
SocketBind(socket"0.0.0.0"50000);
 
SocketListen(socketOnSocketIncoming);
}
public 
OnSocketIncoming(Handle:socketHandle:newSocketString:remoteIP[], remotePortany:arg) {
 
PrintToServer("%s:%d connected"remoteIPremotePort);
 
SocketSetReceiveCallback(newSocketOnChildSocketReceive);
 
SocketSetDisconnectCallback(newSocketOnChildSocketDisconnected);
 
SocketSetErrorCallback(newSocketOnChildSocketError);
 
SocketSend(newSocket"send quit to quit\n");
}
public 
OnSocketError(Handle:socket, const errorType, const errorNumany:ary) {
 
LogError("socket error %d (errno %d)"errorTypeerrorNum);
 
CloseHandle(socket);
}
public 
OnChildSocketReceive(Handle:socketString:receiveData[], const dataSizeany:hFile) {
 
SocketSend(socketreceiveData);
 if (
strncmp(receiveData"quit"4) == 0CloseHandle(socket);
}
public 
OnChildSocketDisconnected(Handle:socketany:hFile) {
 
CloseHandle(socket);
}
public 
OnChildSocketError(Handle:socket, const errorType, const errorNumany:ary) {
 
LogError("child socket error %d (errno %d)"errorTypeerrorNum);
 
CloseHandle(socket);



Then I use PHP's fsockopen function to send a string. Like this:

PHP Code:

function fsgetdata$port$send)
{
 
$fp fsockopen("tcp://127.0.0.1"$port$errno$errstr1);
 if (!
$fp) {
  return -
1;
 }
 
stream_set_timeout($fp2);
 
fwrite($fp$send);
 
$status stream_get_meta_data($fp);
 if( 
$status['timed_out'] ) {
  
fclose$fp );
  return -
2;
 }
 
$data .= fread($fp4096);
 
//while (!feof($fp))             //This will generate PHP 30 second timeout
 // $data .= fgets($fp, 512);
 
$data trim($datachr(255));
 
$status stream_get_meta_data($fp);
 
fclose($fp);
 return !
$status['time_out'] ? $data : -2;
}
$ch fsgetdata50000"Some msg for test");
 
echo 
"[".$ch."]";
//If not start the server, output "-1"
//Else Was not able to show anything 

Does not display any messages to the console. There is no record of any log.

I used: CS:GO latest version of yesterday. MM :1.9.2 . SM 1.5-hg3786

Mathias. 02-22-2013 20:17

Re: Need help: Socket On CS:GO?
 
I'm not a php master, but I can clearly tell you that is not the extension the problem.

wwzw 02-22-2013 20:27

Re: Need help: Socket On CS:GO?
 
This PHP function should be no errors, I use this function to send a message to scoket_hz.amxx.dll (AMX MOD X), and the right to obtain reply data.

May I ask who has been successfully using Scoket 3.0.1 CS: GO server?

PHP Code:

version
Protocol version 12223
Exe version 1.22.2.3 
(csgo)
Exe build13:44:21 Feb 20 2013 (5218) (730)
meta version
Metamod
:Source version 1.9.2
Build ID
811:a85baef2eadb
Loaded 
As: GameDLL (gameinfo.txt)
Compiled onFeb  6 2013
Plugin 
interface version15:14
SourceHook version
5:5
http
://www.metamodsource.net/
meta list
Listing 3 plugins:
  [
01SourceMod (1.5.0-dev+3786by AlliedModders LLC
  
[02CS Tools (1.5.0-dev+3786by AlliedModders LLC
  
[03SDK Tools (1.5.0-dev+3786by AlliedModders LLC
sm exts 
list
[
SMDisplaying 11 extensions:
[
01Automatic Updater (1.5.0-dev+3786): Updates SourceMod gamedata files
[02Webternet (1.5.0-dev+3786): Extension for interacting with URLs
[03CS Tools (1.5.0-dev+3786): CS extended functionality
[04BinTools (1.5.0-dev+3786): Low-level C/C++ Calling API
[05SDK Tools (1.5.0-dev+3786): Source SDK Tools
[06Top Menus (1.5.0-dev+3786): Creates sorted nested menus
[07Client Preferences (1.5.0-dev+3786): Saves client preference settings
[08SQLite (1.5.0-dev+3786): SQLite Driver
[09Regex (1.5.0-dev+3786): Provides regex natives for plugins
[10Socket (3.0.1): Socket extension for SourceMod
[11MySQL-DBI (1.5.0-dev+3786): MySQL driver implementation for DBI 


Mathias. 02-22-2013 21:02

Re: Need help: Socket On CS:GO?
 
Try the same code with an other source server, I bet you will have the same result. How to explain you this... Basicly this extension should not change any game data anything related to the game, it the same as SQL, Regex and everything that don't change anything related to the game but are offer to use with it.

wwzw 02-22-2013 21:47

Re: Need help: Socket On CS:GO?
 
I am in the CS:S server test, it can work!
The console display:
PHP Code:

:58776 connected 

PHP page also display: ($data = fread ($fp, 4096); receive data)
PHP Code:

send quit to quit 

I edit some code of listenexample.sp:
PHP Code:

public OnChildSocketReceive(Handle:socketString:receiveData[], const dataSizeany:hFile) {
 
PrintToServer("Receive: %s"receiveData);
 
SocketSend(socketreceiveData);
 
CloseHandle(socket);


Then I use the following code to receive all the data:
PHP Code:

//$data .= fread($fp, 4096);
while (!feof ($fp))
$data. = fgets ($fp512); 

Console display:
PHP Code:

:60140 connected
Receive
Some msg for test 

PHP web page display:
PHP Code:

send quit to quit Some msg for test 

This obviously: socket3.0.1 on the CS:S is the work is successful, but in the CS:GO is not working properly.

Mathias. 02-22-2013 22:06

Re: Need help: Socket On CS:GO?
 
Hum weird, like I said I was not sure, maybe your right. Good to know this, would be nice if someone more experienced could explain us what going on or even solve the problem.

wwzw 03-08-2013 20:33

Re: Need help: Socket On CS:GO?
 
Thanks for Crytiqal !

I tested: When I login to the server, Socket work properly!
But ... how to make the Socket work, when no player on the server?

Doc-Holiday 03-08-2013 20:39

Re: Re: Need help: Socket On CS:GO?
 
Quote:

Originally Posted by wwzw (Post 1909217)
Thanks for Crytiqal !

I tested: When I login to the server, Socket work properly!
But ... how to make the Socket work, when no player on the server?

Try turning off hibernation


All times are GMT -4. The time now is 23:57.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.