AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   velocity_by_aim (https://forums.alliedmods.net/showthread.php?t=128351)

maakera 05-31-2010 07:23

velocity_by_aim
 
i want it to add boost every time i press mouse 2 when holding a knife.
doesnt work :S
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <vector>
#include <engine>

#define PLUGIN "Knife Boost"
#define VERSION "1.0"
#define AUTHOR "Zibit"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("+attack2","Boost",ADMIN_KICK,"Allows boost if pressed mouse2")
    
// Add your code here...
}

public 
Boost(id)
{
new 
ClipAmmoWeapon get_user_weapon(idClipAmmo)
if ( 
Weapon == CSW_KNIFE ) {   
new 
Float:vRetValue[3]
velocity_by_aim id500vRetValue )
}



drekes 05-31-2010 08:20

Re: velocity_by_aim
 
You can't hook +attack2 and other original half-life + and - commands. There is a way to hook it through fakemeta though. Try to search a little.

NiHiLaNTh 05-31-2010 10:29

Re: velocity_by_aim
 
With this you can hook secondary attack of knife
Code:

public plugin_init ( )
{
    ...

    RegisterHam ( Ham_Weapon_SecondaryAttack, "weapon_knife", "Boost", 1 )
}


maakera 06-01-2010 16:09

Re: velocity_by_aim
 
hmm like this ?
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <vector>
#include <engine>
#include <hamsandwich>
#define PLUGIN "Knife Boost"
#define VERSION "1.0"
#define AUTHOR "Zibit"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam Ham_Weapon_SecondaryAttack"weapon_knife""Boost")
}

public 
Boost(id)
{
new 
ClipAmmoWeapon get_user_weapon(idClipAmmo
if ( 
Weapon == CSW_KNIFE ) {   
new 
Float:vRetValue[3]
velocity_by_aim id500vRetValue )
console_print id"Boost Used!" )
}



ConnorMcLeod 06-02-2010 02:12

Re: velocity_by_aim
 
No

Replace Boost( id ) with Boost( iKnife ), where iKnife is the entity index of the knife, then use private offset m_pPlayer to retrieve player id, and add velocity to him (you may also check if it's the first push of attack2)

This may help you : http://cs-sdk.googlecode.com/svn/trunk/wpn_knife.cpp

Also, you shoule make some research on hamsandwich, fakemeta, on how to use ham hooks and pdatas, before you start anything, else you will make lots of errors and you gonna loose lot of time.


All times are GMT -4. The time now is 05:24.

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