Annonce

Réduire
Aucune annonce.

Lancer de couteau

Réduire
X
  • Filtre
  • Heure
  • Afficher
Tout nettoyer
nouveaux messages

  • Lancer de couteau

    Salut,

    J'aurais voulus savoir si on pouvais me mettre ce plugins avec un flag :
    http://forums.alliedmods.net/showthr...light=throwing

    (flag r)

    Merci

  • #2
    Salut,

    de base non, mais il est surement possible de le faire en modifiant la source.
    Communauté d'entraide (web, sourcemod, mani...) comprenant aussi de nombreux tutos
    http://tutos-serveur.net/

    Commentaire


    • #3
      KDO ==> http://forum.verygames.net/showthrea...r-vip-question

      Commentaire


      • #4
        Compile ça :

        Code PHP:
        // if lemurs had knives,
        // they would throw them!

        #include <sourcemod>
        #include <sdktools>

        #define NAME "CSS Throwing Knives"
        #define VERSION "1.2.2b"
        #define KNIFE_MDL "models/weapons/w_knife_ct.mdl"
        #define KNIFEHIT_SOUND "weapons/knife/knife_hit3.wav"
        #define TRAIL_MDL "materials/sprites/lgtning.vmt"
        #define TRAIL_COLOR {177, 177, 177, 117}
        #define ADD_OUTPUT "OnUser1 !self:Kill::1.5:1"
        #define COUNT_TXT "Throwing Knives : %i"

        new Handle:g_CVarEnable;
        new 
        Handle:g_CVarEnableDev;
        new 
        bool:g_bDev;
        new 
        Handle:g_hLethalArray;
        new 
        Handle:g_CVarVelocity;
        new 
        Float:g_fVelocity;
        new 
        Handle:g_CVarKnives;
        new 
        Handle:g_CVarDamage;
        new 
        String:g_sDamage[8];
        new 
        Handle:g_CVarHSDamage;
        new 
        String:g_sHSDamage[8];
        new 
        Handle:g_CVarSteal;
        new 
        Handle:g_CVarTrail;
        new 
        bool:g_bTrail;
        new 
        Handle:g_CVarNoBlock;
        new 
        bool:g_bNoBlock;
        new 
        Handle:g_CVarDisplay;
        new 
        g_iDisplay;
        new 
        Handle:g_CVarFF;
        new const 
        Float:g_fSpin[3] = {4877.40.00.0};
        new const 
        Float:g_fMinS[3] = {-24.0, -24.0, -24.0};
        new const 
        Float:g_fMaxS[3] = {24.024.024.0};
        new 
        g_iKnives[MAXPLAYERS+1];
        new 
        g_iKnifeMI;
        new 
        g_iPointHurt;
        new 
        g_iEnvBlood;
        new 
        g_iTrailMI;
        new 
        Handle:g_hKTForward;
        new 
        Handle:g_hKHForward;
        new 
        Handle:g_hKKForward;

        public 
        Plugin:myinfo = {

            
        name NAME,
            
        author "meng",
            
        version VERSION,
            
        description "Throwing knives for CSS",
            
        url "http://www.sourcemod.net"
        };

        public 
        APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max) {

            
        CreateNative("SetClientThrowingKnives"NativeSetClientThrowingKnives);
            
        CreateNative("GetClientThrowingKnives"NativeGetClientThrowingKnives);
            
        RegPluginLibrary("cssthrowingknives");
            return 
        APLRes_Success;
        }

        public 
        OnPluginStart() {

            
        CreateConVar("sm_cssthrowingknives"VERSIONNAMEFCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
            
        g_CVarEnable CreateConVar("sm_throwingknives_enable""1""Enable/disable plugin."_true0.0true1.0);
            
        g_CVarEnableDev CreateConVar("sm_throwingknives_dev""0""Enable/disable dev. mode."_true0.0true1.0);
            
        g_CVarVelocity CreateConVar("sm_throwingknives_velocity""5""Velocity (speed) adjustment."_true1.0true10.0);
            
        g_CVarKnives CreateConVar("sm_throwingknives_count""0""Amount of knives players spawn with."_true0.0true100.0);
            
        g_CVarDamage CreateConVar("sm_throwingknives_damage""57""Damage adjustment."_true10.0true200.0);
            
        g_CVarHSDamage CreateConVar("sm_throwingknives_hsdamage""127""Headshot damage adjustment."_true20.0true200.0);
            
        g_CVarSteal CreateConVar("sm_throwingknives_steal""1""If enabled, knife kills get the victims remaining knives. 0 = Disabled | 1 = Melee kills only | 2 = All knife kills"_true0.0true2.0);
            
        g_CVarTrail CreateConVar("sm_throwingknives_trail""0""Enable/disable trail effect."_true0.0true1.0);
            
        g_CVarNoBlock CreateConVar("sm_throwingknives_noblock""0""Set to \"1\" if using noblock for players."_true0.0true1.0);
            
        g_CVarDisplay CreateConVar("sm_throwingknives_display""1""Knives remaining display location. 1 = Hint | 2 = Key Hint"_true1.0true2.0);
            
        g_CVarFF FindConVar("mp_friendlyfire");

            
        // initialize global vars, hook CVar changes
            
        HookConVarChange(g_CVarEnableCVarChange);
            
        g_fVelocity = (1000.0 + (250.0 GetConVarFloat(g_CVarVelocity)));
            
        HookConVarChange(g_CVarVelocityCVarChange);
            
        GetConVarString(g_CVarDamageg_sDamagesizeof(g_sDamage));
            
        HookConVarChange(g_CVarDamageCVarChange);
            
        GetConVarString(g_CVarHSDamageg_sHSDamagesizeof(g_sHSDamage));
            
        HookConVarChange(g_CVarHSDamageCVarChange);
            
        g_bTrail GetConVarBool(g_CVarTrail);
            
        HookConVarChange(g_CVarTrailCVarChange);
            
        g_bNoBlock GetConVarBool(g_CVarNoBlock);
            
        HookConVarChange(g_CVarNoBlockCVarChange);
            
        g_iDisplay GetConVarInt(g_CVarDisplay);
            
        HookConVarChange(g_CVarDisplayCVarChange);
            
        g_bDev GetConVarBool(g_CVarEnableDev);
            
        HookConVarChange(g_CVarEnableDevCVarChange);

            
        AutoExecConfig(true"throwingknives");

            
        g_hLethalArray CreateArray();
            
        g_hKTForward CreateGlobalForward("OnKnifeThrow"ET_EventParam_Cell);
            
        g_hKHForward CreateGlobalForward("OnKnifeHit"ET_EventParam_CellParam_CellParam_Cell);
            
        g_hKKForward CreateGlobalForward("OnPostKnifeKill"ET_EventParam_CellParam_CellParam_Cell);

            
        AddNormalSoundHook(NormalSHook:SoundsHook);
            
        HookEvent("round_start"EventRoundStartEventHookMode_PostNoCopy);
            
        HookEvent("player_spawn"EventPlayerSpawn);
            
        HookEvent("weapon_fire"EventWeaponFire);
            
        HookEvent("player_death"EventPlayerDeathEventHookMode_Pre);
        }

        public 
        CVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) {

            if ((
        convar == g_CVarEnable) && (StringToInt(newValue) == 1)) {
                if (
        g_iPointHurt == -1)
                    
        CreateEnts();
                for (new 
        1<= MaxClientsi++)
                    
        g_iKnives[i] = GetConVarInt(g_CVarKnives);
            }
            else if (
        convar == g_CVarVelocity)
                
        g_fVelocity = (1000.0 + (250.0 StringToFloat(newValue)));
            else if (
        convar == g_CVarDamage)
                
        strcopy(g_sDamagesizeof(g_sDamage), newValue);
            else if (
        convar == g_CVarHSDamage)
                
        strcopy(g_sHSDamagesizeof(g_sHSDamage), newValue);
            else if (
        convar == g_CVarTrail)
                
        g_bTrail GetConVarBool(g_CVarTrail);
            else if (
        convar == g_CVarNoBlock)
                
        g_bNoBlock GetConVarBool(g_CVarNoBlock);
            else if (
        convar == g_CVarDisplay)
                
        g_iDisplay GetConVarInt(g_CVarDisplay);
            else if (
        convar == g_CVarEnableDev)
                
        g_bDev GetConVarBool(g_CVarNoBlock);
        }

        public 
        OnMapStart() {

            
        g_iKnifeMI PrecacheModel(KNIFE_MDL);
            
        g_iTrailMI PrecacheModel(TRAIL_MDL);
            
        PrecacheSound(KNIFEHIT_SOUND);
        }

        public 
        EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) {

            
        g_iPointHurt = -1;
            
        g_iEnvBlood = -1;
            
        ClearArray(g_hLethalArray);
            if (
        GetConVarBool(g_CVarEnable))
                
        CreateEnts();
        }

        public 
        EventPlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast) {

            if (
        GetConVarBool(g_CVarEnable)) {
                new 
        client GetClientOfUserId(GetEventInt(event"userid"));
                if(
        GetUserFlagBits(client) & ADMFLAG_CUSTOM4)
                    
        iKnives[client] = GetConVarInt(g_CVarKnives);
                else
                    
        iKnives[client] = 0;
            }
        }

        public 
        EventWeaponFire(Handle:event,const String:name[],bool:dontBroadcast) { // only fires for primary attack

            
        if (GetConVarBool(g_CVarEnable)) {
                new 
        client GetClientOfUserId(GetEventInt(event"userid"));
                static 
        String:sWeapon[32];
                
        GetEventString(event"weapon"sWeaponsizeof(sWeapon));
                if (!
        IsFakeClient(client) && StrEqual(sWeapon"knife") && (g_iKnives[client] > 0))
                    
        ThrowKnife(client);
            }
        }

        public 
        EventPlayerDeath(Handle:event,const String:name[],bool:dontBroadcast) {

            if (
        GetConVarBool(g_CVarEnable)) {
                new 
        victim GetClientOfUserId(GetEventInt(event"userid"));
                new 
        attacker GetClientOfUserId(GetEventInt(event"attacker"));
                
        decl String:sWeapon[32];
                
        GetEventString(event"weapon"sWeaponsizeof(sWeapon));
                new 
        bool:tknife StrEqual(sWeapon"tknife");
                new 
        bool:tknifehs StrEqual(sWeapon"tknifehs");
                if (
        tknife || tknifehs) {
                    
        // the event is pre-hooked,
                    // setting the weapon string will change the icon used in the kill notification
                    
        SetEventString(event"weapon""knife");
                    if (
        g_bDev) {
                        
        Call_StartForward(g_hKKForward);
                        
        Call_PushCell(victim);
                        
        Call_PushCell(attacker);
                        
        Call_PushCell(tknifehs);
                        
        // since i cant prevent the victim from dying at this point,
                        // i dont care what the return value is
                        
        Call_Finish();
                    }
                    if ((
        GetConVarInt(g_CVarSteal) > 1) && (GetClientTeam(attacker) != GetClientTeam(victim)))
                        
        KnifeCount(attacker, (g_iKnives[attacker] = (g_iKnives[attacker] + g_iKnives[victim])));
                }
                else if (
        StrEqual(sWeapon"knife") && (GetConVarInt(g_CVarSteal) > 0) && (GetClientTeam(attacker) != GetClientTeam(victim)))
                    
        KnifeCount(attacker, (g_iKnives[attacker] = (g_iKnives[attacker] + g_iKnives[victim])));
            }
        }

        ThrowKnife(client) {

            
        // anybody care if this dude throws a knife?
            
        if (g_bDev) {
                new 
        value;
                
        Call_StartForward(g_hKTForward);
                
        Call_PushCell(client);
                
        Call_Finish(_:value);
                if (
        value != 0)
                    return;
            }

            static 
        Float:fPos[3], Float:fAng[3], Float:fVel[3], Float:fPVel[3];
            
        GetClientEyePosition(clientfPos);
            
        // simple noblock fix. prevent throw if it will spawn inside another client
            
        if (g_bNoBlock && IsClientIndex(GetTraceHullEntityIndex(fPosclient)))
                return;

            
        // create & spawn entity. set model & owner. set to kill itself OnUser1
            // calc & set spawn position, angle, velocity & spin
            // add to lethal knife array, teleport, add trial, ...
            
        new entity CreateEntityByName("flashbang_projectile");
            if ((
        entity != -1) && DispatchSpawn(entity)) {
                
        SetEntityModel(entityKNIFE_MDL);
                
        SetEntPropEnt(entityProp_Send"m_hOwnerEntity"client);
                
        SetVariantString(ADD_OUTPUT);
                
        AcceptEntityInput(entity"AddOutput");
                
        GetClientEyeAngles(clientfAng);
                
        GetAngleVectors(fAngfVelNULL_VECTORNULL_VECTOR);
                
        ScaleVector(fVelg_fVelocity);
                
        GetEntPropVector(clientProp_Data"m_vecVelocity"fPVel);
                
        AddVectors(fVelfPVelfVel);
                
        SetEntPropVector(entityProp_Data"m_vecAngVelocity"g_fSpin);
                
        SetEntPropFloat(entityProp_Send"m_flElasticity"0.2);
                
        PushArrayCell(g_hLethalArrayentity);
                
        TeleportEntity(entityfPosfAngfVel);
                
        KnifeCount(client, --g_iKnives[client]);
                if (
        g_bTrail) {
                    
        TE_SetupBeamFollow(entityg_iTrailMI00.77.77.73TRAIL_COLOR);
                    
        TE_SendToAll();
                }
            }
        }

        public 
        Action:SoundsHook(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags) {

            if (
        GetConVarBool(g_CVarEnable) && StrEqual(sample"weapons/flashbang/grenade_hit1.wav"false)) {
                new 
        index FindValueInArray(g_hLethalArrayentity);
                if (
        index != -1) {
                    
        volume 0.2;
                    
        RemoveFromArray(g_hLethalArrayindex); // delethalize on first bounce
                    
        new attacker GetEntPropEnt(entityProp_Send"m_hOwnerEntity");
                    static 
        Float:fKnifePos[3], Float:fAttPos[3], Float:fVicEyePos[3];
                    
        GetEntPropVector(entityProp_Data"m_vecOrigin"fKnifePos);
                    new 
        victim GetTraceHullEntityIndex(fKnifePosattacker);
                    if (
        IsClientIndex(victim) && IsClientInGame(attacker)) {
                        
        RemoveEdict(entity);
                        if (
        GetConVarBool(g_CVarFF) || (GetClientTeam(victim) != GetClientTeam(attacker))) {
                            
        GetClientAbsOrigin(attackerfAttPos);
                            
        GetClientEyePosition(victimfVicEyePos);
                            
        EmitAmbientSound(KNIFEHIT_SOUNDfKnifePosvictimSNDLEVEL_NORMAL_0.8);
                            
        // HURT!
                            
        if (IsValidEntity(g_iPointHurt)) {
                                new 
        bool:headShot = (FloatAbs(fKnifePos[2] - fVicEyePos[2]) < 4.7) ? true false;
                                
        // last chance to stop this thing were doing
                                
        if (g_bDev) {
                                    new 
        value;
                                    
        Call_StartForward(g_hKHForward);
                                    
        Call_PushCell(victim);
                                    
        Call_PushCell(attacker);
                                    
        Call_PushCell(headShot);
                                    
        Call_Finish(_:value);
                                    if (
        value != 0)
                                        return 
        Plugin_Changed;
                                }
                                
        DispatchKeyValue(victim"targetname""hurt");
                                
        DispatchKeyValue(g_iPointHurt"Damage", (headShot) ? g_sHSDamage g_sDamage);
                                
        DispatchKeyValue(g_iPointHurt"classname", (headShot) ? "weapon_tknifehs" "weapon_tknife");
                                
        TeleportEntity(g_iPointHurtfAttPosNULL_VECTORNULL_VECTOR);
                                
        AcceptEntityInput(g_iPointHurt"Hurt"attacker);
                                
        DispatchKeyValue(g_iPointHurt"classname""point_hurt");
                                
        DispatchKeyValue(victim"targetname""nohurt");
                                
        SetVariantString("BloodImpact");
                                
        AcceptEntityInput(entity"DispatchEffect");
                                if (
        IsValidEntity(g_iEnvBlood))
                                    
        AcceptEntityInput(g_iEnvBlood"EmitBlood"victim);
                            }
                        }
                    }
                    else 
        // didn't hit a player, kill itself in a few seconds
                        
        AcceptEntityInput(entity"FireUser1");
                    return 
        Plugin_Changed;
                }
                else if (
        GetEntProp(entityProp_Send"m_nModelIndex") == g_iKnifeMI) {
                    
        volume 0.2;
                    return 
        Plugin_Changed;
                }
            }
            return 
        Plugin_Continue;
        }

        GetTraceHullEntityIndex(Float:pos[3], xindex) {

            
        TR_TraceHullFilter(posposg_fMinSg_fMaxSMASK_SHOTTHFilterxindex);
            return 
        TR_GetEntityIndex();
        }

        public 
        bool:THFilter(entitycontentsMaskany:data) {

            return 
        IsClientIndex(entity) && (entity != data);
        }

        bool:IsClientIndex(index) {

            return (
        index 0) && (index <= MaxClients);
        }

        KnifeCount(clientcount) {

            if (
        IsClientInGame(client)) {
                switch (
        g_iDisplay) {
                    case 
        1// Hint
                        
        PrintHintText(clientCOUNT_TXTcount);
                    case 
        2: { // Key Hint
                        
        static String:sBuffer[64];
                        
        Format(sBuffer64COUNT_TXTcount);
                        new 
        Handle:hKHT StartMessageOne("KeyHintText"client);
                        
        BfWriteByte(hKHT1);
                        
        BfWriteString(hKHTsBuffer);
                        
        EndMessage();
                    }
                }
            }
        }

        CreateEnts() {

            if (((
        g_iPointHurt CreateEntityByName("point_hurt")) != -1) && DispatchSpawn(g_iPointHurt)) {
                
        DispatchKeyValue(g_iPointHurt"DamageTarget""hurt");
                
        DispatchKeyValue(g_iPointHurt"DamageType""0");
            }
            if (((
        g_iEnvBlood CreateEntityByName("env_blood")) != -1) && DispatchSpawn(g_iEnvBlood)) {
                
        DispatchKeyValue(g_iEnvBlood"spawnflags""13");
                
        DispatchKeyValue(g_iEnvBlood"amount""1000");
            }
        }

        public 
        NativeSetClientThrowingKnives(Handle:pluginnumParams) {

            new 
        client GetNativeCell(1);
            new 
        num GetNativeCell(2);
            
        KnifeCount(clientg_iKnives[client] = num);
        }

        public 
        NativeGetClientThrowingKnives(Handle:pluginnumParams) {

            new 
        client GetNativeCell(1);
            return 
        g_iKnives[client];

        Logiquement c'est bon.

        Kriax.

        Commentaire


        • #5
          Sa me dit sa :

          Commentaire


          • #6
            Petite erreur de ma part :

            Code PHP:
            // if lemurs had knives,
            // they would throw them!

            #include <sourcemod>
            #include <sdktools>

            #define NAME "CSS Throwing Knives"
            #define VERSION "1.2.2b"
            #define KNIFE_MDL "models/weapons/w_knife_ct.mdl"
            #define KNIFEHIT_SOUND "weapons/knife/knife_hit3.wav"
            #define TRAIL_MDL "materials/sprites/lgtning.vmt"
            #define TRAIL_COLOR {177, 177, 177, 117}
            #define ADD_OUTPUT "OnUser1 !self:Kill::1.5:1"
            #define COUNT_TXT "Throwing Knives : %i"

            new Handle:g_CVarEnable;
            new 
            Handle:g_CVarEnableDev;
            new 
            bool:g_bDev;
            new 
            Handle:g_hLethalArray;
            new 
            Handle:g_CVarVelocity;
            new 
            Float:g_fVelocity;
            new 
            Handle:g_CVarKnives;
            new 
            Handle:g_CVarDamage;
            new 
            String:g_sDamage[8];
            new 
            Handle:g_CVarHSDamage;
            new 
            String:g_sHSDamage[8];
            new 
            Handle:g_CVarSteal;
            new 
            Handle:g_CVarTrail;
            new 
            bool:g_bTrail;
            new 
            Handle:g_CVarNoBlock;
            new 
            bool:g_bNoBlock;
            new 
            Handle:g_CVarDisplay;
            new 
            g_iDisplay;
            new 
            Handle:g_CVarFF;
            new const 
            Float:g_fSpin[3] = {4877.40.00.0};
            new const 
            Float:g_fMinS[3] = {-24.0, -24.0, -24.0};
            new const 
            Float:g_fMaxS[3] = {24.024.024.0};
            new 
            g_iKnives[MAXPLAYERS+1];
            new 
            g_iKnifeMI;
            new 
            g_iPointHurt;
            new 
            g_iEnvBlood;
            new 
            g_iTrailMI;
            new 
            Handle:g_hKTForward;
            new 
            Handle:g_hKHForward;
            new 
            Handle:g_hKKForward;

            public 
            Plugin:myinfo = {

                
            name NAME,
                
            author "meng",
                
            version VERSION,
                
            description "Throwing knives for CSS",
                
            url "http://www.sourcemod.net"
            };

            public 
            APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max) {

                
            CreateNative("SetClientThrowingKnives"NativeSetClientThrowingKnives);
                
            CreateNative("GetClientThrowingKnives"NativeGetClientThrowingKnives);
                
            RegPluginLibrary("cssthrowingknives");
                return 
            APLRes_Success;
            }

            public 
            OnPluginStart() {

                
            CreateConVar("sm_cssthrowingknives"VERSIONNAMEFCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
                
            g_CVarEnable CreateConVar("sm_throwingknives_enable""1""Enable/disable plugin."_true0.0true1.0);
                
            g_CVarEnableDev CreateConVar("sm_throwingknives_dev""0""Enable/disable dev. mode."_true0.0true1.0);
                
            g_CVarVelocity CreateConVar("sm_throwingknives_velocity""5""Velocity (speed) adjustment."_true1.0true10.0);
                
            g_CVarKnives CreateConVar("sm_throwingknives_count""0""Amount of knives players spawn with."_true0.0true100.0);
                
            g_CVarDamage CreateConVar("sm_throwingknives_damage""57""Damage adjustment."_true10.0true200.0);
                
            g_CVarHSDamage CreateConVar("sm_throwingknives_hsdamage""127""Headshot damage adjustment."_true20.0true200.0);
                
            g_CVarSteal CreateConVar("sm_throwingknives_steal""1""If enabled, knife kills get the victims remaining knives. 0 = Disabled | 1 = Melee kills only | 2 = All knife kills"_true0.0true2.0);
                
            g_CVarTrail CreateConVar("sm_throwingknives_trail""0""Enable/disable trail effect."_true0.0true1.0);
                
            g_CVarNoBlock CreateConVar("sm_throwingknives_noblock""0""Set to \"1\" if using noblock for players."_true0.0true1.0);
                
            g_CVarDisplay CreateConVar("sm_throwingknives_display""1""Knives remaining display location. 1 = Hint | 2 = Key Hint"_true1.0true2.0);
                
            g_CVarFF FindConVar("mp_friendlyfire");

                
            // initialize global vars, hook CVar changes
                
            HookConVarChange(g_CVarEnableCVarChange);
                
            g_fVelocity = (1000.0 + (250.0 GetConVarFloat(g_CVarVelocity)));
                
            HookConVarChange(g_CVarVelocityCVarChange);
                
            GetConVarString(g_CVarDamageg_sDamagesizeof(g_sDamage));
                
            HookConVarChange(g_CVarDamageCVarChange);
                
            GetConVarString(g_CVarHSDamageg_sHSDamagesizeof(g_sHSDamage));
                
            HookConVarChange(g_CVarHSDamageCVarChange);
                
            g_bTrail GetConVarBool(g_CVarTrail);
                
            HookConVarChange(g_CVarTrailCVarChange);
                
            g_bNoBlock GetConVarBool(g_CVarNoBlock);
                
            HookConVarChange(g_CVarNoBlockCVarChange);
                
            g_iDisplay GetConVarInt(g_CVarDisplay);
                
            HookConVarChange(g_CVarDisplayCVarChange);
                
            g_bDev GetConVarBool(g_CVarEnableDev);
                
            HookConVarChange(g_CVarEnableDevCVarChange);

                
            AutoExecConfig(true"throwingknives");

                
            g_hLethalArray CreateArray();
                
            g_hKTForward CreateGlobalForward("OnKnifeThrow"ET_EventParam_Cell);
                
            g_hKHForward CreateGlobalForward("OnKnifeHit"ET_EventParam_CellParam_CellParam_Cell);
                
            g_hKKForward CreateGlobalForward("OnPostKnifeKill"ET_EventParam_CellParam_CellParam_Cell);

                
            AddNormalSoundHook(NormalSHook:SoundsHook);
                
            HookEvent("round_start"EventRoundStartEventHookMode_PostNoCopy);
                
            HookEvent("player_spawn"EventPlayerSpawn);
                
            HookEvent("weapon_fire"EventWeaponFire);
                
            HookEvent("player_death"EventPlayerDeathEventHookMode_Pre);
            }

            public 
            CVarChange(Handle:convar, const String:oldValue[], const String:newValue[]) {

                if ((
            convar == g_CVarEnable) && (StringToInt(newValue) == 1)) {
                    if (
            g_iPointHurt == -1)
                        
            CreateEnts();
                    for (new 
            1<= MaxClientsi++)
                        
            g_iKnives[i] = GetConVarInt(g_CVarKnives);
                }
                else if (
            convar == g_CVarVelocity)
                    
            g_fVelocity = (1000.0 + (250.0 StringToFloat(newValue)));
                else if (
            convar == g_CVarDamage)
                    
            strcopy(g_sDamagesizeof(g_sDamage), newValue);
                else if (
            convar == g_CVarHSDamage)
                    
            strcopy(g_sHSDamagesizeof(g_sHSDamage), newValue);
                else if (
            convar == g_CVarTrail)
                    
            g_bTrail GetConVarBool(g_CVarTrail);
                else if (
            convar == g_CVarNoBlock)
                    
            g_bNoBlock GetConVarBool(g_CVarNoBlock);
                else if (
            convar == g_CVarDisplay)
                    
            g_iDisplay GetConVarInt(g_CVarDisplay);
                else if (
            convar == g_CVarEnableDev)
                    
            g_bDev GetConVarBool(g_CVarNoBlock);
            }

            public 
            OnMapStart() {

                
            g_iKnifeMI PrecacheModel(KNIFE_MDL);
                
            g_iTrailMI PrecacheModel(TRAIL_MDL);
                
            PrecacheSound(KNIFEHIT_SOUND);
            }

            public 
            EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) {

                
            g_iPointHurt = -1;
                
            g_iEnvBlood = -1;
                
            ClearArray(g_hLethalArray);
                if (
            GetConVarBool(g_CVarEnable))
                    
            CreateEnts();
            }

            public 
            EventPlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast) {

                if (
            GetConVarBool(g_CVarEnable)) {
                    new 
            client GetClientOfUserId(GetEventInt(event"userid"));
                    if(
            GetUserFlagBits(client) & ADMFLAG_CUSTOM4)
                        
            g_iKnives[client] = GetConVarInt(g_CVarKnives);
                    else
                        
            g_iKnives[client] = 0;
                }
            }

            public 
            EventWeaponFire(Handle:event,const String:name[],bool:dontBroadcast) { // only fires for primary attack

                
            if (GetConVarBool(g_CVarEnable)) {
                    new 
            client GetClientOfUserId(GetEventInt(event"userid"));
                    static 
            String:sWeapon[32];
                    
            GetEventString(event"weapon"sWeaponsizeof(sWeapon));
                    if (!
            IsFakeClient(client) && StrEqual(sWeapon"knife") && (g_iKnives[client] > 0))
                        
            ThrowKnife(client);
                }
            }

            public 
            EventPlayerDeath(Handle:event,const String:name[],bool:dontBroadcast) {

                if (
            GetConVarBool(g_CVarEnable)) {
                    new 
            victim GetClientOfUserId(GetEventInt(event"userid"));
                    new 
            attacker GetClientOfUserId(GetEventInt(event"attacker"));
                    
            decl String:sWeapon[32];
                    
            GetEventString(event"weapon"sWeaponsizeof(sWeapon));
                    new 
            bool:tknife StrEqual(sWeapon"tknife");
                    new 
            bool:tknifehs StrEqual(sWeapon"tknifehs");
                    if (
            tknife || tknifehs) {
                        
            // the event is pre-hooked,
                        // setting the weapon string will change the icon used in the kill notification
                        
            SetEventString(event"weapon""knife");
                        if (
            g_bDev) {
                            
            Call_StartForward(g_hKKForward);
                            
            Call_PushCell(victim);
                            
            Call_PushCell(attacker);
                            
            Call_PushCell(tknifehs);
                            
            // since i cant prevent the victim from dying at this point,
                            // i dont care what the return value is
                            
            Call_Finish();
                        }
                        if ((
            GetConVarInt(g_CVarSteal) > 1) && (GetClientTeam(attacker) != GetClientTeam(victim)))
                            
            KnifeCount(attacker, (g_iKnives[attacker] = (g_iKnives[attacker] + g_iKnives[victim])));
                    }
                    else if (
            StrEqual(sWeapon"knife") && (GetConVarInt(g_CVarSteal) > 0) && (GetClientTeam(attacker) != GetClientTeam(victim)))
                        
            KnifeCount(attacker, (g_iKnives[attacker] = (g_iKnives[attacker] + g_iKnives[victim])));
                }
            }

            ThrowKnife(client) {

                
            // anybody care if this dude throws a knife?
                
            if (g_bDev) {
                    new 
            value;
                    
            Call_StartForward(g_hKTForward);
                    
            Call_PushCell(client);
                    
            Call_Finish(_:value);
                    if (
            value != 0)
                        return;
                }

                static 
            Float:fPos[3], Float:fAng[3], Float:fVel[3], Float:fPVel[3];
                
            GetClientEyePosition(clientfPos);
                
            // simple noblock fix. prevent throw if it will spawn inside another client
                
            if (g_bNoBlock && IsClientIndex(GetTraceHullEntityIndex(fPosclient)))
                    return;

                
            // create & spawn entity. set model & owner. set to kill itself OnUser1
                // calc & set spawn position, angle, velocity & spin
                // add to lethal knife array, teleport, add trial, ...
                
            new entity CreateEntityByName("flashbang_projectile");
                if ((
            entity != -1) && DispatchSpawn(entity)) {
                    
            SetEntityModel(entityKNIFE_MDL);
                    
            SetEntPropEnt(entityProp_Send"m_hOwnerEntity"client);
                    
            SetVariantString(ADD_OUTPUT);
                    
            AcceptEntityInput(entity"AddOutput");
                    
            GetClientEyeAngles(clientfAng);
                    
            GetAngleVectors(fAngfVelNULL_VECTORNULL_VECTOR);
                    
            ScaleVector(fVelg_fVelocity);
                    
            GetEntPropVector(clientProp_Data"m_vecVelocity"fPVel);
                    
            AddVectors(fVelfPVelfVel);
                    
            SetEntPropVector(entityProp_Data"m_vecAngVelocity"g_fSpin);
                    
            SetEntPropFloat(entityProp_Send"m_flElasticity"0.2);
                    
            PushArrayCell(g_hLethalArrayentity);
                    
            TeleportEntity(entityfPosfAngfVel);
                    
            KnifeCount(client, --g_iKnives[client]);
                    if (
            g_bTrail) {
                        
            TE_SetupBeamFollow(entityg_iTrailMI00.77.77.73TRAIL_COLOR);
                        
            TE_SendToAll();
                    }
                }
            }

            public 
            Action:SoundsHook(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags) {

                if (
            GetConVarBool(g_CVarEnable) && StrEqual(sample"weapons/flashbang/grenade_hit1.wav"false)) {
                    new 
            index FindValueInArray(g_hLethalArrayentity);
                    if (
            index != -1) {
                        
            volume 0.2;
                        
            RemoveFromArray(g_hLethalArrayindex); // delethalize on first bounce
                        
            new attacker GetEntPropEnt(entityProp_Send"m_hOwnerEntity");
                        static 
            Float:fKnifePos[3], Float:fAttPos[3], Float:fVicEyePos[3];
                        
            GetEntPropVector(entityProp_Data"m_vecOrigin"fKnifePos);
                        new 
            victim GetTraceHullEntityIndex(fKnifePosattacker);
                        if (
            IsClientIndex(victim) && IsClientInGame(attacker)) {
                            
            RemoveEdict(entity);
                            if (
            GetConVarBool(g_CVarFF) || (GetClientTeam(victim) != GetClientTeam(attacker))) {
                                
            GetClientAbsOrigin(attackerfAttPos);
                                
            GetClientEyePosition(victimfVicEyePos);
                                
            EmitAmbientSound(KNIFEHIT_SOUNDfKnifePosvictimSNDLEVEL_NORMAL_0.8);
                                
            // HURT!
                                
            if (IsValidEntity(g_iPointHurt)) {
                                    new 
            bool:headShot = (FloatAbs(fKnifePos[2] - fVicEyePos[2]) < 4.7) ? true false;
                                    
            // last chance to stop this thing were doing
                                    
            if (g_bDev) {
                                        new 
            value;
                                        
            Call_StartForward(g_hKHForward);
                                        
            Call_PushCell(victim);
                                        
            Call_PushCell(attacker);
                                        
            Call_PushCell(headShot);
                                        
            Call_Finish(_:value);
                                        if (
            value != 0)
                                            return 
            Plugin_Changed;
                                    }
                                    
            DispatchKeyValue(victim"targetname""hurt");
                                    
            DispatchKeyValue(g_iPointHurt"Damage", (headShot) ? g_sHSDamage g_sDamage);
                                    
            DispatchKeyValue(g_iPointHurt"classname", (headShot) ? "weapon_tknifehs" "weapon_tknife");
                                    
            TeleportEntity(g_iPointHurtfAttPosNULL_VECTORNULL_VECTOR);
                                    
            AcceptEntityInput(g_iPointHurt"Hurt"attacker);
                                    
            DispatchKeyValue(g_iPointHurt"classname""point_hurt");
                                    
            DispatchKeyValue(victim"targetname""nohurt");
                                    
            SetVariantString("BloodImpact");
                                    
            AcceptEntityInput(entity"DispatchEffect");
                                    if (
            IsValidEntity(g_iEnvBlood))
                                        
            AcceptEntityInput(g_iEnvBlood"EmitBlood"victim);
                                }
                            }
                        }
                        else 
            // didn't hit a player, kill itself in a few seconds
                            
            AcceptEntityInput(entity"FireUser1");
                        return 
            Plugin_Changed;
                    }
                    else if (
            GetEntProp(entityProp_Send"m_nModelIndex") == g_iKnifeMI) {
                        
            volume 0.2;
                        return 
            Plugin_Changed;
                    }
                }
                return 
            Plugin_Continue;
            }

            GetTraceHullEntityIndex(Float:pos[3], xindex) {

                
            TR_TraceHullFilter(posposg_fMinSg_fMaxSMASK_SHOTTHFilterxindex);
                return 
            TR_GetEntityIndex();
            }

            public 
            bool:THFilter(entitycontentsMaskany:data) {

                return 
            IsClientIndex(entity) && (entity != data);
            }

            bool:IsClientIndex(index) {

                return (
            index 0) && (index <= MaxClients);
            }

            KnifeCount(clientcount) {

                if (
            IsClientInGame(client)) {
                    switch (
            g_iDisplay) {
                        case 
            1// Hint
                            
            PrintHintText(clientCOUNT_TXTcount);
                        case 
            2: { // Key Hint
                            
            static String:sBuffer[64];
                            
            Format(sBuffer64COUNT_TXTcount);
                            new 
            Handle:hKHT StartMessageOne("KeyHintText"client);
                            
            BfWriteByte(hKHT1);
                            
            BfWriteString(hKHTsBuffer);
                            
            EndMessage();
                        }
                    }
                }
            }

            CreateEnts() {

                if (((
            g_iPointHurt CreateEntityByName("point_hurt")) != -1) && DispatchSpawn(g_iPointHurt)) {
                    
            DispatchKeyValue(g_iPointHurt"DamageTarget""hurt");
                    
            DispatchKeyValue(g_iPointHurt"DamageType""0");
                }
                if (((
            g_iEnvBlood CreateEntityByName("env_blood")) != -1) && DispatchSpawn(g_iEnvBlood)) {
                    
            DispatchKeyValue(g_iEnvBlood"spawnflags""13");
                    
            DispatchKeyValue(g_iEnvBlood"amount""1000");
                }
            }

            public 
            NativeSetClientThrowingKnives(Handle:pluginnumParams) {

                new 
            client GetNativeCell(1);
                new 
            num GetNativeCell(2);
                
            KnifeCount(clientg_iKnives[client] = num);
            }

            public 
            NativeGetClientThrowingKnives(Handle:pluginnumParams) {

                new 
            client GetNativeCell(1);
                return 
            g_iKnives[client];


            Commentaire


            • #7
              marche pas

              Commentaire


              • #8
                Heu t'es sur ? xD

                Commentaire


                • #9
                  ya pas de couteau :P

                  Commentaire


                  • #10
                    Envoyé par kriax Voir le message
                    Reprend la source d'origine.

                    Remplace le Player_Spawn par ceci :
                    Code PHP:
                    public EventPlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
                    {
                        new 
                    client GetClientOfUserId(GetEventInt(event"userid"));

                        if ((
                    GetConVarBool(g_CVarEnable)) && IsVip(client))
                        {
                            
                    g_iKnives[client] = GetConVarInt(g_CVarKnives);
                        }
                        else
                        {
                            
                    g_iKnives[client] = 0
                        
                    }

                    et en dessous tu met cela :
                    Code PHP:
                    public IsVip(client)
                    {
                        if (
                    GetUserFlagBits(client) & ADMFLAG_CUSTOM4) return true;
                        else return 
                    false;

                    Tiens fait se que j'avais dit à l'époque, même si ma modif est bonne oO

                    Commentaire

                    Chargement...
                    X