Zep Дата: Воскресенье, 03.02.2013, 20:55 | Сообщение # 1
Сообщения: 199
Награды: 2
Замечания:
Код
[CSTRIKE]Invalid player 11 [AMXX]Displaying debug trace (plugin "cssbQuitInAfkDM.amxx") [AMXX]Run time error 10: native error (native "cs_get_user_team") [AMXX][0] cssbQuitInAfkDM.sma::cssbChangeTeam (line 54)
Помогите исправить исходник
Код
#include <amxmodx> #include <amxmisc> #include <message_const> #include <cstrike> #include <fakemeta> #include <fakemeta_util> #include <csdm> //#include <respawn> #pragma semicolon 1 #define PLUGIN "CSSB Quit In Afk DM" #define VERSION "2.0" #define AUTHOR "CSSB" #define SPEC_CHECK_TEAM 30 // Menu keys const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0; const OFFSET_CSDEATHS = 444; const OFFSET_CSTEAMS = 114; const OFFSET_LINUX = 5; new CsTeams:arrCsUserTeam[33]; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); register_dictionary("cssbQuitInAfkDM.txt"); register_clcmd("say", "cssbQuitInAfkDM"); register_clcmd("chooseteam", "cssbChangeTeam"); register_clcmd("jointeam", "cssbChangeTeam"); // Menus new szNameMenu[256]; format(szNameMenu, sizeof(szNameMenu) - 1, "%L",LANG_PLAYER,"CSSB_AFK_MENU_CHOOSE_TEAM"); register_menu(szNameMenu, KEYSMENU, "cssbMenuGame"); csdm_set_intromsg(0); if(!(task_exists(297546,0))) set_task(float(SPEC_CHECK_TEAM),"cssbCheckTeam",297546,_,_,"b"); } // Block Team Change public cssbChangeTeam(idUser) { new CsTeams:csTeamCurrentUser = cs_get_user_team(idUser); if (csTeamCurrentUser == CS_TEAM_UNASSIGNED || arrCsUserTeam [idUser]> CS_TEAM_SPECTATOR || csTeamCurrentUser == CS_TEAM_UNASSIGNED) return PLUGIN_CONTINUE; cssbShowMenuSelectTeam(idUser); return PLUGIN_HANDLED; } // Select Team Menu cssbShowMenuSelectTeam(idUser) { new szMenu[250]; new iLength = 0; new CsTeams:csTeamCurrentUser = cs_get_user_team(idUser); // Title iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\y%L^n^n",LANG_PLAYER, "CSSB_AFK_MENU_CHOOSE_TEAM"); // 1. Terrorist if( (csTeamCurrentUser != CS_TEAM_T && csTeamCurrentUser == CS_TEAM_CT) || (csTeamCurrentUser != CS_TEAM_T && csTeamCurrentUser == CS_TEAM_SPECTATOR) ) iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\r1.\w %L^n", LANG_PLAYER, "CSSB_AFK_TERRORIST"); else iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\d1. %L^n", LANG_PLAYER, "CSSB_AFK_TERRORIST"); // 2. Counter-Terrorist if( (csTeamCurrentUser != CS_TEAM_CT && csTeamCurrentUser == CS_TEAM_T) || (csTeamCurrentUser != CS_TEAM_CT && csTeamCurrentUser == CS_TEAM_SPECTATOR) ) iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\r2.\w %L^n", LANG_PLAYER, "CSSB_AFK_COUNTER_TERRORIST"); else iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\d2. %L^n", LANG_PLAYER, "CSSB_AFK_COUNTER_TERRORIST"); // 3. Spectator if( (csTeamCurrentUser != CS_TEAM_SPECTATOR && csTeamCurrentUser == CS_TEAM_T) || (csTeamCurrentUser != CS_TEAM_SPECTATOR && csTeamCurrentUser == CS_TEAM_CT) ) iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\r3.\w %L^n", LANG_PLAYER,"CSSB_AFK_SPECTR"); else iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "\d3. %L^n", LANG_PLAYER,"CSSB_AFK_SPECTR"); // 0. Exit iLength += formatex(szMenu[iLength], charsmax(szMenu) - iLength, "^n^n\r0.\w %L", LANG_PLAYER, "CSSB_MENU_EXIT"); new szNameMenu[256]; format(szNameMenu, sizeof(szNameMenu) - 1, "%L",LANG_PLAYER,"CSSB_AFK_MENU_CHOOSE_TEAM"); show_menu(idUser, KEYSMENU, szMenu, -1, szNameMenu); } // Game Menu public cssbMenuGame(idUser, key) { new CsTeams:csTeamCurrentUser = cs_get_user_team(idUser); switch (key) { case 0: //Join Terrorist { if(csTeamCurrentUser != CS_TEAM_T) { cs_set_user_team(idUser, CS_TEAM_T,CS_DONTCHANGE); fm_user_kill(idUser, 1); csdm_respawn(idUser); } else { cssbColoredPrint(idUser, "^x01[^x03 !^x01 ]^x04 %L", LANG_PLAYER, "CSSB_CMD_NOT"); cssbShowMenuSelectTeam(idUser); } } case 1: //Join Counter-Terrorist { if(csTeamCurrentUser != CS_TEAM_CT) { cs_set_user_team(idUser, CS_TEAM_CT,CS_DONTCHANGE); fm_user_kill(idUser, 1); csdm_respawn(idUser); } else { cssbColoredPrint(idUser, "^x01[^x03 !^x01 ]^x04 %L", LANG_PLAYER, "CSSB_CMD_NOT"); cssbShowMenuSelectTeam(idUser); } } case 2: //Join Spectator { if(csTeamCurrentUser != CS_TEAM_SPECTATOR) { arrCsUserTeam [idUser]= cs_get_user_team(idUser); new iNumDeath = cs_get_user_deaths(idUser); new iNumFrags = get_user_frags(idUser); cs_set_user_team(idUser, CS_TEAM_SPECTATOR); fm_user_kill(idUser, 1); fm_cs_set_user_deaths(idUser, iNumDeath); set_user_frags(idUser,iNumFrags); RemoveEntityAll("trigger_body"); } else { cssbColoredPrint(idUser, "^x01[^x03 !^x01 ]^x04 %L", LANG_PLAYER, "CSSB_CMD_NOT"); cssbShowMenuSelectTeam(idUser); } } case 3:{cssbShowMenuSelectTeam(idUser);} case 4:{cssbShowMenuSelectTeam(idUser);} case 5:{cssbShowMenuSelectTeam(idUser);} case 6:{cssbShowMenuSelectTeam(idUser);} case 7:{cssbShowMenuSelectTeam(idUser);} case 8:{cssbShowMenuSelectTeam(idUser);} } return PLUGIN_HANDLED; } cssbColoredPrint(target, const message[], any:...) { static buffer[512], i, argscount; argscount = numargs(); // Send to everyone if (!target) { static player; for (player = 1; player <= get_maxplayers(); player++) { // Not connected if (!is_user_connected(player)) continue; // Remember changed arguments static changed[5], changedcount; // [5] = max LANG_PLAYER occurencies changedcount = 0; // Replace LANG_PLAYER with player id for (i = 2; i < argscount; i++) { if (getarg(i) == LANG_PLAYER) { setarg(i, 0, player); changed [changedcount]= i; changedcount++; } } // Format message for player vformat(buffer, charsmax(buffer), message, 3); // Send it message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, player); write_byte(player); write_string(buffer); message_end(); // Replace back player id's with LANG_PLAYER for (i = 0; i < changedcount; i++) setarg(changed[i], 0, LANG_PLAYER); } } // Send to specific target else { // Format message for player vformat(buffer, charsmax(buffer), message, 3); // Send it message_begin(MSG_ONE, get_user_msgid("SayText"), _, target); write_byte(target); write_string(buffer); message_end(); } } public cssbCheckTeam() { new iPlayersNum; new arrPlayers[32]; get_players(arrPlayers,iPlayersNum, "ach"); for(new i = 0; i < iPlayersNum; i++) { new idUser = arrPlayers[i]; if(is_user_alive(idUser)) { new CsTeams:csTeamCurrentUser = cs_get_user_team(idUser); if(csTeamCurrentUser == CS_TEAM_T) arrCsUserTeam [idUser]= CS_TEAM_T; if(csTeamCurrentUser == CS_TEAM_CT) arrCsUserTeam [idUser]= CS_TEAM_CT; } } } stock fm_cs_set_user_deaths(id, value) { set_pdata_int(id, OFFSET_CSDEATHS, value, OFFSET_LINUX); } stock set_user_frags(index, frags) { set_pev(index, pev_frags, float(frags)); return 1; } public cssbQuitInAfkDM(idUser) { new szLeft[6], szRight[123]; new szNameUser[32]; new szSaid[192]; read_args(szSaid,192); remove_quotes(szSaid); strbreak(szSaid, szLeft, 4, szRight, 122); get_user_name(idUser,szNameUser,31); if (equali(szLeft, "/afk")) { if (cs_get_user_team(idUser) == CS_TEAM_SPECTATOR) { cs_set_user_team(idUser, arrCsUserTeam[idUser]); csdm_respawn(idUser); } else { if(is_user_alive(idUser)) { arrCsUserTeam [idUser]= cs_get_user_team(idUser); new iNumDeath = cs_get_user_deaths(idUser); new iNumFrags = get_user_frags(idUser); cs_set_user_team(idUser, CS_TEAM_SPECTATOR); fm_user_kill(idUser, 1); fm_cs_set_user_deaths(idUser, iNumDeath); set_user_frags(idUser,iNumFrags); } } } return PLUGIN_CONTINUE; } stock RemoveEntityAll(name[]) { new ent = engfunc(EngFunc_FindEntityByString, 0, "classname", name); new temp; while (ent) { temp = engfunc(EngFunc_FindEntityByString, ent, "classname", name); engfunc(EngFunc_RemoveEntity, ent); ent = temp; } } public print_message(idUser, msg[],iMsg) { message_begin(iMsg, get_user_msgid("SayText"), {0,0,0}, idUser); write_byte(idUser); write_string(msg); message_end(); } public cssbInfoOnClient(idUser) { new szMessage[256]; format(szMessage, 255, "^x03%L ^x04%L", LANG_PLAYER,"CSSB_AFK_DM", LANG_PLAYER,"CSSB_AFK_SAY"); print_message(idUser, szMessage,MSG_ONE); return PLUGIN_CONTINUE; } public client_putinserver(idUser) { set_task(30.0,"cssbInfoOnClient",idUser); return PLUGIN_CONTINUE; } public client_connect(idUser) { arrCsUserTeam [idUser]= CsTeams; } public client_disconnect(idUser) { arrCsUserTeam [idUser]= CsTeams; }
Сообщение отредактировал Zep - Воскресенье, 03.02.2013, 21:34
Zep Дата: Воскресенье, 03.02.2013, 21:32 | Сообщение # 3
Сообщения: 199
Награды: 2
Замечания:
Contra63 , это куда вставить? Добавлено (03.02.2013, 21:32) --------------------------------------------- Сделал вот так, вроде скомпилировалось Код
// Block Team Change public cssbChangeTeam(idUser) { new CsTeams:csTeamCurrentUser = cs_get_user_team(idUser); if (csTeamCurrentUser == CS_TEAM_UNASSIGNED || arrCsUserTeam [idUser]> CS_TEAM_SPECTATOR || csTeamCurrentUser == CS_TEAM_UNASSIGNED) if(!is_user_alive(idUser) || !is_user_connected(idUser)) return PLUGIN_CONTINUE; cssbShowMenuSelectTeam(idUser); return PLUGIN_HANDLED; }
Сообщение отредактировал Zep - Воскресенье, 03.02.2013, 21:33