SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 26/11/2016, 05:24 PM   #271
CoaPsyFactor
Gangsta
 
Join Date: Jul 2010
Location: Belgrade, Serbia
Posts: 871
Reputation: 47
Default Re: Socket plugin (v0.2b released)

there is bug with socket_remote_client_connected, fix is really easy.

File CSocket.cpp on line 286 condition should be reversed

Code:
if(m_pSocketInfo[socketid].ssl) {
	if(recv(m_pSocketInfo[socketid].connected_clients[remote_clientid], tempbuf, sizeof(tempbuf), NULL) != 0)
		return 1;
}
should be

Code:
if(false == m_pSocketInfo[socketid].ssl) {
	if(recv(m_pSocketInfo[socketid].connected_clients[remote_clientid], tempbuf, sizeof(tempbuf), NULL) != 0)
		return 1;
}
__________________
Quote:
Originally Posted by ThaiLuan View Post
Code:
C:\Users\Administrator\Downloads\Viet-RP\gamemodes\3mien.pwn(112016) : fatal error 101: cannot write to file: "disk full"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Help me! How to fix error
CoaPsyFactor is offline   Reply With Quote
Old 22/12/2016, 07:47 PM   #272
oMa37
High-roller
 
oMa37's Avatar
 
Join Date: Feb 2016
Posts: 1,033
Reputation: 152
Default Re: Socket plugin (v0.2b released)

Hey,

I have been recently trying to send/receive from the server to my PHP file through this plugin, It's going pretty well but I'm just facing one issue with receiving the data from the server, It just keeps on crashing the website or sending errors, I'm running a 3 seconds timer to update the chat, Here is my codes anyway:


In the PHP file:

PHP Code:
if(socket_recv $sock $msg2045 ) === TRUE)
            {
                echo 
'<div class="msg"><span class="username">'.$msg.'</span></div>';
            }
            else {
             
                
$errorcode socket_last_error();
                
$errormsg socket_strerror($errorcode);
                 
                die(
"Could not receive data: [$errorcode$errormsg \n");
            } 
In the PWN file:

PHP Code:
public OnGameModeInit() {

    
oSocket socket_create(TCP);
    if(
is_socket_valid(oSocket)) {

        
socket_set_max_connections(oSocket10);
        
socket_listen(oSocket1337);
    }    
    return 
1;
}

public 
OnPlayerText(playeridtext[]) {

    new 
name[MAX_PLAYER_NAME+1];
    
GetPlayerName(playeridnamesizeof name);

    new 
str[80];
    
format(strsizeof str"%s: %s"nametext);
    
socket_send(oSocketstrsizeof str);
    return 
1;

The connection between the server and the website is fine.
oMa37 is offline   Reply With Quote
Old 25/01/2017, 01:11 PM   #273
Riccardomen
Little Clucker
 
Join Date: Aug 2012
Posts: 21
Reputation: 1
Default Re: Socket plugin (v0.2b released)

The plugin wont load i dont know why..
"failed to load socket.dll"
Riccardomen is offline   Reply With Quote
Old 25/01/2017, 11:06 PM   #274
Jeroen52
Gangsta
 
Jeroen52's Avatar
 
Join Date: Oct 2008
Location: The Netherlands
Posts: 803
Reputation: 62
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by Riccardomen View Post
The plugin wont load i dont know why..
"failed to load socket.dll"
Are you certain that the socket.dll file is in your plugins/ folder?
__________________
Jeroen52 is offline   Reply With Quote
Old 23/02/2017, 06:09 PM   #275
MerryDeer
Banned
 
Join Date: Jun 2016
Posts: 727
Reputation: 8
Default Re: Socket plugin (v0.2b released)

How to send from website, to sa-mp server only?
MerryDeer is offline   Reply With Quote
Old 24/02/2017, 04:17 AM   #276
azzerking
Gangsta
 
azzerking's Avatar
 
Join Date: Dec 2009
Location: England, Leicestershire
Posts: 496
Reputation: 70
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by MerryDeer View Post
How to send from website, to sa-mp server only?
I'm guessing your using PHP, right? If so then you need to read up on PHP about sending data via sockets. You will need to setup your server to accept a socket connection from your website, and then via PHP send the raw data to the samp server.

A useful tip would to use JSON or serialization to pass large amounts of data to the server, but if your only sending a small amount, you might be okay. Make sure you secure your connection if possible, make sure only your webserver ip address is the one connecting, and that if you can use SSL to secure your traffic, there is a free way to do this using Let Encrypt ( ****** Search ), yet can be difficult to setup in some cases.

Sources
Official PHP Sockets Page
PHP Sockets Tutorial
__________________


Web Skill: PHP, HTML, CSS, JS, RUBY, NODE.js.

Programing Skill: Objective C, C#, C++, D#, Python, Java, MySQL.

OS Skill: Windows (95 - 10), Ubuntu/Debian, Raspbian, Kali, Arch, Unix, Mac (E-MACs - Current)

Scripting Skill: LUA, Pawn, C38*
azzerking is offline   Reply With Quote
Old 24/02/2017, 04:48 AM   #277
azzerking
Gangsta
 
azzerking's Avatar
 
Join Date: Dec 2009
Location: England, Leicestershire
Posts: 496
Reputation: 70
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by oMa37 View Post
Hey,

I have been recently trying to send/receive from the server to my PHP file through this plugin, It's going pretty well but I'm just facing one issue with receiving the data from the server, It just keeps on crashing the website or sending errors, I'm running a 3 seconds timer to update the chat, Here is my codes anyway:


In the PHP file:

PHP Code:
if(socket_recv $sock $msg2045 ) === TRUE)
            {
                echo 
'<div class="msg"><span class="username">'.$msg.'</span></div>';
            }
            else {
             
                
$errorcode socket_last_error();
                
$errormsg socket_strerror($errorcode);
                 
                die(
"Could not receive data: [$errorcode$errormsg \n");
            } 
