Help pleas someone Edit my Code
#1
Hi
i use this code for Bind hotkey (F1) to connect to the server.
to work this code i have to run my game with this parameter:

iw5mp.exe +server 192.168.137.1:27017

But i want to run Game without this parameters and i need to edit this code
so i want to Add ip and port into this code so there is no need to GetCommandLineA() in this lin:

[code=cpp] char * cmdline = (char *)GetCommandLineA(); [/code]

But i dont know how can i do this may i pleased someone do that for me.
i will very Thanks from he/she.

[code=cpp]

if (vKey == VK_F1)
{
Console(0, V("connect_extF1\n\n"));
}

if (strncmp(command, V("connect_extF1"), 11) == 0)
{
char * cmdline = (char *)GetCommandLineA();
char *server = strstr(cmdline, V("+server "));
if (server == NULL)
{
info("ERROR: +server commandline param not found.");
return 0;
}

ServerList* pList = ServerList::getInstance();
if (pList == NULL)
{
info("ERROR: Unable to get ServerList instance!");
return 0;
}

char connect_cmd[255];

DWORD ip = 0;
USHORT port = 0;
char ip_str[255];

if (parseIpPort(server+8, &ip, &port))
{
makeIPstr(ip, ip_str);

sprintf(connect_cmd, V("connect %s:%d\n"), ip_str, port);

#ifdef DEBUGGING_ENABLED
info("ip %08X port %04X ->> console cmd will be: %s", ip, port, connect_cmd);
#endif


void * blob = pList->createConnectionBlob(htonl(ip), port, false);
pList->startConnBlobLoaderThread(blob);

return tramp(unk, connect_cmd);
}
else
{
info("ERROR: Invalid 'server' command line value. Required format: +server ip:netport");
return 0;
}
}


[/code]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Mep Edit coordinance raminr63 2 4,442 10-22-2013, 15:02
Last Post: Yamato
  Help Code color crosshairs koren30 3 5,254 10-02-2013, 19:26
Last Post: koren30
  Help need help?how to make plugins code hXnarutoXone 12 11,704 09-01-2013, 18:30
Last Post: Bandarigoda123
  Help Need Help with C# code tubwux 2 4,318 08-27-2013, 18:18
Last Post: tubwux
Information Help How to edit new derived entry? (Solved) SSonic70 1 3,593 08-20-2013, 15:29
Last Post: Nekochan
  [Request] Compile this code please dozsa0 4 5,811 08-10-2013, 21:02
Last Post: Nukem
  Compile this code please First_Semyon 12 12,740 08-08-2013, 14:53
Last Post: Bandarigoda123
  [Release] MOSSY v9.12 Re-edit by BloKK187 BloKK187 24 41,250 08-05-2013, 23:44
Last Post: TheWraith10219
  Compile please this code First_Semyon 8 7,639 07-28-2013, 01:52
Last Post: First_Semyon
  [Request] Edit BOloader 0.8 Bot settings IgnaBmx 2 4,750 06-30-2013, 02:35
Last Post: IgnaBmx

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.