Raised This Month: $32 Target: $400
 8% 

[TF2] Making Syringe projectile shoot straight?


Post New Thread Reply   
 
Thread Tools Display Modes
nergal
Veteran Member
Join Date: Apr 2012
Old 02-01-2014 , 22:50   Re: [TF2] Making Syringe projectile shoot straight?
Reply With Quote #11

Quote:
Originally Posted by Chdata View Post
entity == tf_projectile_syringe

Won't work, GetEntityClassName then check if it's "tf_projectile_syringe"

You could probably get away with

(s[15] == 'y')

ahhh I see.

how does this come out?

PHP Code:
public OnEntityCreated(entity, const String:classname[]) //syringe gun redo
{
    if (
StrEqual(classname"CTFProjectile_Syringe"false))
        if (
StrEqual(entity"tf_projectile_syringe"false))
            
SDKHook(entitySDKHook_SpawnHook_EntitySpawned);
}
public 
Hook_EntitySpawned(entity)
{
    new 
String:Entname[32];
    if (
IsValidEdict(entity)) GetEntityClassname(entityEntnamesizeof(Entname));
      if (
StrEqual(entity"tf_projectile_syringe"false) && IsValidEntity(entity))
        
SetEntityGravity(Entname0.1);

__________________

Last edited by nergal; 02-01-2014 at 22:53.
nergal is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 02-01-2014 , 23:15   Re: [TF2] Making Syringe projectile shoot straight?
Reply With Quote #12

"entity" is not a string. It is the ent index of the entity. It's a number, ranging anywhere from MaxClients+1 to 4096 (right?)


PHP Code:
public OnEntityCreated(entity, const String:classname[]) //syringe gun redo
{
    if (
StrEqual(classname"tf_projectile_syringe"false))
        
SDKHook(entitySDKHook_SpawnHook_SyringeSpawned);
}
public 
Hook_SyringeSpawned(syringe)
{
    if (
IsValidEntity(syringe)) //this check might not be necessary, but I don't know enough about SDKHooks to say for certain
        
SetEntityGravity(syringe0.1);

There is no need to check the entity's validness multiple times. Also, you cannot SetEntityGravity on a string, only on entities.

Also, I don't know how well setting the gravity to 0.1 would work. You might want to replace SetEntityGravity with the movetype suggestion above.
__________________

Last edited by ddhoward; 02-01-2014 at 23:27.
ddhoward is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-02-2014 , 01:00   Re: [TF2] Making Syringe projectile shoot straight?
Reply With Quote #13

Quote:
Originally Posted by ddhoward View Post
"entity" is not a string. It is the ent index of the entity. It's a number, ranging anywhere from MaxClients+1 to 4096 (right?)


PHP Code:
public OnEntityCreated(entity, const String:classname[]) //syringe gun redo
{
    if (
StrEqual(classname"tf_projectile_syringe"false))
        
SDKHook(entitySDKHook_SpawnHook_SyringeSpawned);
}
public 
Hook_SyringeSpawned(syringe)
{
    if (
IsValidEntity(syringe)) //this check might not be necessary, but I don't know enough about SDKHooks to say for certain
        
SetEntityGravity(syringe0.1);

There is no need to check the entity's validness multiple times. Also, you cannot SetEntityGravity on a string, only on entities.

Also, I don't know how well setting the gravity to 0.1 would work. You might want to replace SetEntityGravity with the movetype suggestion above.

I didn't set entity as a string when i tested out, but thanks for all the help guys; I shall return with the results.
__________________
nergal is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 02-02-2014 , 09:04   Re: [TF2] Making Syringe projectile shoot straight?
Reply With Quote #14

I think in most cases you should unhook after using hookspawn, or it can cause problems //fire again, atleast it has for me in the past. Also, tis a lie about returning plugin handled from it, that crashes my server errytime.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Reply



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 21:54.


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