Aller au contenu
News ticker
  • Bienvenue sur le nouveau forum VeryGames
  • Welcome to the new VeryGames forum
  • VeryNews

    Aide sur script chef des gardiens


    fredist

    Messages recommandés

    Bonjour,

     

    Pour mon serveur jail, je veux installer le plugins pour devenir chef des gardiens, j'ai donc trouver deux plugins intéressant, mais les deux se complète, et je veux donc les assemblés afin qu'il ne fassent plus qu'un.

     

    Le premier permet d'afficher au début du round un menu avec la question "Voulez-vous devenir le chef des gardiens ?" et les réponse "1. Oui, 2. Non", s'il y a plusieurs gardiens qui veulent être chef alors le plugins fait un random sur les candidats au poste de chef de gardiens.

    Voici le lien de ce plugin (il se trouve 2 commentaires en dessous du post):

    https://forums.alliedmods.net/showthread.php?t=179724

     

    Le deuxième permet d'avoir les commandes pour devenir chef ou démissionner, très pratique quand le premier chef des gardiens est mort pour qu'un autre gardien prenne le relais, et aussi pour démissionné, s'il na pas envie d'y être. Quand le chef parle dans le chat, à côté il y a marquer chef (pratique pour le différencier des autres gardiens.

    Voici le lien de ce plugin:

    https://forums.alliedmods.net/showthread.php?p=1476638

     

    Ce que je n'arrive pas à faire, c'est quand la sélection de vote au début du round, ce là ne prend pas effet avec les commandes, donc un gardien qui fait !c pourra devenir gardien (on se retrouve donc avec 2 gardiens), de plus quand le chef à était sélectionné (après qu'il est appuyait sur 1 par erreur", s'il tape !pc, la commande n'a aucun effet, de plus s'il parle dans le chat le [Chef] à côter n'apparait pas. En revanche si on effectue tout avec les commandes elles communiquent entre elle comme dans l'original.

     

    Je vous donne donc ci-dessous le mélange des deux codes afin de pouvoir m'aider à résoudre se problème.

     

    #include <sourcemod>#include <sdktools>
    #include <cstrike>
    
    
    #define PLUGIN_VERSION   "3.0.1"
    
    
    new Warden = -1;
    new Handle:g_cVar_mnotes = INVALID_HANDLE;
    new Handle:g_fward_onBecome = INVALID_HANDLE;
    new Handle:g_fward_onRemove = INVALID_HANDLE;
    new bool:g_bWantsCaptain[MAXPLAYERS+1] = {false, ...};
    new bool:g_bSomebodyChose = false;
    
    
    public Plugin:myinfo = {
       name = "Jailbreak Warden",
       author = "ecca",
       description = "Jailbreak Warden script",
       version = PLUGIN_VERSION,
       url = "ffac.eu"
    };
    
    
    public OnPluginStart() 
    {
       // Initialize our phrases
       LoadTranslations("warden.phrases");
    
       // Register our public commands
       RegConsoleCmd("sm_w", BecomeWarden);
       RegConsoleCmd("sm_warden", BecomeWarden);
       RegConsoleCmd("sm_uw", ExitWarden);
       RegConsoleCmd("sm_unwarden", ExitWarden);
       RegConsoleCmd("sm_c", BecomeWarden);
       RegConsoleCmd("sm_commander", BecomeWarden);
       RegConsoleCmd("sm_pc", ExitWarden);
       RegConsoleCmd("sm_uncommander", ExitWarden);
    
       // Register our admin commands
       RegAdminCmd("sm_rw", RemoveWarden, ADMFLAG_GENERIC);
       RegAdminCmd("sm_rc", RemoveWarden, ADMFLAG_GENERIC);
    
       // Hooking the events
       HookEvent("round_start", roundStart); // For the round start
       HookEvent("player_death", playerDeath); // To check when our warden dies :)
       HookEvent("round_start",Event_RoundStart);
    
       // For our warden to look some extra cool
       AddCommandListener(HookPlayerChat, "say");
    
       // May not touch this line
       CreateConVar("sm_warden_version", PLUGIN_VERSION,  "The version of the SourceMod plugin JailBreak Warden, by ecca", FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_DONTRECORD);
       g_cVar_mnotes = CreateConVar("sm_warden_better_notifications", "0", "0 - disabled, 1 - Will use hint and center text", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    
       g_fward_onBecome = CreateGlobalForward("warden_OnWardenCreated", ET_Ignore, Param_Cell);
       g_fward_onRemove = CreateGlobalForward("warden_OnWardenRemoved", ET_Ignore, Param_Cell);
    }
    
    
    public Event_RoundStart(Handle:event,const String:name[],bool:dontBroadcast)
    {
       g_bSomebodyChose = false;
       if(!GetConVarBool(g_fward_onBecome))
           return;
       new Handle:menu = INVALID_HANDLE;
       for(new i=1;i<MaxClients;i++)
       {
           if(ValidPlayer(i)&&GetClientTeam(i)==CS_TEAM_CT)
           {
               menu = CreateMenu(MenuHandler_CaptainChoice);
               SetMenuTitle(menu, "%T", "Menu_Title", i);
               new String:text[64];
               Format(text, sizeof(text), "%T", "Yes", i);    
               AddMenuItem(menu, "yes", text);
               Format(text, sizeof(text), "%T", "No", i);    
               AddMenuItem(menu, "nothing", text);
               SetMenuExitButton(menu, false);
               DisplayMenu(menu,i,15);
           }
       }
       CreateTimer(15.0,CheckCaptain);
       return;
    }
    
    
    public Action:CheckCaptain(Handle:timer,any:data)
    {
       if(!g_bSomebodyChose)
           return Plugin_Handled;
       new bool:chosen = false;
       new random;
       do {
           random = GetRandomInt(1,MaxClients);
           if(ValidPlayer(random)&&g_bWantsCaptain[random])
           {
               PrintToChatAll("[Faction] %t","Captain_Chosen",random);
               chosen = true;
           }
       }
       while(!chosen);
       return Plugin_Continue;
    }
    
    
    public MenuHandler_CaptainChoice(Handle:menu, MenuAction:action, client, param2)
    {
       if (action == MenuAction_End)
       {
           CloseHandle(menu);
       } else if(action == MenuAction_Select)
       {
           decl String:choice[16];
           GetMenuItem(menu,param2,choice,sizeof(choice));
           if(strcmp(choice,"yes")==0)
           {
               g_bWantsCaptain[client]=true;
               g_bSomebodyChose = true;
           }
       }
    }
    
    
    stock bool:ValidPlayer(i,bool:check_alive=false)
    {
       if(i>0 && i<=MaxClients && IsClientConnected(i) && IsClientInGame(i))
       {
           if(check_alive && !IsPlayerAlive(i))
           {
               return false;
           }
           return true;
       }
       return false;
    }
    
    
    public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
    {
       CreateNative("warden_exist", Native_ExistWarden);
       CreateNative("warden_iswarden", Native_IsWarden);
       CreateNative("warden_set", Native_SetWarden);
       CreateNative("warden_remove", Native_RemoveWarden);
    
    
       RegPluginLibrary("warden");
    
       return APLRes_Success;
    }
    
    
    public Action:BecomeWarden(client, args) 
    {
       if (Warden == -1) // There is no warden , so lets proceed
       {
           if (GetClientTeam(client) == 3) // The requested player is on the Counter-Terrorist side
           {
               if (IsPlayerAlive(client)) // A dead warden would be worthless >_<
               {
                   SetTheWarden(client);
               }
               else // Grr he is not alive -.-
               {
                   PrintToChat(client, "[Faction] %t", "warden_playerdead");
               }
           }
           else // Would be wierd if an terrorist would run the prison wouldn't it :p
           {
               PrintToChat(client, "[Faction] %t", "warden_ctsonly");
           }
       }
       else // The warden already exist so there is no point setting a new one
       {
           PrintToChat(client, "[Faction] %t", "warden_exist", Warden);
       }
    }
    
    
    public Action:ExitWarden(client, args) 
    {
       if(client == Warden) // The client is actually the current warden so lets proceed
       {
           PrintToChatAll("[Faction] %t", "warden_retire", client);
           if(GetConVarBool(g_cVar_mnotes))
           {
               PrintCenterTextAll("[Faction] %t", "warden_retire", client);
               PrintHintTextToAll("[Faction] %t", "warden_retire", client);
           }
           Warden = -1; // Open for a new warden
           SetEntityRenderColor(client, 255, 255, 255, 255); // Lets remove the awesome color
       }
       else // Fake dude!
       {
           PrintToChat(client, "[Faction] %t", "warden_notwarden");
       }
    }
    
    
    public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast) 
    {
       Warden = -1; // Lets remove the current warden if he exist
    }
    
    
    public Action:playerDeath(Handle:event, const String:name[], bool:dontBroadcast) 
    {
       new client = GetClientOfUserId(GetEventInt(event, "userid")); // Get the dead clients id
    
       if(client == Warden) // Aww damn , he is the warden
       {
           PrintToChatAll("[Faction] %t", "warden_dead", client);
           if(GetConVarBool(g_cVar_mnotes))
           {
               PrintCenterTextAll("[Faction] %t", "warden_dead", client);
               PrintHintTextToAll("[Faction] %t", "warden_dead", client);
           }
           SetEntityRenderColor(client, 255, 255, 255, 255); // Lets give him the standard color back
           Warden = -1; // Lets open for a new warden
       }
    }
    
    
    public OnClientDisconnect(client)
    {
       if(client == Warden) // The warden disconnected, action!
       {
           PrintToChatAll("[Faction] %t", "warden_disconnected");
           if(GetConVarBool(g_cVar_mnotes))
           {
               PrintCenterTextAll("[Faction] %t", "warden_disconnected", client);
               PrintHintTextToAll("[Faction] %t", "warden_disconnected", client);
           }
           Warden = -1; // Lets open for a new warden
       }
    }
    
    
    public Action:RemoveWarden(client, args)
    {
       if(Warden != -1) // Is there an warden at the moment ?
       {
           RemoveTheWarden(client);
       }
       else
       {
           PrintToChatAll("[Faction] %t", "warden_noexist");
       }
    
    
       return Plugin_Handled; // Prevent sourcemod from typing "unknown command" in console
    }
    
    
    public Action:HookPlayerChat(client, const String:command[], args)
    {
       if(Warden == client && client != 0) // Check so the player typing is warden and also checking so the client isn't console!
       {
           new String:szText[256];
           GetCmdArg(1, szText, sizeof(szText));
    
           if(szText[0] == '/' || szText[0] == '@' || IsChatTrigger()) // Prevent unwanted text to be displayed.
           {
               return Plugin_Handled;
           }
    
           if(IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 3) // Typing warden is alive and his team is Counter-Terrorist
           {
               PrintToChatAll("[Chef] %N : %s", client, szText);
               return Plugin_Handled;
           }
       }
    
       return Plugin_Continue;
    }
    
    
    public SetTheWarden(client)
    {
       PrintToChatAll("[Faction] %t", "warden_new", client);
    
       if(GetConVarBool(g_cVar_mnotes))
       {
           PrintCenterTextAll("[Faction] %t", "warden_new", client);
           PrintHintTextToAll("[Faction] %t", "warden_new", client);
       }
       Warden = client;
       SetEntityRenderColor(client, 0, 0, 255, 255);
       SetClientListeningFlags(client, VOICE_NORMAL);
    
       Forward_OnWardenCreation(client);
    }
    
    
    public RemoveTheWarden(client)
    {
       PrintToChatAll("[Faction] %t", "warden_removed", client, Warden);
       if(GetConVarBool(g_cVar_mnotes))
       {
           PrintCenterTextAll("[Faction] %t", "warden_removed", client);
           PrintHintTextToAll("[Faction] %t", "warden_removed", client);
       }
       SetEntityRenderColor(Warden, 255, 255, 255, 255);
       Warden = -1;
    
       Forward_OnWardenRemoved(client);
    }
    
    
    public Native_ExistWarden(Handle:plugin, numParams)
    {
       if(Warden != -1)
           return true;
    
       return false;
    }
    
    
    public Native_IsWarden(Handle:plugin, numParams)
    {
       new client = GetNativeCell(1);
    
       if(!IsClientInGame(client) && !IsClientConnected(client))
           ThrowNativeError(SP_ERROR_INDEX, "Client index %i is invalid", client);
    
       if(client == Warden)
           return true;
    
       return false;
    }
    
    
    public Native_SetWarden(Handle:plugin, numParams)
    {
       new client = GetNativeCell(1);
    
       if (!IsClientInGame(client) && !IsClientConnected(client))
           ThrowNativeError(SP_ERROR_INDEX, "Client index %i is invalid", client);
    
       if(Warden == -1)
       {
           SetTheWarden(client);
       }
    }
    
    
    public Native_RemoveWarden(Handle:plugin, numParams)
    {
       new client = GetNativeCell(1);
    
       if (!IsClientInGame(client) && !IsClientConnected(client))
           ThrowNativeError(SP_ERROR_INDEX, "Client index %i is invalid", client);
    
       if(client == Warden)
       {
           RemoveTheWarden(client);
       }
    }
    
    
    public Forward_OnWardenCreation(client)
    {
       Call_StartForward(g_fward_onBecome);
       Call_PushCell(client);
       Call_Finish();
    }
    
    
    public Forward_OnWardenRemoved(client)
    {
       Call_StartForward(g_fward_onRemove);
       Call_PushCell(client);
       Call_Finish();
    
    }

    PS: Je suis novice en programmation, soyez indulgent :-D

    Lien vers le commentaire
    Partager sur d’autres sites

    J'avais fais ça avant:

     

    #include <sourcemod>
    #include <morecolors>
    
    new bool:g_bWant[MAXPLAYERS+1] = false;
    new g_Captain;
    
    public OnPluginStart()
    {
       HookEvent("round_start", Event_RoundStart);
       HookEvent("player_death", Event_PlayerDeath);
    
       RegConsoleCmd("sm_chef", Command_Chef);
       RegConsoleCmd("sm_chefct", Command_Chef);
    
       AddCommandListener(HookPlayerChat, "say");
    }
    
    public OnClientDisconnect(client)
    {
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT s'est déconnecter !");
       }
    }
    
    public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
    {
       g_Captain = -1;
    
       for(new i = 1; i <= MaxClients; i++)
           if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
               MenuCaptain(i);
    }
    
    public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT est mort !");
       }
    }
    
    public MenuCaptain(client)
    {
       g_bWant[client] = false;
    
       new Handle:hMenu = CreateMenu(MenuHandler_Captain);
       SetMenuTitle(hMenu, "Voulez-vous être le capitaine");
       AddMenuItem(hMenu, "oui", "Oui");
       AddMenuItem(hMenu, "", "Non");
    
       SetMenuExitButton(hMenu, false);
       DisplayMenu(hMenu, client, 15);
    
       CreateTimer(15.0, Timer_ChooseCaptain);
    }
    
    public MenuHandler_Captain(Handle:hMenu, MenuAction:action, client, param)
    {
       if(action == MenuAction_Select)
       {
           decl String:sParam[64];
           GetMenuItem(hMenu, param, sParam, sizeof(sParam));
    
           if(StrEqual(sParam, "oui"))
               g_bWant[client] = true;
       }
       if(action == MenuAction_End)
           CloseHandle(hMenu);
    }
    
    public Action:Timer_ChooseCaptain(Handle:timer)
    {
       g_Captain = GetRandomClient();
    
       if(IsClientValid(g_Captain))
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
    }
    
    public Action:HookPlayerChat(client, const String:command[], args)
    {
       if(client == g_Captain)
       {
           new String:sText[256];
           GetCmdArg(1, sText, sizeof(sText));
    
           if(sText[0] == '/' || sText[0] == '@' || IsChatTrigger())
               return Plugin_Handled;
    
           if(IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 3)
           {
               PrintToChatAll("[Chef] %N : %s", client, sText);
               return Plugin_Handled;
           }
       }
    
       return Plugin_Continue;
    }
    
    public Action:Command_Chef(client, args)
    {
       if(!IsClientValid(client) || GetClientTeam(client) != 3)
           return Plugin_Handled;
    
       if(IsClientValid(g_Captain))
       {
           if(client == g_Captain)
           {
               CPrintToChatAll("{green}[JAIL] %N démissionne", client);
               g_Captain = -1;
           }
           else
               CPrintToChatAll("{green}[JAIL] Votre capitaine est %N", g_Captain);
       }
       else if(!IsClientValid(g_Captain))
       {
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
           g_Captain = client;
       }
    
       return Plugin_Handled;
    }
    
    public GetRandomClient()
    {
       new client[MaxClients+1];
       new count;
    
       for (new i = 1; i <= MaxClients; i++)
           if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3 && g_bWant[i]) 
               client[count++] = i;
    
       return (count == 0) ? -1 : client[GetRandomInt(0, count-1)];
    }
    
    stock bool:IsClientValid(client)
    {
       if(client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
           return true;
    
       return false;
    }
    

     

    En gros ça fais aussi une demission de capitaine avec la commande !chef et !chefct.

    J'ai juste rajouté le chat avec comme dans l'autre plugin.

     

    J'ai aucun souvenir de l'avoir utiliser donc donne du retour.

    Tu n'as plus besoin de ton plugin à toi ^^

     

    J'ai pas réellement le temps de te re-faire un truc en entier, si il ne fonctionne pas je te ferrais un truc plus opti Mercredi ^^ (Wai c'est dans longtemps).

     

    Kriax.

    Lien vers le commentaire
    Partager sur d’autres sites

    yop

    csgo ou css rien ne change (sauf les couleurs normalement), la tu le vois, syntax 1.6 mais utilisable sous 1.7

     

    je t'en ferrais un propre quand j'aurais le temps, j'hésitais sur si il fonctionnais ou pas mdr', je vais essayer de trouve un trou pour t'en faire un ou si quelqu'un se porte volontaire mdr'

     

    edit : t'es sur qu'il vas pas je viens de le lire et normalement c'est bon o.O il est load sur ton serv ?

    Lien vers le commentaire
    Partager sur d’autres sites

    Je t'avais oublier excuse moi !!

     

    #include <sourcemod>
    #include <csgocolors>
    
    new bool:g_bWant[MAXPLAYERS+1] = false;
    new g_Captain;
    
    public OnPluginStart()
    {
       HookEvent("round_start", Event_RoundStart);
       HookEvent("player_death", Event_PlayerDeath);
    
       RegConsoleCmd("sm_chef", Command_Chef);
       RegConsoleCmd("sm_chefct", Command_Chef);
    
       AddCommandListener(HookPlayerChat, "say");
    }
    
    public OnClientDisconnect(client)
    {
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT s'est déconnecter !");
       }
    }
    
    public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
    {
       g_Captain = -1;
    
       for(new i = 1; i <= MaxClients; i++)
           if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
               MenuCaptain(i);
    }
    
    public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT est mort !");
       }
    }
    
    public MenuCaptain(client)
    {
       g_bWant[client] = false;
    
       new Handle:hMenu = CreateMenu(MenuHandler_Captain);
       SetMenuTitle(hMenu, "Voulez-vous être le capitaine");
       AddMenuItem(hMenu, "oui", "Oui");
       AddMenuItem(hMenu, "", "Non");
    
       SetMenuExitButton(hMenu, false);
       DisplayMenu(hMenu, client, 15);
    
       CreateTimer(15.0, Timer_ChooseCaptain);
    }
    
    public MenuHandler_Captain(Handle:hMenu, MenuAction:action, client, param)
    {
       if(action == MenuAction_Select)
       {
           decl String:sParam[64];
           GetMenuItem(hMenu, param, sParam, sizeof(sParam));
    
           if(StrEqual(sParam, "oui"))
               g_bWant[client] = true;
       }
       if(action == MenuAction_End)
           CloseHandle(hMenu);
    }
    
    public Action:Timer_ChooseCaptain(Handle:timer)
    {
       g_Captain = GetRandomClient();
    
       if(IsClientValid(g_Captain))
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
    }
    
    public Action:HookPlayerChat(client, const String:command[], args)
    {
       if(client == g_Captain)
       {
           new String:sText[256];
           GetCmdArg(1, sText, sizeof(sText));
    
           if(sText[0] == '/' || sText[0] == '@' || IsChatTrigger())
               return Plugin_Handled;
    
           if(IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 3)
           {
               PrintToChatAll("[Chef] %N : %s", client, sText);
               return Plugin_Handled;
           }
       }
    
       return Plugin_Continue;
    }
    
    public Action:Command_Chef(client, args)
    {
       if(!IsClientValid(client) || GetClientTeam(client) != 3)
           return Plugin_Handled;
    
       if(IsClientValid(g_Captain))
       {
           if(client == g_Captain)
           {
               CPrintToChatAll("{green}[JAIL] %N démissionne", client);
               g_Captain = -1;
           }
           else
               CPrintToChatAll("{green}[JAIL] Votre capitaine est %N", g_Captain);
       }
       else if(!IsClientValid(g_Captain))
       {
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
           g_Captain = client;
       }
    
       return Plugin_Handled;
    }
    
    public GetRandomClient()
    {
       new client[MaxClients+1];
       new count;
    
       for (new i = 1; i <= MaxClients; i++)
           if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3 && g_bWant[i]) 
               client[count++] = i;
    
       return (count == 0) ? -1 : client[GetRandomInt(0, count-1)];
    }
    
    stock bool:IsClientValid(client)
    {
       if(client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
           return true;
    
       return false;
    }  
    

     

    Tu vas devoir prendre ça pour compiler :

    https://github.com/Maxximou5/csgo-playertrails/blob/master/scripting/include/csgocolors.inc

     

    Juste le csgocolors.inc

    Lien vers le commentaire
    Partager sur d’autres sites

    Tiens normalement c'est bon.

    À défaut d'utiliser les bons trucs mdr'

     

    #include <sourcemod>
    #include <csgocolors>
    #include <scp>
    
    new bool:g_bWant[MAXPLAYERS+1] = false;
    new g_Captain;
    new g_bChoose;
    
    public OnPluginStart()
    {
       HookEvent("round_start", Event_RoundStart);
       HookEvent("player_death", Event_PlayerDeath);
    
       RegConsoleCmd("sm_chef", Command_Chef);
       RegConsoleCmd("sm_chefct", Command_Chef);
    }
    
    public OnClientDisconnect(client)
    {
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT s'est déconnecter !");
       }
    }
    
    public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
    {
       g_Captain = -1;
    
       for(new i = 1; i <= MaxClients; i++)
           if(IsClientValid(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
               MenuCaptain(i);
    
       CreateTimer(15.0, Timer_ChooseCaptain);
       g_bChoose = false;
    }
    
    public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT est mort !");
       }
    }
    
    public MenuCaptain(client)
    {
       g_bWant[client] = false;
    
       new Handle:hMenu = CreateMenu(MenuHandler_Captain);
       SetMenuTitle(hMenu, "Voulez-vous être le capitaine");
       AddMenuItem(hMenu, "oui", "Oui");
       AddMenuItem(hMenu, "", "Non");
    
       SetMenuExitButton(hMenu, false);
       DisplayMenu(hMenu, client, 14);
    }
    
    public MenuHandler_Captain(Handle:hMenu, MenuAction:action, client, param)
    {
       if(action == MenuAction_Select)
       {
           decl String:sParam[64];
           GetMenuItem(hMenu, param, sParam, sizeof(sParam));
    
           if(StrEqual(sParam, "oui"))
               g_bWant[client] = true;
       }
       if(action == MenuAction_End)
           CloseHandle(hMenu);
    }
    
    public Action:Timer_ChooseCaptain(Handle:timer)
    {
       g_Captain = GetRandomClient();
    
       if(IsClientValid(g_Captain) && IsPlayerAlive(g_Captain))
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
    
       g_bChoose = true;
    }
    
    public Action:OnChatMessage(&author, Handle:recipients, String:name[], String:message[]) 
    {
       if(author == g_Captain)
           Format(name, MAXLENGTH_NAME, "\x01[CHEF] \x03%s", name);
    
       return Plugin_Changed;
    }
    
    public Action:Command_Chef(client, args)
    {
       if(!IsClientValid(client) || !IsPlayerAlive(client) || GetClientTeam(client) < 3 || !g_bChoose)
           return Plugin_Handled;
    
       if(IsClientValid(g_Captain) && IsPlayerAlive(g_Captain))
       {
           if(client == g_Captain)
           {
               CPrintToChatAll("{green}[JAIL] %N démissionne", client);
               g_Captain = -1;
           }
           else
               CPrintToChat(client, "{green}[JAIL] Votre capitaine est %N", g_Captain);
       }
       else
       {
           g_Captain = client;
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
       }
    
       return Plugin_Handled;
    }
    
    public GetRandomClient()
    {
       new client[MaxClients+1];
       new count;
    
       for (new i = 1; i <= MaxClients; i++)
           if (IsClientValid(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3 && g_bWant[i]) 
               client[count++] = i;
    
       return (count == 0) ? -1 : client[GetRandomInt(0, count-1)];
    }
    
    stock bool:IsClientValid(client)
    {
       if(client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
           return true;
    
       return false;
    }  
    

     

    Tu vas avoir besoin de ça sur ton serveur : https://forums.alliedmods.net/showthread.php?p=1820365

     

    Derien :p

    Lien vers le commentaire
    Partager sur d’autres sites

    Ce là fonctionne parfaitement, merci à toi pour cet excellent travail.

     

    J'aurais deux petite requêtes à te proposer si tu as le temps et si ça ne te dérange pas bien évidement.

     

    - Le chef peut-il devenir bleue afin de le différencier des autres gardiens ? (déjà vue sur d'autres serveurs)

    - Peut tu mettre une deuxième commande pour démissionner, afin de différencier la commande pour devenir chef et celle de démission ?

    Lien vers le commentaire
    Partager sur d’autres sites

    Test ça :

     

    #include <sourcemod>
    #include <csgocolors>
    #include <scp>
    
    new bool:g_bWant[MAXPLAYERS+1] = false;
    new g_Captain;
    new g_bChoose;
    
    public OnPluginStart()
    {
       HookEvent("round_start", Event_RoundStart);
       HookEvent("player_death", Event_PlayerDeath);
    
       RegConsoleCmd("sm_chef", Command_Chef);
       RegConsoleCmd("sm_chefct", Command_Chef);
       RegConsoleCmd("sm_demission", Command_Demission);
       RegConsoleCmd("sm_dem", Command_Demission);
    }
    
    public OnClientDisconnect(client)
    {
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT s'est déconnecter !");
       }
    }
    
    public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
    {
       g_Captain = -1;
    
       for(new i = 1; i <= MaxClients; i++)
           if(IsClientValid(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
               MenuCaptain(i);
    
       CreateTimer(15.0, Timer_ChooseCaptain);
       g_bChoose = false;
    }
    
    public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT est mort !");
       }
    }
    
    public MenuCaptain(client)
    {
       g_bWant[client] = false;
    
       new Handle:hMenu = CreateMenu(MenuHandler_Captain);
       SetMenuTitle(hMenu, "Voulez-vous être le capitaine");
       AddMenuItem(hMenu, "oui", "Oui");
       AddMenuItem(hMenu, "", "Non");
    
       SetMenuExitButton(hMenu, false);
       DisplayMenu(hMenu, client, 14);
    }
    
    public MenuHandler_Captain(Handle:hMenu, MenuAction:action, client, param)
    {
       if(action == MenuAction_Select)
       {
           decl String:sParam[64];
           GetMenuItem(hMenu, param, sParam, sizeof(sParam));
    
           if(StrEqual(sParam, "oui"))
               g_bWant[client] = true;
       }
       if(action == MenuAction_End)
           CloseHandle(hMenu);
    }
    
    public Action:Timer_ChooseCaptain(Handle:timer)
    {
       g_Captain = GetRandomClient();
    
       if(IsClientValid(g_Captain) && IsPlayerAlive(g_Captain))
       {
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
           SetEntityRenderColor(g_Captain, 0, 0, 255, 255);
       }
    
       g_bChoose = true;
    }
    
    public Action:OnChatMessage(&author, Handle:recipients, String:name[], String:message[]) 
    {
       if(author == g_Captain)
           Format(name, MAXLENGTH_NAME, "\x01[CHEF] \x03%s", name);
    
       return Plugin_Changed;
    }
    
    public Action:Command_Chef(client, args)
    {
       if(!IsClientValid(client) || !IsPlayerAlive(client) || GetClientTeam(client) < 3 || !g_bChoose)
           return Plugin_Handled;
    
       if(IsClientValid(g_Captain) && IsPlayerAlive(g_Captain))
           CPrintToChat(client, "{green}[JAIL] Votre capitaine est %N", g_Captain);
       else
       {
           g_Captain = client;
    
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
           SetEntityRenderColor(g_Captain, 0, 0, 255, 255);
       }
    
       return Plugin_Handled;
    }
    
    public Action:Command_Demission(client, args)
    {
       if(!IsClientValid(client) || !IsPlayerAlive(client) || GetClientTeam(client) < 3 || !g_bChoose || g_Captain != client)
           return Plugin_Handled;
    
       if(client == g_Captain)
       {
           CPrintToChatAll("{green}[JAIL] %N démissionne", g_Captain);
           SetEntityRenderColor(g_Captain, 255, 255, 255, 255);
    
           g_Captain = -1;
       }
    
       return Plugin_Handled;
    }
    
    public GetRandomClient()
    {
       new client[MaxClients+1];
       new count;
    
       for (new i = 1; i <= MaxClients; i++)
           if (IsClientValid(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3 && g_bWant[i]) 
               client[count++] = i;
    
       return (count == 0) ? -1 : client[GetRandomInt(0, count-1)];
    }
    
    stock bool:IsClientValid(client)
    {
       if(client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
           return true;
    
       return false;
    }  
    

    Lien vers le commentaire
    Partager sur d’autres sites

    Merci énormément pour ton excellent travail, une petite dernière chose si tu le veut bien.

     

    Peut-tu mettre dans plus que dans le chat en message d'avertissement, afin qu'il soit mieux visible (pour le nouveau chef et démission du chef) ? (Tout en le gardant dans le chat bien évidement).

    Lien vers le commentaire
    Partager sur d’autres sites

    Afficher dans le chat, le hint message et le center text :

     

    #include <sourcemod>
    #include <csgocolors>
    #include <scp>
    
    new bool:g_bWant[MAXPLAYERS+1] = false;
    new g_Captain;
    new g_bChoose;
    
    public OnPluginStart()
    {
       HookEvent("round_start", Event_RoundStart);
       HookEvent("player_death", Event_PlayerDeath);
    
       RegConsoleCmd("sm_chef", Command_Chef);
       RegConsoleCmd("sm_chefct", Command_Chef);
       RegConsoleCmd("sm_demission", Command_Demission);
       RegConsoleCmd("sm_dem", Command_Demission);
    }
    
    public OnClientDisconnect(client)
    {
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT s'est déconnecter !");
           PrintCenterTextAll("Le chef des CT s'est déconnecter !");
           PrintHintTextToAll("Le chef des CT s'est déconnecter !");
       }
    }
    
    public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
    {
       g_Captain = -1;
    
       for(new i = 1; i <= MaxClients; i++)
           if(IsClientValid(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3)
               MenuCaptain(i);
    
       CreateTimer(15.0, Timer_ChooseCaptain);
       g_bChoose = false;
    }
    
    public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       new client = GetClientOfUserId(GetEventInt(event, "userid"));
    
       if(client == g_Captain)
       {
           g_Captain = -1;
           CPrintToChatAll("{green}[JAIL] Le chef des CT est mort !");
           PrintCenterTextAll("Le chef des CT est mort !");
           PrintHintTextToAll("Le chef des CT est mort !");
       }
    }
    
    public MenuCaptain(client)
    {
       g_bWant[client] = false;
    
       new Handle:hMenu = CreateMenu(MenuHandler_Captain);
       SetMenuTitle(hMenu, "Voulez-vous être le capitaine");
       AddMenuItem(hMenu, "oui", "Oui");
       AddMenuItem(hMenu, "", "Non");
    
       SetMenuExitButton(hMenu, false);
       DisplayMenu(hMenu, client, 14);
    }
    
    public MenuHandler_Captain(Handle:hMenu, MenuAction:action, client, param)
    {
       if(action == MenuAction_Select)
       {
           decl String:sParam[64];
           GetMenuItem(hMenu, param, sParam, sizeof(sParam));
    
           if(StrEqual(sParam, "oui"))
               g_bWant[client] = true;
       }
       if(action == MenuAction_End)
           CloseHandle(hMenu);
    }
    
    public Action:Timer_ChooseCaptain(Handle:timer)
    {
       g_Captain = GetRandomClient();
    
       if(IsClientValid(g_Captain) && IsPlayerAlive(g_Captain))
       {
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
           PrintCenterTextAll("Le chef des CT est : %N", g_Captain);
           PrintHintTextToAll("Le chef des CT est : %N", g_Captain);
    
           SetEntityRenderColor(g_Captain, 0, 0, 255, 255);
       }
    
       g_bChoose = true;
    }
    
    public Action:OnChatMessage(&author, Handle:recipients, String:name[], String:message[]) 
    {
       if(author == g_Captain)
           Format(name, MAXLENGTH_NAME, "\x01[CHEF] \x03%s", name);
    
       return Plugin_Changed;
    }
    
    public Action:Command_Chef(client, args)
    {
       if(!IsClientValid(client) || !IsPlayerAlive(client) || GetClientTeam(client) < 3 || !g_bChoose)
           return Plugin_Handled;
    
       if(IsClientValid(g_Captain) && IsPlayerAlive(g_Captain))
           CPrintToChat(client, "{green}[JAIL] Votre capitaine est %N", g_Captain);
       else
       {
           g_Captain = client;
    
           CPrintToChatAll("{green}[JAIL] Le chef des CT est : {lightgreen}%N", g_Captain);
           PrintCenterTextAll("Le chef des CT est : %N", g_Captain);
           PrintHintTextToAll("Le chef des CT est : %N", g_Captain);
    
           SetEntityRenderColor(g_Captain, 0, 0, 255, 255);
       }
    
       return Plugin_Handled;
    }
    
    public Action:Command_Demission(client, args)
    {
       if(!IsClientValid(client) || !IsPlayerAlive(client) || GetClientTeam(client) < 3 || !g_bChoose || g_Captain != client)
           return Plugin_Handled;
    
       if(client == g_Captain)
       {
           CPrintToChatAll("{green}[JAIL] %N démissionne", g_Captain);
           PrintCenterTextAll("%N démissionne", g_Captain);
           PrintHintTextToAll("%N démissionne", g_Captain);
    
           SetEntityRenderColor(g_Captain, 255, 255, 255, 255);
    
           g_Captain = -1;
       }
    
       return Plugin_Handled;
    }
    
    public GetRandomClient()
    {
       new client[MaxClients+1];
       new count;
    
       for (new i = 1; i <= MaxClients; i++)
           if (IsClientValid(i) && IsPlayerAlive(i) && GetClientTeam(i) == 3 && g_bWant[i]) 
               client[count++] = i;
    
       return (count == 0) ? -1 : client[GetRandomInt(0, count-1)];
    }
    
    stock bool:IsClientValid(client)
    {
       if(client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
           return true;
    
       return false;
    }  
    

     

    Désolé pour le retard mais je taff sur une api rp ^^'

    N'hésite pas à re-poster en cas de problème ou d'envoyer ceux qui ont besoin d'aide :)

     

    Kriax.

    Lien vers le commentaire
    Partager sur d’autres sites

    Ton plugins est parfait, une requête me viens à l'idée, par contre je ne sais pas si ce là est possible.

     

    Très souvent en tant que chef on demande aux prisonniers de venir sur nos impacts de balles, mais d'autres CT tire un peu partout et les prisonniers ne savent plus trop où aller, est-il donc possible d'avoir des balles (styles paintball) pour le chef, afin de différencier ses impacts des autres gardiens ?

     

    Encore une fois mille merci, pour ce plugins, et si tu es sur d'autres projets, prend ton temps, c'est déjà très gentil ce que tu fait.

    Lien vers le commentaire
    Partager sur d’autres sites

    Rejoindre la conversation

    Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.

    Invité
    Répondre à ce sujet…

    ×   Collé en tant que texte enrichi.   Coller en tant que texte brut à la place

      Seulement 75 émoticônes maximum sont autorisées.

    ×   Votre lien a été automatiquement intégré.   Afficher plutôt comme un lien

    ×   Votre contenu précédent a été rétabli.   Vider l’éditeur

    ×   Vous ne pouvez pas directement coller des images. Envoyez-les depuis votre ordinateur ou insérez-les depuis une URL.

    ×
    ×
    • Créer...