LemoNSK 1 Opublikowano 15 Sierpnia 2018 Udostępnij Opublikowano 15 Sierpnia 2018 Hello, can anybody of you correct my code? If it tries to transfer both of us (best player on the server in certain team with the opposite random player in opposite team, it sometimes transfers both and sometimes doesn't. Please try correcting it and explaining how u corrected it. #include <amxmodx> #include <amxmisc> #include <cromchat> #include <cstrike> #include <fun> #define PLUGIN "Transfer Plugin" #define VERSION "1.0" #define AUTHOR "Reddington" new g_iEnemiesKilled[33]; new cvar_transferafter; new rounds; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_logevent("logevent_round_end", 2, "1=Round_End"); cvar_transferafter = register_cvar("r_transferafter", "5.0"); } public logevent_round_end() { rounds++; if(rounds > get_pcvar_num(cvar_transferafter)) { //Retrieve the IDs of best killers in the server. new ctID = GetTopKiller(2); new tID = GetTopKiller(1); //Retriev user frags new ctKills = get_user_frags(ctID); new tKills = get_user_frags(tID); //Retrieve user deaths. new ctDeaths = get_user_deaths(ctID); new tDeaths = get_user_deaths(tID); //Compare kill to deaths ratio. if((ctKills / ctDeaths) > (tKills / tDeaths)) { //CT is better //Get user's name. new name[255], name2[255] ,msg[255], iPnum, players[32], player1; get_user_name(ctID, name, sizeof(name)); if(is_user_alive(ctID)) { set_user_health(ctID, 0); } //Transfer the best player to opponent team. cs_set_user_team(ctID, CS_TEAM_T); get_players(players, iPnum, "ceh", "TERRORIST"); player1 = players[random(iPnum)]; //Get the name of the opposite random enemy. get_user_name(player1, name2, sizeof(name2)); if(is_user_alive(player1)) { set_user_health(player1, 0); } //Swap the random player from T to CT. cs_set_user_team(player1, CS_TEAM_CT); formatex(msg, sizeof(msg), "&x07[&x04LamdaProCS&x07] &x03Player &x04%s &x03has been replaced by player &x04%s", name, name2); for(new x = 1; x < 33; x++) { if(is_user_connected(x)) { CC_SendMessage(x, msg); } } ctKills = 0; ctDeaths = 0; tKills = 0; tDeaths = 0; rounds = 0; player1 = 0; } if((ctKills / ctDeaths) < (tKills / tDeaths)) //T is better { //Get user's name. new name[255], name2[255] ,msg[255], iPnum, players[32], player1; get_user_name(tID, name, sizeof(name)); if(is_user_alive(tID)) { set_user_health(tID, 0); } //Transfer the best player to opponent team. cs_set_user_team(tID, CS_TEAM_CT); get_players(players, iPnum, "ceh", "CT"); player1 = players[random(iPnum)]; //Get the name of the opposite random enemy. get_user_name(player1, name2, sizeof(name2)); if(is_user_alive(player1)) { set_user_health(player1, 0); } //Swap the random player from CT to T. cs_set_user_team(player1, CS_TEAM_T); formatex(msg, sizeof(msg), "&x07[&x04LamdaProCS&x07] &x03Player &x04%s &x03has been replaced by player &x04%s", name, name2); for(new x = 1; x < 33; x++) { if(is_user_connected(x)) { CC_SendMessage(x, msg); } } ctKills = 0; ctDeaths = 0; tKills = 0; tDeaths = 0; rounds = 0; player1 = 0; } if((ctKills / ctDeaths) == (tKills / tDeaths)) { } } } GetTopKiller(iTeam) { new iPlayers[32], iPlayersnum; get_players(iPlayers, iPlayersnum, "ceh", iTeam == 1 ? "TERRORIST" : "CT") SortCustom1D(iPlayers, iPlayersnum, "SortByKills") return iPlayers[0] } public SortByKills(elem1, elem2) { if ( g_iEnemiesKilled[elem1] > g_iEnemiesKilled[elem2] ) { return -1; } else { return 1; } return 0; } 1 Cytuj Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi
Dołącz do dyskusji
Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.