Ich habe ein Problem. Wenn ich ohne Launcher-Server verbinden, sagt es, dass ich Launcher haben, aber wenn ich mit Abschussrampe verbinden, sagt es, dass ich Launcher nicht.
C
#include <a_samp>
#include <socket>
#include <foreach>
new Socket:g_Socket;
main () {}
enum SOCKET
{
PlayerID,
SocketIP[19],
Name[24]
};
new SocketInfo[MAX_PLAYERS][SOCKET];
new Player_Socket_ID[MAX_PLAYERS]={-1,...};
public OnGameModeInit()
{
g_Socket = socket_create(TCP);
new IP[20] = "192.168.1.103";
new Port = 7775;
if(tcpConnect(IP, Port))
socket_set_max_connections(g_Socket, 10);
socket_listen(g_Socket, Port);
return 1;
}
public OnGameModeExit()
{
if(is_socket_valid(g_Socket))
socket_destroy(g_Socket);
return 1;
}
stock tcpConnect(ip[], port)
{
g_Socket = socket_create(TCP);
return 1;
}
stock TCP_server()
{
g_Socket = socket_create(TCP);
new IP[20] = "192.168.1.103";
new Port = 7775;
if(udpConnect(IP, Port))
return 0;
}
public onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid)
{
printf("[LAUNCHER] Connection to Socket Server. | ClientID: [%d] | ClientIP: [%s] ",remote_clientid, remote_client);
format(SocketInfo[remote_clientid][SocketIP], 16, remote_client);
return 1;
}
public onSocketRemoteDisconnect(Socket:id, remote_clientid)
{
printf("[LAUNCHER] Player Socket ponisten | ClientID: [%d] | PlayerID: [%d] ",remote_clientid, SocketInfo[remote_clientid][PlayerID]);
if(IsPlayerConnected(SocketInfo[remote_clientid][PlayerID]))
{
Player_Socket_ID[SocketInfo[remote_clientid][PlayerID]] = -1;
SocketInfo[remote_clientid][PlayerID] = -1;
format(SocketInfo[remote_clientid][SocketIP],16,"-1");
format(SocketInfo[remote_clientid][Name], 24, "-1");
}
return 1;
}
public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
{
printf("Remote client [%d] has sent: %s", remote_clientid, data);
format(SocketInfo[remote_clientid][Name], 24, data);
return 1;
}
public OnPlayerConnect(playerid)
{
new IP[16];
GetPlayerIp(playerid, IP, sizeof(IP));
for(new n = 0; n < MAX_PLAYERS; n++)
{
if(!strcmp(IP, SocketInfo[n][SocketIP], false, strlen(IP)) && !strcmp(ImeIgraca(playerid), SocketInfo[n][Name],false, strlen(ImeIgraca(playerid))))
{
SocketInfo[n][PlayerID] = playerid;
Player_Socket_ID[playerid] = n;
SendClientMessage(playerid, -1, "[LAUNCHER] You are connected to launcher.");
printf("[LAUNCHER] Player ID: [%d] se konektovao sa launcherom, ClientID: [%d].",playerid,Player_Socket_ID[playerid]);
break;
}
else
{
SendClientMessage(playerid, -1,"[LAUNCHER] You didn't use launcher for connection.");
break;
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
printf("[LAUNCHER] Player ID [%d] se diskonektovao sa servera. ClientID je iskljucen: [%d]",playerid,Player_Socket_ID[playerid]);
socket_sendto_remote_client(g_Socket, Player_Socket_ID[playerid], "DISCONNECT");
socket_close_remote_client(g_Socket,Player_Socket_ID[playerid]);
SocketInfo[Player_Socket_ID[playerid]][PlayerID] = -1;
format(SocketInfo[Player_Socket_ID[playerid]][SocketIP],16, "-1");
format(SocketInfo[Player_Socket_ID[playerid]][Name], 24, "-1");
Player_Socket_ID[playerid] = -1;
return 1;
}
stock ImeIgraca(id)
{
new ime[MAX_PLAYER_NAME];
GetPlayerName(id, ime, sizeof ime);
return ime;
}
Alles anzeigen
Entschuldigen Sie bitte für mein nicht so gutes Deutsch