AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sockets help.. (https://forums.alliedmods.net/showthread.php?t=56086)

lucky109 06-06-2007 11:20

Sockets help..
 
how to use sockets to send the player name when playe enter the command and receives the player name from a socket ???

regalis 06-06-2007 11:22

Re: Sockets help..
 
interesting!
Tell me more please :)

lucky109 06-06-2007 11:47

Re: Sockets help..
 
Quote:

Originally Posted by regalis (Post 486307)
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

regalis 06-06-2007 12:33

Re: Sockets help..
 
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


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

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