AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [SNIPPET] Wicked Nades (https://forums.alliedmods.net/showthread.php?t=222819)

zipcore 08-06-2013 21:24

[SNIPPET] Wicked Nades
 
Give nades random direction depending on players movement speed:fox:

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;



noodleboy347 08-09-2013 12:42

Re: [SNIPPET] Wicked Nades
 
What's with the timer

thetwistedpanda 08-09-2013 12:53

Re: [SNIPPET] Wicked Nades
 
OnEntityCreated may have been too early to modify the speed. OnEntitySpawn would have worked as an alternative to a timer though, if memory serves.

zipcore 08-09-2013 19:26

Re: [SNIPPET] Wicked Nades
 
Quote:

Originally Posted by thetwistedpanda (Post 2009382)
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

Despirator 08-10-2013 07:25

Re: [SNIPPET] Wicked Nades
 
1 Attachment(s)
code using sdkhooks

zipcore 08-11-2013 08:49

Re: [SNIPPET] Wicked Nades
 
Quote:

Originally Posted by Despirator (Post 2009881)
code using sdkhooks

rofl, but gj^^

API 08-16-2013 13:29

Re: [SNIPPET] Wicked Nades
 
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."

Powerlord 08-23-2013 11:39

Re: [SNIPPET] Wicked Nades
 
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.

zipcore 08-25-2013 05:39

Re: [SNIPPET] Wicked Nades
 
Quote:

Originally Posted by pimpinjuice (Post 2014712)
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.


All times are GMT -4. The time now is 07:00.

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