ItsMods
Help pleas someone Edit my Code - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: Help pleas someone Edit my Code (/Thread-Help-pleas-someone-Edit-my-Code.html)



pleas someone Edit my Code - raminr63 - 10-13-2012

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:
char * cmdline = (char *)GetCommandLineA();

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:
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; } }