Raised This Month: $ Target: $400
 0% 

Sockets help..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lucky109
Senior Member
Join Date: Jan 2005
Old 06-06-2007 , 11:20   Sockets help..
Reply With Quote #1

how to use sockets to send the player name when playe enter the command and receives the player name from a socket ???
lucky109 is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-06-2007 , 11:22   Re: Sockets help..
Reply With Quote #2

interesting!
Tell me more please
__________________
regalis is offline
lucky109
Senior Member
Join Date: Jan 2005
Old 06-06-2007 , 11:47   Re: Sockets help..
Reply With Quote #3

Quote:
Originally Posted by regalis View Post
interesting!
Tell me more please
Code:
Client Side:

#include <amxmodx>
#include <amxmisc>
#include <sockets>

#define HOST "127.0.01"
new g_connection;

public plugin_init() {
    register_clcmd("savemyname", "testFunction");
}

writeSocket(string[], len)
{
    socket_send(g_connection, string, len);
}

public testFunction(id)
{
    new error = 0;
    
    g_connection = socket_open(HOST, 1337, SOCKET_TCP, error);
    
    if(g_connection <= 0)
    {
        switch(error)
        {
            case 1: 
            {
                server_print("Error while creating socket.");
            }
            
            case 2: 
            {
                server_print("Error while resolving hostname.");
            }
            
            case 3: 
            {
                server_print("Couldn't connect to %s:1337", HOST);
            }
        }
        
        return PLUGIN_CONTINUE;
    }
    
    new name[32];
    get_user_name(id,name,31);
    new httpGet[128];
    formatex(httpGet, 127, "%s", name);
    writeSocket(httpGet, 128);
    return PLUGIN_CONTINUE;
}
how about server side and receives data from a socket on client side??
my english too bad..sorry

Last edited by lucky109; 06-06-2007 at 11:49.
lucky109 is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-06-2007 , 12:33   Re: Sockets help..
Reply With Quote #4

I understand the following...you have a command for the players which they can use to store their names on a webpage!?
You need a php-page or something similar which receives the data you send through the socket..
But to be honest is don't know how to do sockets and stuff..
Doesn't this code work? it looks correct!?..0o

greetz regalis
__________________
regalis is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 10:36.


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