Raised This Month: $350 Target: $400
 87%   Almost there!

It's possible?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hu3br
Senior Member
Join Date: Apr 2015
Old 10-31-2016 , 22:58   It's possible?
Reply With Quote #1

Is possible made this plugin [CSS & CSGO] Throwing Knives works with another entity for replace smokegrenade_projectile, because i use this [CSGO] Custom Nade Models 1.2 and when i throw the knife, it goes like a model that i choosen for smoke, anyone can help ?

Thanks
hu3br is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-31-2016 , 23:46   Re: It's possible?
Reply With Quote #2

For those who do not understand what OP is asking:
When the throwing knives is creating the knife it is actually making a smokegrenade_projectile with the model of the knife, which Custom Nade Models plugin is catching the creation of the smokegrenade and changing the model.

EDIT:
try this:

Last edited by Mitchell; 11-01-2016 at 09:23.
Mitchell is offline
hu3br
Senior Member
Join Date: Apr 2015
Old 11-01-2016 , 08:59   Re: It's possible?
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
For those who do not understand what OP is asking:
When the throwing knives is creating the knife it is actually making a smokegrenade_projectile with the model of the knife, which Custom Nade Models plugin is catching the creation of the smokegrenade and changing the model.

EDIT:
try this:
Same problem =(
hu3br is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-01-2016 , 09:24   Re: It's possible?
Reply With Quote #4

Quote:
Originally Posted by hu3br View Post
Same problem =(
Maybe this
Attached Files
File Type: sp Get Plugin or Get Source (throwingknives.sp - 373 views - 11.8 KB)
Mitchell is offline
hu3br
Senior Member
Join Date: Apr 2015
Old 11-01-2016 , 09:55   Re: It's possible?
Reply With Quote #5

sorry, I'm using it, the vip throwing knives, my bad haha ! But still not working

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <cstrike>
#include <vip_core>

public Plugin:myinfo 
{
    
name "[VIP] Throwing Knives",
    
author "R1KO (original by meng, Bacardi)",
    
version "1.0.5"
};

#define VIP_TK        "ThrowingKnives"

#define DMG_HEADSHOT        (1 << 30)

new bool:    g_bIsCSGO;

new            
g_iTrailSprite;
new            
g_iBloodDecal;
new 
Handle:    g_hThrownKnives;
new 
Handle:    g_hTimerDelay[MAXPLAYERS+1];
new 
bool:    g_bHeadshot[MAXPLAYERS+1];
new            
g_iPlayerKniveCount[MAXPLAYERS+1];

new 
bool:    g_Cvar_bSteal;
new 
Float:    g_Cvar_fVelocity;
new 
Float:    g_Cvar_fDamage;
new 
Float:    g_Cvar_fHSDamage;
new 
Float:    g_Cvar_fModelScale;
new 
Float:    g_Cvar_fGravity;
new 
Float:    g_Cvar_fElasticity;
new 
Float:    g_Cvar_fMaxLifeTime;
new 
bool:    g_Cvar_bTrails;

public 
OnPluginStart() 
{
    
g_bIsCSGO Func_IsCSGO();

    
decl Handle:hCvar;

    
hCvar CreateConVar("vip_throwingknives_steal""1""Если включено атакующий получит ножи жертвы."_true0.0true1.0);
    
HookConVarChange(hCvarOnStealChange);
    
g_Cvar_bSteal GetConVarBool(hCvar);
    
hCvar CreateConVar("vip_throwingknives_velocity""2250""Скорость полёта ножа.");
    
HookConVarChange(hCvarOnVelocityChange);
    
g_Cvar_fVelocity GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_damage""57""Наносимый урон."_true0.0);
    
HookConVarChange(hCvarOnDamageChange);
    
g_Cvar_fDamage GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_hsdamage""127""Наносимый урон в голову."_true0.0);
    
HookConVarChange(hCvarOnHSDamageChange);
    
g_Cvar_fHSDamage GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_modelscale""1.0""Значение размера ножа (1.0 - норма)"_true0.0);
    
HookConVarChange(hCvarOnModelScaleChange);
    
g_Cvar_fModelScale GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_gravity""1.0""Значение силы тяжести ножа (1.0 - норма)"_true0.0);
    
HookConVarChange(hCvarOnGravityChange);
    
g_Cvar_fGravity GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_elasticity""0.2""Значение эластичности"_true0.0);
    
HookConVarChange(hCvarOnElasticityChange);
    
g_Cvar_fElasticity GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_maxlifetime""1.5""Максимальное время жизни ножа (сек)"_true1.0true30.0);
    
HookConVarChange(hCvarOnMaxLifeTimeChange);
    
g_Cvar_fMaxLifeTime GetConVarFloat(hCvar);
    
hCvar CreateConVar("vip_throwingknives_trails""1""Эффект траектории ножа"_true0.0true1.0);
    
HookConVarChange(hCvarOnTrailsChange);
    
g_Cvar_bTrails GetConVarBool(hCvar);
    
    
AutoExecConfig(true"VIP_ThrowingKnives""vip");

    
CloseHandle(hCvar);
    
    
LoadTranslations("vip_modules.phrases");

    
g_hThrownKnives CreateArray();

    
HookEvent("player_spawn",    Event_PlayerSpawn);
    
HookEvent("weapon_fire",    Event_WeaponFire);
    
HookEvent("player_death",    Event_PlayerDeathEventHookMode_Pre);
}


bool:Func_IsCSGO()
{
    if (
GetFeatureStatus(FeatureType_Native"GetEngineVersion") == FeatureStatus_Available)
    {
        return 
GetEngineVersion() == Engine_CSGO;
    }
    else if (
GetFeatureStatus(FeatureType_Native"GuessSDKVersion") == FeatureStatus_Available)
    {
        return 
GuessSDKVersion() == SOURCE_SDK_CSGO;
    }
    return 
false;
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max
{
    
MarkNativeAsOptional("GuessSDKVersion");
    
MarkNativeAsOptional("GetEngineVersion");

    return 
APLRes_Success
}

public 
OnStealChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])            g_Cvar_bSteal GetConVarBool(hCvar);
public 
OnVelocityChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])        g_Cvar_fVelocity GetConVarFloat(hCvar);
public 
OnDamageChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])            g_Cvar_fDamage GetConVarFloat(hCvar);
public 
OnHSDamageChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])        g_Cvar_fHSDamage GetConVarFloat(hCvar);
public 
OnModelScaleChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])        g_Cvar_fModelScale GetConVarFloat(hCvar);
public 
OnGravityChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])            g_Cvar_fGravity GetConVarFloat(hCvar);
public 
OnElasticityChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])        g_Cvar_fElasticity GetConVarFloat(hCvar);
public 
OnMaxLifeTimeChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])    g_Cvar_fMaxLifeTime GetConVarFloat(hCvar);
public 
OnTrailsChange(Handle:hCvar, const String:sOldValue[], const String:sNewValue[])            g_Cvar_bTrails GetConVarBool(hCvar);

