Jump to content
News ticker
  • Bienvenue sur le nouveau forum VeryGames
  • Welcome to the new VeryGames forum
  • VeryNews

    probleme script


    Azik

    Recommended Posts

    Bonjour,

     

    J'utilise un script, mais quand on tue la personne sa donne 4xxxxxx HP à la place de 10 HP.

     

    Le code:

    #pragma semicolon 1
    #include <sourcemod>
    #define PLUGIN_VERSION "1.0"
    
    
    
    
    new Handle:g_hEnable;
    new Handle:g_hAnnouce;
    new Handle:kniferhealth = INVALID_HANDLE;
    
    
    public OnPluginStart()
    {
    CreateConVar("css_kniferhealth_version", PLUGIN_VERSION, "La version du plugins", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_SPONLY);
    g_hEnable = CreateConVar("css_kniferhealth_enable", "1", "Mettre le plugins ON (1) et OFF (2)", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    g_hAnnouce = CreateConVar("css_kniferhealth_message", "1", "Mettre un message si on tue au couteau?", FCVAR_PLUGIN);
    kniferhealth = CreateConVar("css_kniferhealth", "10", "Combien d'HP gagne t-on si on tue au cut ?", FCVAR_PLUGIN);
    RegConsoleCmd("kh", Command_OnOff, "Is KniferHealth On/Off?");
    HookEvent("player_death", Event_player_knifed);
    //The Config File
    AutoExecConfig(true, "css_kniferhealth");
    }
    
    
    public Action:Event_player_knifed(Handle:event, const String:name[], bool:dontBroadcast)
    {
    //Enables The Plugin.
    if (GetConVarInt(g_hEnable) > 0)
    {
    	new client = GetClientOfUserId(GetEventInt(event, "attacker"));
    	//checks to see whether its an actual client.
    	//if (client > 0 && client < 20)
    	for(client = 0; client <= MaxClients; client++)
    	{
    		decl String:weaponName[32];
    		decl String:killerName[32];
    		decl String:victimName[32];
    		//decl String:target[32], String:health[10];
    		GetEventString(event,"weapon",weaponName,32);
    
    		//if the weapon used in death was a knife it continues
    
    		if(StrEqual(weaponName, "knife"))
    		{
    			new userid = GetEventInt(event, "userid");
    			new userid2 = GetEventInt(event, "attacker");
    			new victim = GetClientOfUserId(userid);
    			new killer = GetClientOfUserId(userid2);
    			//continues
    			if(victim != 0 && killer != 0)
    			{
    				new victimTeam = GetClientTeam(victim);
    				new killerTeam = GetClientTeam(killer);
    
    
    				if(killerTeam != victimTeam)
    				{
    					GetClientName(victim, victimName, 32);
    					GetClientName(killer, killerName, 32);
    
    					//Hints Messages to attacker and victim
    					if (GetConVarInt(g_hAnnouce) > 0)
    					{
    						PrintHintText(victim, "Tu as ete tue au couteau par %s !", killerName);
    						PrintHintText(killer, "Tu as tue %s. Tu gagnes %i hp !", victimName, kniferhealth);
    					}
    					//new m_Offset = FindSendPropOffs("CTFPlayer", "m_iHealth"); //Offset
    
    					//adds health to the knifer according to the convar's integer.
    					new kHealth = GetClientHealth(killer);
    					SetEntityHealth(killer, kHealth + GetConVarInt(kniferhealth));
    				}
    			}
    		}
    	}
    }
    }
    
    
    public Action:Command_OnOff(client, args)
    {
    if (GetConVarInt(g_hEnable) == 1)
    {
    	//\x04 is the color green(I think)
    	PrintToChat(client, "\x01Le script CutHP est actuellement \x04Actif\x01!");
    }
    else if (GetConVarInt(g_hEnable) == 0)
    {
    	PrintToChat(client, "\x01Le script CutHP est actuellement \x04Inactif\x01!");
    }
    return Plugin_Handled;
    }
    
    
    

     

    Merci :D

    Link to comment
    Share on other sites

    Tiens : https://forums.alliedmods.net/forumdisplay.php?f=52

     

    Je suis gentil :

     

    [b]SetEntityHealth[/b]
    
    [b]Syntax:[/b][color=#000000] stock SetEntityHealth(entity, amount)[/color] 
    
    [b]Usage: [/b]
    entity    Entity index.  
    amount    Health amount.[b]
    
    Notes[/b]: Sets an entity's health                           
    
    [b]Return: [/b][i]No return.[/i]
    
    [b]Version Added:[/b]
    1.0.0.1946
    [b]On error / Errors: [/b]Invalid entity index, or lack of mod compliance.
    

     

    Kriax.

    Link to comment
    Share on other sites

    Tien test

     

    #pragma semicolon 1
    #include <sourcemod>
    #define PLUGIN_VERSION "1.0"
    
    public Plugin:myinfo =
    {
       name    = "Plugin Knifed",
       author    = "Azik" ,
       version     = PLUGIN_VERSION,
    };
    
    new Handle:g_hEnable;
    new Handle:g_hAnnouce;
    new Handle:g_hKniferhealth = INVALID_HANDLE;
    new g_iKniferhealt = 0;
    
    
    public OnPluginStart()
    {
       CreateConVar("css_kniferhealth_version", PLUGIN_VERSION, "La version du plugins", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_SPONLY);
       g_hEnable = CreateConVar("css_kniferhealth_enable", "1", "Mettre le plugins ON (1) et OFF (2)", FCVAR_PLUGIN, true, 0.0, true, 1.0);
       g_hAnnouce = CreateConVar("css_kniferhealth_message", "1", "Mettre un message si on tue au couteau?", FCVAR_PLUGIN);
       g_hKniferhealth = CreateConVar("css_kniferhealth", "10", "Combien d'HP gagne t-on si on tue au cut ?", FCVAR_PLUGIN);
       RegConsoleCmd("kh", Command_OnOff, "Is KniferHealth On/Off?");
       HookEvent("player_death", Event_player_knifed);
       //The Config File
       AutoExecConfig(true, "css_kniferhealth");
    }
    
    public OnConfigsExecuted()
    {
       g_iKniferhealt = GetConVarInt(g_hKniferhealth);
    }
    
    public Action:Event_player_knifed(Handle:event, const String:name[], bool:dontBroadcast)
    {
       //Enables The Plugin.
       if (GetConVarInt(g_hEnable) > 0)
       {
           new client = GetClientOfUserId(GetEventInt(event, "attacker"));
           //checks to see whether its an actual client.
           //if (client > 0 && client < 20)
           for(client = 0; client <= MaxClients; client++)
           {
               decl String:weaponName[32];
               decl String:killerName[32];
               decl String:victimName[32];
               //decl String:target[32], String:health[10];
               GetEventString(event,"weapon",weaponName,32);
    
               //if the weapon used in death was a knife it continues
    
               if(StrEqual(weaponName, "knife"))
               {
                   new userid = GetEventInt(event, "userid");
                   new userid2 = GetEventInt(event, "attacker");
                   new victim = GetClientOfUserId(userid);
                   new killer = GetClientOfUserId(userid2);
                   //continues
                   if(victim != 0 && killer != 0)
                   {
                       new victimTeam = GetClientTeam(victim);
                       new killerTeam = GetClientTeam(killer);
    
    
                       if(killerTeam != victimTeam)
                       {
                           GetClientName(victim, victimName, 32);
                           GetClientName(killer, killerName, 32);
    
                           //Hints Messages to attacker and victim
                           if (GetConVarInt(g_hAnnouce) > 0)
                           {
                               PrintHintText(victim, "Tu as ete tue au couteau par %s !", killerName);
                               PrintHintText(killer, "Tu as tue %s. Tu gagnes %i hp !", victimName, g_iKniferhealt);
                           }
                           //new m_Offset = FindSendPropOffs("CTFPlayer", "m_iHealth"); //Offset
    
                           //adds health to the knifer according to the convar's integer.
                           new kHealth = GetClientHealth(killer);
                           SetEntityHealth(killer, kHealth + g_iKniferhealt);
                       }
                   }
               }
           }
       }
    }
    
    
    public Action:Command_OnOff(client, args)
    {
       if (GetConVarInt(g_hEnable) == 1)
       {
           //\x04 is the color green(I think)
           PrintToChat(client, "\x01Le script CutHP est actuellement \x04Actif\x01!");
       }
       else if (GetConVarInt(g_hEnable) == 0)
       {
           PrintToChat(client, "\x01Le script CutHP est actuellement \x04Inactif\x01!");
       }
       return Plugin_Handled;
    }
    

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...