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

    Dernier CT


    fredist

    Messages recommandés

    Bonjour,

     

    J'ai trouver un bon plugin pour affiché un message quand il ne reste plus qu'un membre d'une team en vie.

    Ayant une serveur ba_jail, j'ai besoin que ce message ne s'affiche uniquement pour le dernier CT en vie et non pas pour le dernier terroriste en vie, je vous met ci-dessous le script que j'ai trouver, mais je n'arrive pas à le modifié pour qu'il ne prenne effet que sur les CT.

     

    #include <sourcemod>#include <sdktools>
    
    
    #pragma semicolon 1
    
    
    #define PLUGIN_VERSION "1.2.1"
    #define MAX_FILE_LEN 80
    
    
    // Plugin definitions
    public Plugin:myinfo = 
    {
       name = "LastMan",
       author = "dalto",
       description = "Last Man Sound",
       version = PLUGIN_VERSION,
       url = "http://forums.alliedmods.net"
    };
    
    
    new g_soundPreference[MAXPLAYERS + 1];
    new Handle:g_CvarChat = INVALID_HANDLE;
    new Handle:g_CvarAnnounce = INVALID_HANDLE;
    new Handle:g_CvarSoundName = INVALID_HANDLE;
    new Handle:g_CvarEnabled = INVALID_HANDLE;
    new String:g_soundName[MAX_FILE_LEN];
    
    
    public OnPluginStart()
    {
       // Before we do anything else lets make sure that the plugin is not disabled
       g_CvarEnabled = CreateConVar("sm_lastman_enable", "1", "Enables the LastMan plugin");
    
    
       // Create the rest of the g_Cvar's
       CreateConVar("sm_lastman_version", PLUGIN_VERSION, "Last Man Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
       g_CvarAnnounce = CreateConVar("sm_lastman_announce", "1", "Announcement preferences");
       g_CvarChat = CreateConVar("sm_lastman_chat", "1", "Chat preferences");
       g_CvarSoundName = CreateConVar("sm_lastman_sound", "lastman/oneandonly.wav", "The sound to play");
       HookConVarChange(g_CvarSoundName, OnSoundChanged);
    
       // Execute the config file
       AutoExecConfig(true, "lastman");
    
       HookEvent("player_death", EventPlayerDeath);
       RegConsoleCmd("lastman", PanelLastman);
    }
    
    
    public OnConfigsExecuted()
    {
       GetConVarString(g_CvarSoundName, g_soundName, MAX_FILE_LEN);
       decl String:buffer[MAX_FILE_LEN];
       PrecacheSound(g_soundName, true);
       Format(buffer, sizeof(buffer), "sound/%s", g_soundName);
       AddFileToDownloadsTable(buffer);
    }
    
    
    public OnSoundChanged(Handle:convar, const String:oldValue[], const String:newValue[])
    {
       decl String:buffer[MAX_FILE_LEN];
       strcopy(g_soundName, sizeof(g_soundName), newValue);
       PrecacheSound(g_soundName, true);
       Format(buffer, sizeof(buffer), "sound/%s", g_soundName);
       AddFileToDownloadsTable(buffer);
    }
    
    public Action:TimerAnnounce(Handle:timer, any:client)
    {
       if(client && IsClientInGame(client) && !IsFakeClient(client))
       {
           PrintToChat(client, "Say !lastman or /lastman to configure the last man standing sound");
       }
    }
    
    
    // When a new client is authorized we reset sound preferences
    // and let them know how to turn the sounds on and off
    public OnClientAuthorized(client, const String:auth[])
    {
       if(client && !IsFakeClient(client))
       {
           g_soundPreference[client] = 1;
           if(GetConVarBool(g_CvarAnnounce))
           {
               CreateTimer(30.0, TimerAnnounce, client);
           }
       }
    }
    
    
    // The death event
    public EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       if(!GetConVarBool(g_CvarEnabled))
       {
           return;
       }
    
       new victimId = GetEventInt(event, "userid");
    
    
       new victimClient = GetClientOfUserId(victimId);
    
    
       new killedTeam = GetClientTeam(victimClient);
    
    
       new playersConnected = GetMaxClients();
    
    
       // We check to see if there is only one person left.
       new lastManId = 0;
       for (new i = 1; i < playersConnected; i++)
       {
           if(IsClientInGame(i))
           {
               if(killedTeam==GetClientTeam(i) && IsPlayerAlive(i))
               {
                   if(lastManId)
                   {
                       lastManId = -1;
                   } else {
                       lastManId = i;
                   }
               }
           }
       }
    
       // If there is only person left than we play a sound and print a message
       if(lastManId > 0)
       {
           new String:clientname[64];
           GetClientName(lastManId, clientname, sizeof(clientname));
           if(GetConVarBool(g_CvarChat))
           {
               PrintToChatAll("-------- %s EST LE DERNIER GARDIEN --------", clientname);
               PrintToChatAll("-------- %s EST LE DERNIER GARDIEN --------", clientname);
               PrintToChatAll("-------- %s EST LE DERNIER GARDIEN --------", clientname);
               PrintToChatAll("-------- %s EST LE DERNIER GARDIEN --------", clientname);
           }
           if(g_soundPreference[lastManId] && !IsFakeClient(lastManId))
           {
               EmitSoundToClient(lastManId, g_soundName);
           }
       }
    
    
    }
    
    
    //  This sets enables or disables the sounds
    public PanelHandlerLastMan(Handle:menu, MenuAction:action, param1, param2)
    {
       if (action == MenuAction_Select)
           if(param2 == 2)
               g_soundPreference[param1] = 0;
           else
               g_soundPreference[param1] = param2;
       else if(action == MenuAction_Cancel)
           PrintToServer("Client %d's Last Man menu was cancelled.  Reason: %d", param1, param2);
    }
    
    //  This creates the lastman panel
    public Action:PanelLastman(client, args)
    {
       new Handle:panel = CreatePanel();
       SetPanelTitle(panel, "Last Man Standing Sound");
       DrawPanelItem(panel, "Enable");
       DrawPanelItem(panel, "Disable");
    
       SendPanelToClient(panel, client, PanelHandlerLastMan, 20);
    
       CloseHandle(panel);
    
       return Plugin_Handled;
    }

    Lien vers le commentaire
    Partager sur d’autres sites

    Salut,

     

     

    Comeme ca ?:

     

    #include <sdktools>
    #include <cstrike>
    #include <morecolors>
    
    
    public void OnPluginStart()
    {
       HookEvent("player_death", OnPlayerDeath);
    }
    
    
    public Action OnPlayerDeath(Event event, const char[] name, bool dontBroadcast)
    {    
       if (GetCountCT() == 1)
       {
           CPrintToChatAll("{green}DERNIER CT"); 
       }
    }
    
    
    public int GetCountCT()
    {
       int iCount = 0;
       for (int i = 1; i <= GetMaxClients(); i++)
       {
           if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT)
           {
               iCount ++;
           }
       }
    
       return iCount;
    }

     

    Cordialement,

    Lien vers le commentaire
    Partager sur d’autres sites

    Tu as le choix, je t'ai aussi fait la modification demande, la phrase de ton Dernier CT s'affiche seulement au joueurs qui sont dans la même team.

     

    #include <sourcemod>
    #include <sdktools>
    
    #pragma semicolon 1
    
    #define PLUGIN_VERSION "1.2.1"
    #define MAX_FILE_LEN 80
    
    // Plugin definitions
    public Plugin:myinfo = 
    {
       name = "LastMan",
       author = "dalto",
       description = "Last Man Sound",
       version = PLUGIN_VERSION,
       url = "http://forums.alliedmods.net"
    };
    
    
    new g_soundPreference[MAXPLAYERS + 1];
    new Handle:g_CvarChat = INVALID_HANDLE;
    new Handle:g_CvarAnnounce = INVALID_HANDLE;
    new Handle:g_CvarSoundName = INVALID_HANDLE;
    new Handle:g_CvarEnabled = INVALID_HANDLE;
    new String:g_soundName[MAX_FILE_LEN];
    
    
    public OnPluginStart()
    {
       // Before we do anything else lets make sure that the plugin is not disabled
       g_CvarEnabled = CreateConVar("sm_lastman_enable", "1", "Enables the LastMan plugin");
    
    
       // Create the rest of the g_Cvar's
       CreateConVar("sm_lastman_version", PLUGIN_VERSION, "Last Man Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
       g_CvarAnnounce = CreateConVar("sm_lastman_announce", "1", "Announcement preferences");
       g_CvarChat = CreateConVar("sm_lastman_chat", "1", "Chat preferences");
       g_CvarSoundName = CreateConVar("sm_lastman_sound", "lastman/oneandonly.wav", "The sound to play");
       HookConVarChange(g_CvarSoundName, OnSoundChanged);
    
       // Execute the config file
       AutoExecConfig(true, "lastman");
    
       HookEvent("player_death", EventPlayerDeath);
       RegConsoleCmd("lastman", PanelLastman);
    }
    
    
    public OnConfigsExecuted()
    {
       GetConVarString(g_CvarSoundName, g_soundName, MAX_FILE_LEN);
       decl String:buffer[MAX_FILE_LEN];
       PrecacheSound(g_soundName, true);
       Format(buffer, sizeof(buffer), "sound/%s", g_soundName);
       AddFileToDownloadsTable(buffer);
    }
    
    
    public OnSoundChanged(Handle:convar, const String:oldValue[], const String:newValue[])
    {
       decl String:buffer[MAX_FILE_LEN];
       strcopy(g_soundName, sizeof(g_soundName), newValue);
       PrecacheSound(g_soundName, true);
       Format(buffer, sizeof(buffer), "sound/%s", g_soundName);
       AddFileToDownloadsTable(buffer);
    }
    
    public Action:TimerAnnounce(Handle:timer, any:client)
    {
       if(client && IsClientInGame(client) && !IsFakeClient(client))
       {
           PrintToChat(client, "Say !lastman or /lastman to configure the last man standing sound");
       }
    }
    
    
    // When a new client is authorized we reset sound preferences
    // and let them know how to turn the sounds on and off
    public OnClientAuthorized(client, const String:auth[])
    {
       if(client && !IsFakeClient(client))
       {
           g_soundPreference[client] = 1;
           if(GetConVarBool(g_CvarAnnounce))
           {
               CreateTimer(30.0, TimerAnnounce, client);
           }
       }
    }
    
    
    // The death event
    public EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
    {
       if(!GetConVarBool(g_CvarEnabled))
       {
           return;
       }
    
       new victimId = GetEventInt(event, "userid");
    
    
       new victimClient = GetClientOfUserId(victimId);
    
    
       new killedTeam = GetClientTeam(victimClient);
    
    
       new playersConnected = GetMaxClients();
    
    
       // We check to see if there is only one person left.
       new lastManId = 0;
       for (new i = 1; i < playersConnected; i++)
       {
           if(IsClientInGame(i))
           {
               if(killedTeam==GetClientTeam(i) && IsPlayerAlive(i))
               {
                   if(lastManId)
                   {
                       lastManId = -1;
                   } else {
                       lastManId = i;
                   }
               }
           }
       }
    
       // If there is only person left than we play a sound and print a message
       if(lastManId > 0)
       {
           new String:clientname[64];
           GetClientName(lastManId, clientname, sizeof(clientname));
           if(GetConVarBool(g_CvarChat))
           {
               for (new i = 1; i <= MaxClients; i++)
               {
                   if(IsClientInGame(i) && IsClientConnected(i) && GetClientTeam(i) == GetClientTeam(lastManId))
                   {
                       PrintToChatAll(client, "-------- %s EST LE DERNIER GARDIEN --------", clientname);
                          PrintToChatAll(client, "-------- %s EST LE DERNIER GARDIEN --------", clientname);
                          PrintToChatAll(client, "-------- %s EST LE DERNIER GARDIEN --------", clientname);
                          PrintToChatAll(client, "-------- %s EST LE DERNIER GARDIEN --------", clientname);
                      }
           }
           if(g_soundPreference[lastManId] && !IsFakeClient(lastManId))
           {
               EmitSoundToClient(lastManId, g_soundName);
           }
       }
    
    
    }
    
    
    //  This sets enables or disables the sounds
    public PanelHandlerLastMan(Handle:menu, MenuAction:action, param1, param2)
    {
       if (action == MenuAction_Select)
           if(param2 == 2)
               g_soundPreference[param1] = 0;
           else
               g_soundPreference[param1] = param2;
       else if(action == MenuAction_Cancel)
           PrintToServer("Client %d's Last Man menu was cancelled.  Reason: %d", param1, param2);
    }
    
    //  This creates the lastman panel
    public Action:PanelLastman(client, args)
    {
       new Handle:panel = CreatePanel();
       SetPanelTitle(panel, "Last Man Standing Sound");
       DrawPanelItem(panel, "Enable");
       DrawPanelItem(panel, "Disable");
    
       SendPanelToClient(panel, client, PanelHandlerLastMan, 20);
    
       CloseHandle(panel);
    
       return Plugin_Handled;
    }
    

     

    Ton dernier CT est simple Nitroxyde ^^

    C'est sympa de proposer ton aide :p

    Lien vers le commentaire
    Partager sur d’autres sites

    Moi c'est un petit défis que je me donne ^^

    C'est pas compliquer mais juste long, j'ai des codes de bases qui merde et des codes complex qui fonctionne, je comprends pas la logique mais bon.

     

    Se que j'ai peur c'est surtout les requêtes sql, je dois les optis, mais un pote m'as fais découvrir SQL_LockDatabase, qui aide un peu ^^ et niveau requête, Marechoux s'amusent à m'aider xD

    J'aimerais terminer l'api et coder tout le RP pour ensuite, peut-être, je dis bien peut-être, la rendre public.

     

    C'est plus simple de coder un gros mode avec une api facile à utiliser.

     

    Heu le truc script chef gardien dans la section scripting ^^.

    Lien vers le commentaire
    Partager sur d’autres sites

    Merci à tout les deux pour vos propositions.

     

    Nitroxyde: Ton script fonctionne, mais il y a un petit problème, devant le message, le code couleur s'affiche au lieu de mettre le message en couleur demander, je crois que morecolors ne fonctionne pas sur CSGO, peut-tu mettre l'include SCP à la place ?

     

    Kriax: Pour ce plugins j'ai besoin que le message s'affiche aux deux équipes, mais le message doit concerner uniquement le dernier CT et pas le dernier terro. Faisant un serveur ba_jail, le dernier CT peut faire tout ce qu'il veux (et les règles n'ont aucun effet sur lui) du coups les terros doivent être au courant que c'est le dernier et qu'il peut tout faire.

     

    Je vous remercie tout les deux de m'aider, c'est très gentil de votre part :D

    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...