public 
VIP_OnVIPLoaded()
{
    
VIP_RegisterFeature(VIP_TKINT);
}

public 
OnMapStart()
{
    
g_iTrailSprite PrecacheModel(g_bIsCSGO "effects/blueblacklargebeam.vmt":"sprites/bluelaser1.vmt");
    
g_iBloodDecal PrecacheDecal("sprites/blood.vmt");
}

public 
OnClientPutInServer(iClient)
{
    if(
IsClientSourceTV(iClient) == false && IsClientReplay(iClient) == false)
    {
        
SDKHookEx(iClientSDKHook_OnTakeDamageOnTakeDamage);
    }
}

public 
Action:OnTakeDamage(iVictim, &iAttacker, &inflictor, &Float:damage, &damagetype, &iWeaponFloat:fDamageForce[3], Float:fDamagePosition[3])
{
    new 
dmgtype g_bIsCSGO DMG_SLASH|DMG_NEVERGIB:DMG_BULLET|DMG_NEVERGIB;

    if(
inflictor <= MaxClients && inflictor == iAttacker && damagetype == dmgtype)
    {
        
g_bHeadshot[iAttacker] = false;

        if(
g_hTimerDelay[iAttacker] != INVALID_HANDLE)
        {
            
KillTimer(g_hTimerDelay[iAttacker]);
            
g_hTimerDelay[iAttacker] = INVALID_HANDLE;
        }
    }
}

