Gość Opublikowano Kwiecień 7, 2018 o 07:57 Udostępnij Opublikowano Kwiecień 7, 2018 o 07:57 Czy znajdzie się jakaś osoba, która pomogła by mi do owego kodu pomóc wstrzyknać zmiany aby plugin używał vguimenu z racji że owy kod czasami potrafi blokować funkcję kupna #include <sourcemod> #include <cstrike> #include <sdktools> #pragma newdecls required #pragma semicolon 1 ConVar cvTeamchangelimit; ConVar cvExcludespec; Handle hTeam; int iTeamchangecount[MAXPLAYERS+1]; public Plugin myinfo = { name = "Team Change Regulator", author = "", description = "Regulates team change.", version = "1.0", url = "https://forums.alliedmods.net/showthread.php?t=306013" }; public void OnPluginStart() { hTeam = CreateConVar("sm_join_team", "1", "Do not edit this"); cvTeamchangelimit = CreateConVar("sm_teamchange_limit", "1", "Sets how many times a player may switch between teams. Default = 1"); cvExcludespec = CreateConVar("sm_teamchange_excludespec", "1", "Should we exclude counting team changes to spectators? 0 = Disable"); AddCommandListener(cmdListener_Changeteam, "jointeam"); HookEvent("player_connect_full", vEvent_OnFullConnect, EventHookMode_Post); } public void vEvent_OnFullConnect(Event event, const char[] name, bool dontBroadcast) { int client = GetClientOfUserId(event.GetInt("userid")); if (client != 0 && IsClientInGame(client) && !IsFakeClient(client) && !bIsAdminRoot(client)) { CreateTimer(0.5, tAssignTeam, client); } } public void OnClientPutInServer(int client) { if (!IsFakeClient(client) && IsClientInGame(client)) { iTeamchangecount[client] = 0; } } public Action tAssignTeam(Handle timer, any client) { if (IsClientInGame(client)) { int iCvar = GetConVarInt(hTeam); switch (iCvar) { case 0: { return Plugin_Handled; } case 1: { int iRed; int iBlue; for (int i = 1; i <= MaxClients; i++) { if (!IsClientInGame(i)) { continue; } int iTeam = GetClientTeam(i); if (iTeam == CS_TEAM_T) { iRed++; } else if (iTeam == CS_TEAM_CT) { iBlue++; } } if (iRed > iBlue) { ChangeClientTeam(client, 3); } else if (iRed < iBlue || iRed == iBlue) { ChangeClientTeam(client, 2); } } case 2: { ChangeClientTeam(client, 2); } case 3: { ChangeClientTeam(client, 3); } } } return Plugin_Continue; } public Action cmdListener_Changeteam(int client, const char[] command, int args) { if (bIsAdminRoot(client)) { return Plugin_Continue; } if (iTeamchangecount[client] == cvTeamchangelimit.IntValue) { PrintToChat(client, "[TeamManager] Nie mozesz ponownie zmienic teamu!!!"); PrintCenterText(client, "<font color='#FF0000'><b>[TeamManager]</font> <font color='#FFFFFF'>Nie mozesz ponownie zmienic teamu!!!</font>"); return Plugin_Handled; } char arg1[3]; GetCmdArg(1, arg1, sizeof(arg1)); int target_team = StringToInt(arg1); int current_team = GetClientTeam(client); if (target_team == current_team) { return Plugin_Handled; } else if ((target_team > 1 && cvExcludespec.IntValue >= 1) || cvExcludespec.IntValue < 1) { iTeamchangecount[client]++; } return Plugin_Handled; } bool bIsAdminRoot(int client) { return (CheckCommandAccess(client, "team_change_admin", ADMFLAG_ROOT, false)); } Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się