//native TSC_SetClientChannelGroup(uid[], groupid, channelname[]); cell AMX_NATIVE_CALL native_TSC_SetClientChannelGroup(AMX* amx, cell* params) { char *TmpParam = NULL; amx_StrParam(amx, params[1], TmpParam); string UID(TmpParam); TSServer.EscapeString(UID); amx_StrParam(amx, params[3], TmpParam); string ChannelName(TmpParam); TSServer.EscapeString(ChannelName); CommandList *cmds = new CommandList; string CmdStr("channelfind pattern="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr, "cid")); char FormatTmp[256]; sprintf(FormatTmp, "clientdbfind pattern=%s -uid", UID.c_str()); cmds->push(new CCommand(FormatTmp, "cldbid")); sprintf(FormatTmp, "setclientchannelgroup cgid=%d cid=<1> cldbid=<2>", (int)params[2]); cmds->push(new CCommand(FormatTmp)); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_SetChannelDescription(channelname[], desc[]); cell AMX_NATIVE_CALL native_TSC_SetChannelDescription(AMX* amx, cell* params) { char *TmpParam = NULL; amx_StrParam(amx, params[1], TmpParam); string ChannelName(TmpParam); TSServer.EscapeString(ChannelName); amx_StrParam(amx, params[2], TmpParam); string Desc(TmpParam); TSServer.EscapeString(Desc); CommandList *cmds = new CommandList; string CmdStr("channelfind pattern="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr, "cid")); CmdStr.assign("channeledit cid=<1> channel_description="); CmdStr.append(Desc); cmds->push(new CCommand(CmdStr)); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_SendChannelMessage(channelname[], msg[]); cell AMX_NATIVE_CALL native_TSC_SendChannelMessage(AMX* amx, cell* params) { char *TmpParam = NULL; amx_StrParam(amx, params[1], TmpParam); string ChannelName(TmpParam); TSServer.EscapeString(ChannelName); amx_StrParam(amx, params[2], TmpParam); string Msg(TmpParam); TSServer.EscapeString(Msg); CommandList *cmds = new CommandList; string CmdStr("channelfind pattern="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr, "cid")); char FormatTmp[256]; sprintf(FormatTmp, "sendtextmessage targetmode=2 target=<1> msg=%s", Msg.c_str()); cmds->push(new CCommand(FormatTmp)); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_MoveChannelBelowChannel(channelname[], parentchannelname[]); cell AMX_NATIVE_CALL native_TSC_MoveChannelBelowChannel(AMX* amx, cell* params) { char *TmpParam = NULL; amx_StrParam(amx, params[1], TmpParam); string ChannelName(TmpParam); TSServer.EscapeString(ChannelName); amx_StrParam(amx, params[2], TmpParam); string ParentChannelName(TmpParam); TSServer.EscapeString(ParentChannelName); CommandList *cmds = new CommandList; string CmdStr("channelfind pattern="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr, "cid")); CmdStr.assign("channelfind pattern="); CmdStr.append(ParentChannelName); cmds->push(new CCommand(CmdStr, "cid")); cmds->push(new CCommand("channeledit cid=<1> channel_order=<2>")); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_CreateChannel(channelname[]); cell AMX_NATIVE_CALL native_TSC_CreateChannel(AMX* amx, cell* params) { char *ChannelNameTmp = NULL; amx_StrParam(amx, params[1], ChannelNameTmp); string ChannelName(ChannelNameTmp); TSServer.EscapeString(ChannelName); CommandList *cmds = new CommandList; string CmdStr("channelcreate channel_name="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr)); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_DeleteChannel(channelname[]); cell AMX_NATIVE_CALL native_TSC_DeleteChannel(AMX* amx, cell* params) { char *ChannelNameTmp = NULL; amx_StrParam(amx, params[1], ChannelNameTmp); string ChannelName(ChannelNameTmp); TSServer.EscapeString(ChannelName); CommandList *cmds = new CommandList; string CmdStr("channelfind pattern="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr, "cid")); cmds->push(new CCommand("channeldelete cid=<1> force=1")); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_SendServerMessage(msg[]); cell AMX_NATIVE_CALL native_TSC_SendServerMessage(AMX* amx, cell* params) { char *TmpParam = NULL; amx_StrParam(amx, params[1], TmpParam); string Msg(TmpParam); TSServer.EscapeString(Msg); CommandList *cmds = new CommandList; string CmdStr("serveridgetbyport virtualserver_port="); CmdStr.append(TSServer.GetPort()); cmds->push(new CCommand(CmdStr, "server_id")); char FormatTmp[256]; sprintf(FormatTmp, "sendtextmessage targetmode=3 target=<1> msg=%s", Msg.c_str()); cmds->push(new CCommand(FormatTmp)); TSServer.AddCommandListToQueue(cmds); return 1; }
//native TSC_SetChannelTalkPower(channelname[], talkpower); cell AMX_NATIVE_CALL native_TSC_SetChannelTalkPower(AMX* amx, cell* params) { char *TmpParam = NULL; amx_StrParam(amx, params[1], TmpParam); string ChannelName(TmpParam); TSServer.EscapeString(ChannelName); CommandList *cmds = new CommandList; string CmdStr("channelfind pattern="); CmdStr.append(ChannelName); cmds->push(new CCommand(CmdStr, "cid")); char FormatTmp[64]; sprintf(FormatTmp, "channeledit cid=<1> channel_needed_talk_power=%d", (int)params[2]); cmds->push(new CCommand(FormatTmp)); TSServer.AddCommandListToQueue(cmds); return 1; }
int main(int argc, char *argv[]) { UNUSED(argc); UNUSED(argv); if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) { fprintf(stderr, "Could not initialise SDL: %s\n", SDL_GetError()); return -1; } if (SDLNet_Init() == -1) { fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError()); exit(EXIT_FAILURE); } if (!SDL_SetVideoMode(320, 200, 0, 0)) { fprintf(stderr, "Could not set video mode: %s\n", SDL_GetError()); SDL_Quit(); exit(-1); } ConfigLoadDefault(&gConfig); ConfigLoad(&gConfig, GetConfigFilePath(CONFIG_FILE)); EventInit(&gEventHandlers, NULL, false); NetInputClient client; NetInputClientInit(&client); NetInputClientConnect(&client, 0x7F000001); // localhost printf("Press esc to exit\n"); Uint32 ticksNow = SDL_GetTicks(); Uint32 ticksElapsed = 0; for (;;) { Uint32 ticksThen = ticksNow; ticksNow = SDL_GetTicks(); ticksElapsed += ticksNow - ticksThen; if (ticksElapsed < 1000 / FPS_FRAMELIMIT) { SDL_Delay(1); debug(D_VERBOSE, "Delaying 1 ticksNow %u elapsed %u\n", ticksNow, ticksElapsed); continue; } EventPoll(&gEventHandlers, SDL_GetTicks()); int cmd = GetOnePlayerCmd( &gEventHandlers, &gConfig.Input.PlayerKeys[0], false, INPUT_DEVICE_KEYBOARD, 0); if (cmd) { printf("Sending %s + %s\n", CmdStr(cmd & (CMD_LEFT | CMD_RIGHT | CMD_UP | CMD_DOWN)), CmdStr(cmd & (CMD_BUTTON1 | CMD_BUTTON2 | CMD_BUTTON3 | CMD_BUTTON4 | CMD_ESC))); NetInputClientSend(&client, cmd); } // Check keyboard escape if (KeyIsPressed(&gEventHandlers.keyboard, SDLK_ESCAPE)) { break; } ticksElapsed -= 1000 / FPS_FRAMELIMIT; } NetInputClientTerminate(&client); EventTerminate(&gEventHandlers); SDLNet_Quit(); SDL_Quit(); return 0; }