public 
VIP_OnVIPClientLoaded(iClient)
{
    
g_iPlayerKniveCount[iClient] = VIP_GetClientFeatureInt(iClientVIP_TK);
}

public 
Event_PlayerSpawn(Handle:hEvent, const String:sEvName[], bool:bDontBroadcast)
{
    new 
iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
    if(
VIP_IsClientVIP(iClient) && VIP_IsClientFeatureUse(iClientVIP_TK))
    {
        
g_iPlayerKniveCount[iClient] = VIP_GetClientFeatureInt(iClientVIP_TK);
    }
}

public 
Action:Event_PlayerDeath(Handle:hEvent, const String:sEvName[], bool:bDontBroadcast)
{
    new 
iClient GetClientOfUserId(GetEventInt(hEvent"attacker"));
    if(
iClient && VIP_IsClientVIP(iClient) && VIP_IsClientFeatureUse(iClientVIP_TK))
    {
        
decl String:sWeapon[20];
        
GetEventString(hEvent"weapon"sWeaponsizeof(sWeapon));

        if(
StrContains(sWeapon"knife"false) != -|| strcmp(sWeapon"bayonet") == 0)
        {
            if(
g_Cvar_bSteal && g_iPlayerKniveCount[iClient] != -1)
            {
                new 
iVictim GetClientOfUserId(GetEventInt(hEvent"userid"));
                if(
g_iPlayerKniveCount[iVictim] > && g_iPlayerKniveCount[iVictim] != -1)
                {
                    
g_iPlayerKniveCount[iClient] += g_iPlayerKniveCount[iVictim];
                    
PrintHintText(iClient"%t: %i""ThrowingKnives"g_iPlayerKniveCount[iClient]);
                }
            }
            
            
SetEventBool(hEvent"headshot"g_bHeadshot[iClient]);
            
g_bHeadshot[iClient] = false;
        }
    }

    return 
Plugin_Continue;
}

public 
Event_WeaponFire(Handle:hEvent, const String:sEvName[], bool:bDontBroadcast)
{
    new 
iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
    if(
VIP_IsClientVIP(iClient) && VIP_IsClientFeatureUse(iClientVIP_TK) && (g_iPlayerKniveCount[iClient] > || g_iPlayerKniveCount[iClient] == -1))
    {
        
decl String:sWeapon[16];
        
GetEventString(hEvent"weapon"sWeaponsizeof(sWeapon));
    
//    LogMessage(sWeapon);

        
if(StrContains(sWeapon[7], "knife"false) != -|| strcmp(sWeapon[7], "bayonet") == 0)
        {
            
g_hTimerDelay[iClient] = CreateTimer(0.0CreateKnifeiClient);
        }
    }
}