In the PWN file:

PHP Code:
public OnGameModeInit() {

    
oSocket socket_create(TCP);
    if(
is_socket_valid(oSocket)) {

        
socket_set_max_connections(oSocket10);
        
socket_listen(oSocket1337);
    }    
    return 
1;
}

public 
OnPlayerText(playeridtext[]) {

    new 
name[MAX_PLAYER_NAME+1];
    
GetPlayerName(playeridnamesizeof name);

    new 
str[80];
    
format(strsizeof str"%s: %s"nametext);
    
socket_send(oSocketstrsizeof str);
    return 
1;

The connection between the server and the website is fine.
PHP is not really meant for this scenario, it would be a better bet using something like node.js or python. The reason for this is that PHP is subjected to a request system, so it will only be called when apache calls the file after you proceed to the site.

Though there is a way to make PHP run infinitely it is not a suggested route to take, and will lead to such issues as what you currently have. PHP ends its process right after the code has been ran, meaning that though you have that code waiting to receive the data, it will not run it since the process is not running to execute it.

This is why I suggested to run something like node.js since the application is designed to run constantly, and not end after the code has been ran.

If you are in fact running PHP in a while loop to keep it alive, and your still not getting data, it maybe that your loops is causing the issue, with reading data from the socket and instead your data is being dropped.

It would be helpful if you could explain your setup, to further help us to finding a solution.
__________________


Web Skill: PHP, HTML, CSS, JS, RUBY, NODE.js.

Programing Skill: Objective C, C#, C++, D#, Python, Java, MySQL.

OS Skill: Windows (95 - 10), Ubuntu/Debian, Raspbian, Kali, Arch, Unix, Mac (E-MACs - Current)

Scripting Skill: LUA, Pawn, C38*
azzerking is offline   Reply With Quote
Old 06/04/2017, 11:57 PM   #278
Saddin
Huge Clucker
 
Saddin's Avatar
 
Join Date: Mar 2011
Posts: 321
Reputation: 32
Default Re: Socket plugin (v0.2b released)

can someone help me?

i made visual studio application that connects to server via socket and send integer to server but i cant recieve it in script

how to read that data?

i connected to server via socket on both sides but dont know what to use of those natives in script and where
Saddin is offline   Reply With Quote
Old 07/04/2017, 11:07 AM   #279
Crazy_Str
Little Clucker
 
Join Date: Aug 2011
Location: Russia
Posts: 28
Reputation: 0
Default Re: Socket plugin (v0.2b released)

Who has problems on the Windows system? unpack in folder game server.
https://yadi.sk/d/sp0vposL3Gk7FR
folder server.rar
__________________
Crazy_Str is offline   Reply With Quote
Old 07/04/2017, 11:47 AM   #280
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,094
Reputation: 130
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by Saddin View Post
can someone help me?

i made visual studio application that connects to server via socket and send integer to server but i cant recieve it in script

how to read that data?

i connected to server via socket on both sides but dont know what to use of those natives in script and where
Checkout TCP Server example script.
__________________
Путин here,
Путин there,
Путин просто everywhere.


Any PM's that include question about any kind of help will be ignored.
Use appropriate boards for that
DRIFT_HUNTER is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Socket Plugin] Retrieving input stream iRage Scripting Help 0 08/01/2014 10:11 AM
Question about socket plugin Kirollos Scripting Help 6 13/07/2012 09:33 PM


All times are GMT. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.