Raised This Month: $ Target: $400
 0% 

Execute function for each click


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 03-20-2011 , 10:23   Execute function for each click
Reply With Quote #1

Hey...
I have this in my code:
PHP Code:
public client_PreThink(id)
{
        if(
get_user_button(id) & IN_ATTACK)
        {
            
throw_kunai(id1)
        }

In game I press attack button and it works perfectly but while I'm pressing mouse1 it repeats the function throw_kunai and throw kunais like a machine gun...
How can I throw ONE kunai for each click?

EDIT: I've noticed now this isn't Scripting help -.- Move this please, and sorry ...
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 03-20-2011 , 13:03   Re: Execute function for each click
Reply With Quote #2

try it with pistol, they are not machine guns.

EDIT: and hook Ham_Weapon_PrimaryAttack
__________________

Working on:
nothing

Last edited by schmurgel1983; 03-20-2011 at 13:07.
schmurgel1983 is offline
kotinha
Senior Member
Join Date: Jun 2009
Location: Alentejo, Portugal :)
Old 03-20-2011 , 13:48   Re: Execute function for each click
Reply With Quote #3

With pistols I have to put infinite ammo and unblock pickup pistols... Since I'm a new at this it's better to make it simple
I tought that there was a function (or something else...) that would block it from repeat the function, if there isn't I'll just delay the process...
__________________
"If God exists, I hope he has a good excuse." - Woody Allen
kotinha is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-20-2011 , 13:57   Re: Execute function for each click
Reply With Quote #4

I'd recommend using FM_CmdStart instead of PreThink, but that's off-topic and I won't go into that.

However, you should use this:
Code:
if( ( get_user_buttons( id ) & IN_ATTACK ) && !( pev( id, pev_oldbuttons ) & IN_ATTACK ) ) {     throw_kunai( id, 1 ) }
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-20-2011 , 14:10   Re: Execute function for each click
Reply With Quote #5

Why do you recommand CmdStart ?

For unlimited ammo you can use method of one of following plugins :
Attached Files
File Type: sma Get Plugin or Get Source (infinite_ammo_light.sma - 498 views - 1.9 KB)
File Type: sma Get Plugin or Get Source (infinite_bpammo_light.sma - 444 views - 2.0 KB)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-20-2011 at 14:18.
ConnorMcLeod is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-20-2011 , 14:46   Re: Execute function for each click
Reply With Quote #6

I recommend it because using PreThink to hook when a player begins using IN_ATTACK is very inefficient.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-20-2011 , 15:14   Re: Execute function for each click
Reply With Quote #7

PostThink could be more efficient than CmdStart because it saves 1 native, and also it's a multiforward, else can do the same in PreThink POST (client_impulse is the engine CmdStart multiforward but it seems to be bugged) :

PHP Code:
#define XO_PLAYER 5
#define m_afButtonPressed 246

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
}

public 
client_PostThink(id)
{
    if( 
is_user_alive(id) && get_pdata_int(idm_afButtonPressedXO_PLAYER) & IN_ATTACK )
    {
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 14:40.


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