public 
Action:CreateKnife(Handle:timerany:iClient)
{
    
g_hTimerDelay[iClient] = INVALID_HANDLE;
    if(
IsClientInGame(iClient))
    {
        new 
slot_knife GetPlayerWeaponSlot(iClientCS_SLOT_KNIFE);
        new 
iKnife CreateEntityByName("smokegrenade_projectile");
        if(
iKnife == -1)
        {
            return;
        }
        
        
DispatchKeyValue(iKnife"classname""throwing_knife");
        if(
DispatchSpawn(iKnife))
        {
            new 
iTeam GetClientTeam(iClient);
            
SetEntPropEnt(iKnifeProp_Send"m_hOwnerEntity"iClient);
            
SetEntPropEnt(iKnifeProp_Send"m_hThrower"iClient);
            
SetEntProp(iKnifeProp_Send"m_iTeamNum"iTeam);

            
decl String:sBuffer[PLATFORM_MAX_PATH];
            if(
slot_knife != -1)
            {
                
GetEntPropString(slot_knifeProp_Data"m_ModelName"sBuffersizeof(sBuffer));
                if(
ReplaceString(sBuffersizeof(sBuffer), "v_knife_""w_knife_"true) != 1)
                {
                    
sBuffer[0] = '\0';
                }
                else if(
g_bIsCSGO && ReplaceString(sBuffersizeof(sBuffer), ".mdl""_dropped.mdl"true) != 1)
                {
                    
sBuffer[0] = '\0';
                }
            }

            if(
FileExists(sBuffertrue) == false)
            {
                if(
g_bIsCSGO)
                {
                    switch(
iTeam)
                    {
                        case 
2:    strcopy(sBuffersizeof(sBuffer), "models/weapons/w_knife_default_t_dropped.mdl");
                        case 
3:    strcopy(sBuffersizeof(sBuffer), "models/weapons/w_knife_default_ct_dropped.mdl");
                    }
                }
                else
                {
                    
strcopy(sBuffersizeof(sBuffer), "models/weapons/w_knife_t.mdl");
                }
            }

            
SetEntProp(iKnifeProp_Send"m_nModelIndex"PrecacheModel(sBuffer));
            
SetEntPropFloat(iKnifeProp_Send"m_flModelScale"g_Cvar_fModelScale);
            
SetEntPropFloat(iKnifeProp_Send"m_flElasticity"g_Cvar_fElasticity);
            
SetEntPropFloat(iKnifeProp_Data"m_flGravity"g_Cvar_fGravity);

            
// Player fOrigin and fAngles
            
decl Float:fOrigin[3], Float:fAngles[3], Float:sPos[3], Float:fPlayerVelocity[3], Float:fVelocity[3];
            
GetClientEyePosition(iClientfOrigin);
            
GetClientEyeAngles(iClientfAngles);

            
// knive new spawn position and fAngles is same as player's
            
GetAngleVectors(fAnglessPosNULL_VECTORNULL_VECTOR);
            
ScaleVector(sPos50.0);
            
AddVectors(sPosfOriginsPos);

            
// knive flying direction and speed/power
            
GetEntPropVector(iClientProp_Data"m_vecVelocity"fPlayerVelocity);
            
GetAngleVectors(fAnglesfVelocityNULL_VECTORNULL_VECTOR);
            
ScaleVector(fVelocityg_Cvar_fVelocity);
            
AddVectors(fVelocityfPlayerVelocityfVelocity);

            
SetEntPropVector(iKnifeProp_Data"m_vecAngVelocity"Float:{4000.00.00.0});

            
// Stop grenade detonate and Kill knive after 1 - 30 sec
            
SetEntProp(iKnifeProp_Data"m_nNextThinkTick", -1);
            
Format(sBuffersizeof(sBuffer), "!self,Kill,,%0.1f,-1"g_Cvar_fMaxLifeTime);
            
DispatchKeyValue(iKnife"OnUser1"sBuffer);
            
AcceptEntityInput(iKnife"FireUser1");

            
// trail effect
            
if(g_Cvar_bTrails)
            {
                if(
g_bIsCSGO)
                {
                    
TE_SetupBeamFollow(iKnifeg_iTrailSprite00.51.00.10, {255255255255});
                }
                else
                {
                    
TE_SetupBeamFollow(iKnifeg_iTrailSprite00.58.01.00, {255255255255});
                }
                
TE_SendToAll();
            }

            
// Throw knive!
            
TeleportEntity(iKnifesPosfAnglesfVelocity);
            
SDKHookEx(iKnifeSDKHook_TouchKnifeHit);

            
PushArrayCell(g_hThrownKnivesEntIndexToEntRef(iKnife));
            if(
g_iPlayerKniveCount[iClient] != -1)
            {
                
g_iPlayerKniveCount[iClient]--;
                
PrintHintText(iClient"%t: %i""ThrowingKnives"g_iPlayerKniveCount[iClient]);
            }
        }
    }
}

