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

[SNIPPET] Wicked Nades


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 08-06-2013 , 21:24   [SNIPPET] Wicked Nades
Reply With Quote #1

Give nades random direction depending on players movement speed

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <smlib>

public OnEntityCreated(entity, const String:classname[])
{
if (
StrEqual(classname"hegrenade_projectile"))
{
CreateTimer(0.0Timer_RandomentityTIMER_FLAG_NO_MAPCHANGE);
}

if (
StrEqual(classname"flashbang_projectile"))
{
CreateTimer(0.0Timer_RandomentityTIMER_FLAG_NO_MAPCHANGE);
}

if (
StrEqual(classname"smokegrenade_projectile"))
{
CreateTimer(0.0Timer_RandomentityTIMER_FLAG_NO_MAPCHANGE);
}
}

public 
Action:Timer_Random(Handle:Timerany:entity)
{
if(
IsValidEntity(entity))
{
new 
client GetEntPropEnt(entityProp_Send"m_hOwnerEntity");

decl Float:fVelp[3];
new 
Float:currentspeed;

new 
Float:RandomMult;

if(
Client_IsValid(clienttrue))
{
Entity_GetAbsVelocity(clientfVelp);
currentspeed SquareRoot(Pow(fVelp[0],2.0)+Pow(fVelp[1],2.0));

RandomMult currentspeed+1.0 2.0;
}

decl Float:fVeln[3];
Entity_GetAbsVelocity(entityfVeln);

fVeln[1] += GetRandomFloat(RandomMult*(-1.0), RandomMult);
fVeln[0] += GetRandomFloat(RandomMult*(-1.0), RandomMult);

TeleportEntity(entityNULL_VECTORNULL_VECTORfVeln);
}
return 
Plugin_Handled;

__________________

Last edited by asherkin; 01-14-2015 at 20:03.
zipcore is offline
noodleboy347
AlliedModders Donor
Join Date: Mar 2009
Old 08-09-2013 , 12:42   Re: [SNIPPET] Wicked Nades
Reply With Quote #2

What's with the timer
noodleboy347 is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-09-2013 , 12:53   Re: [SNIPPET] Wicked Nades
Reply With Quote #3

OnEntityCreated may have been too early to modify the speed. OnEntitySpawn would have worked as an alternative to a timer though, if memory serves.
__________________
thetwistedpanda is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 08-09-2013 , 19:26   Re: [SNIPPET] Wicked Nades
Reply With Quote #4

Quote:
Originally Posted by thetwistedpanda View Post
OnEntityCreated may have been too early to modify the speed. OnEntitySpawn would have worked as an alternative to a timer though, if memory serves.
correct
__________________
zipcore is offline
Despirator
Senior Member
Join Date: Jun 2011
Location: Kazakhstan ->Shymkent
Old 08-10-2013 , 07:25   Re: [SNIPPET] Wicked Nades
Reply With Quote #5

code using sdkhooks
Attached Files
File Type: sp Get Plugin or Get Source (wicked_nades.sp - 215 views - 918 Bytes)
Despirator is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 08-11-2013 , 08:49   Re: [SNIPPET] Wicked Nades
Reply With Quote #6

Quote:
Originally Posted by Despirator View Post
code using sdkhooks
rofl, but gj^^
__________________
zipcore is offline
API
Veteran Member
Join Date: May 2006
Old 08-16-2013 , 13:29   Re: [SNIPPET] Wicked Nades
Reply With Quote #7

What is so funny about using SDKHooks? The timer you have is laughable.

EDIT: Also, your signature should read: "I can do plugins for a fair price. PM me."
__________________

Last edited by API; 08-16-2013 at 13:30.
API is offline
Send a message via AIM to API
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-23-2013 , 11:39   Re: [SNIPPET] Wicked Nades
Reply With Quote #8

Your original code is missing a dependency on SDKHooks. Since SDKHooks provides the OnEntityCreated callback, it won't work if SDKHooks isn't on the server.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 08-25-2013 , 05:39   Re: [SNIPPET] Wicked Nades
Reply With Quote #9

Quote:
Originally Posted by pimpinjuice View Post
What is so funny about using SDKHooks? The timer you have is laughable.

EDIT: Also, your signature should read: "I can do plugins for a fair price. PM me."
I was laughing about this huge demand. And it's a timer because we were starting with a repeating timer to change mutiple times direction etc. anyway we never usered this but we had much fun to see this 1 time.
__________________
zipcore is offline
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 07:19.


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