public 
Action:KnifeHit(iKnifeiVictim)
{
    if(
iVictim <= MaxClients)
    {
        
SetVariantString("csblood");
        
AcceptEntityInput(iKnife"DispatchEffect");
        
AcceptEntityInput(iKnife"Kill");

        new 
iAttacker GetEntPropEnt(iKnifeProp_Send"m_hThrower");
        new 
inflictor GetPlayerWeaponSlot(iAttacker2);

        if(
inflictor == -1)
        {
            
inflictor iAttacker;
        }

        
decl Float:fVictimEye[3], Float:fDamagePosition[3], Float:fDamageForce[3];
        
GetClientEyePosition(iVictimfVictimEye);

        
GetEntPropVector(iKnifeProp_Data"m_vecOrigin"fDamagePosition);
        
GetEntPropVector(iKnifeProp_Data"m_vecVelocity"fDamageForce);

        if(
GetVectorLength(fDamageForce) != 0.0// iKnife movement stop
        
{
            new 
Float:distance GetVectorDistance(fDamagePositionfVictimEye);
            
g_bHeadshot[iAttacker] = distance <= 20.0;

            new 
dmgtype g_bIsCSGO DMG_SLASH|DMG_NEVERGIB:DMG_BULLET|DMG_NEVERGIB;

            if(
g_bHeadshot[iAttacker])
            {
                
dmgtype |= DMG_HEADSHOT;
            }

            
SDKHooks_TakeDamage(iVictiminflictoriAttacker,
            
g_bHeadshot[iAttacker] ? g_Cvar_fHSDamage:g_Cvar_fDamage,
            
dmgtypeiKnifefDamageForcefDamagePosition);

            
TE_SetupBloodSprite(fDamagePositionFloat:{0.00.00.0}, {25500255}, 1g_iBloodDecalg_iBloodDecal);
            
TE_SendToAll(0.0);

            new 
ragdoll GetEntPropEnt(iVictimProp_Send"m_hRagdoll");
            if(
ragdoll != -1)
            {
                
ScaleVector(fDamageForce50.0);
                
fDamageForce[2] = FloatAbs(fDamageForce[2]);
                
SetEntPropVector(ragdollProp_Send"m_vecForce"fDamageForce);
                
SetEntPropVector(ragdollProp_Send"m_vecRagdollVelocity"fDamageForce);
            }
        }
    }
    else if(
FindValueInArray(g_hThrownKnivesEntIndexToEntRef(iVictim)) != -1// ножи столкнулись
    
{
        
SDKUnhook(iKnifeSDKHook_TouchKnifeHit);
        
decl Float:sPos[3], Float:dir[3];
        
GetEntPropVector(iKnifeProp_Data"m_vecOrigin"sPos);
        
TE_SetupArmorRicochet(sPosdir);
        
TE_SendToAll(0.0);

        
DispatchKeyValue(iKnife"OnUser1""!self,Kill,,1.0,-1");
        
AcceptEntityInput(iKnife"FireUser1");
    }
}

public 
OnEntityDestroyed(entity)
{
    if(
IsValidEdict(entity))
    {
        new 
index FindValueInArray(g_hThrownKnivesEntIndexToEntRef(entity));
        if(
index != -1)
        {
            
RemoveFromArray(g_hThrownKnivesindex);
        }
    }


Last edited by hu3br; 11-01-2016 at 09:56.
hu3br is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-01-2016 , 10:45   Re: It's possible?
Reply With Quote #6

Try this custom_nades plugin, i haven't tested it but i fixed a few things that shouldn't have been in the plugin in the first place, also added a check for m_nNextThinkTick:
-snip-

Last edited by Mitchell; 11-01-2016 at 18:26.
Mitchell is offline
hu3br
Senior Member
Join Date: Apr 2015
Old 11-01-2016 , 11:29   Re: It's possible?
Reply With Quote #7

Quote:
Originally Posted by Mitchell View Post
Try this custom_nades plugin, i haven't tested it but i fixed a few things that shouldn't have been in the plugin in the first place, also added a check for m_nNextThinkTick:
Yes works fine now, thank you Mitchell !
hu3br is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-01-2016 , 12:32   Re: It's possible?
Reply With Quote #8

Try better topic title...
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Nursik
Senior Member
Join Date: Jul 2016
Location: In TF2
Old 11-01-2016 , 12:51   Re: It's possible?
Reply With Quote #9

Quote:
Originally Posted by KissLick View Post
Try better topic title...
+1
Nursik is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 11-01-2016 , 18:12   Re: It's possible?
Reply With Quote #10

Quote:
Originally Posted by Mitchell View Post
Try this custom_nades plugin, i haven't tested it but i fixed a few things that shouldn't have been in the plugin in the first place, also added a check for m_nNextThinkTick:
I use this for me and i give errors

PHP Code:
[SMException reportedProperty "m_nNextThinkTick" not found (entity 169/smokegrenade_projectile
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:12.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode