Raised This Month: $ Target: $400
 0% 

Shot event (Method)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-27-2013 , 10:13   Shot event (Method)
Reply With Quote #1

Hi all, i know if was this tutorial http://forums.alliedmods.net/showthread.php?t=54887
Writed by VEN.

But i see in old plugin a way to detect in other way, its counting bullets in weapon of a player.

Like this: https://forums.alliedmods.net/showthread.php?t=21342

Basically this code:

PHP Code:
#include <amxmodx>

new g_iLastWeap[33];
new 
g_iLastAmmo[33];

new 
g_iShots[33];

public 
plugin_init()
{
    
register_plugin("Fired",AMXX_VERSION_STR,"Amxx Dev Team");

    
register_event("CurWeapon","ev_CurWeapon","be","1=1","3>0");
}

public 
ev_CurWeapon(id)
{

    new 
iWeapon     read_data(2);
    new 
iAmmo     read_data(3);

    if(!
g_iLastWeap[id]) g_iLastWeap[id] = iWeapon;

    if((
g_iLastAmmo[id] > iAmmo) && (g_iLastWeap[id] == iWeapon)) g_iShots[id]++;
    
    
g_iLastAmmo[id] = iAmmo;
    
g_iLastWeap[id] = iWeapon;

    
client_print(id,print_chat,"* Shots: %d (Ammo remainder: %d) (Last Weapon: #%d)",g_iShots[id],g_iLastAmmo[id],g_iLastWeap[id]);

It is safe to used and correctly count shots fired?

EDIT: In my tests is not counting last bullet shot, Any suggestion?

Thanks.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 07-27-2013 at 10:49.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-27-2013 , 11:01   Re: Shot event (Method)
Reply With Quote #2

What are you trying to do?
Are you using X ammount of bullets in clip to trigger event or are you just retrieving the current bullets in clip?
You cant wrap your question in another question. You may be missing out on a good answer.
__________________
Black Rose is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-27-2013 , 11:30   Re: Shot event (Method)
Reply With Quote #3

Quote:
Originally Posted by Black Rose View Post
What are you trying to do?
Are you using X ammount of bullets in clip to trigger event or are you just retrieving the current bullets in clip?
You cant wrap your question in another question. You may be missing out on a good answer.
I tried to count shots based on CurWeapon event and clips, but is not counting last shot.
I think its the 3rd paramter, used in register_event.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-27-2013 , 11:51   Re: Shot event (Method)
Reply With Quote #4

You obviously misunderstood me. So you will get the answer you asked for, not the one you may need.
"3>0" is wrong. Parameter 3 is clip ammo. Just remove it and it will count the last shot.

Here you can read information about game events
http://wiki.amxmodx.org/Half-Life_1_...ents#CurWeapon
__________________

Last edited by Black Rose; 07-27-2013 at 11:52.
Black Rose is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-27-2013 , 12:36   Re: Shot event (Method)
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
You obviously misunderstood me. So you will get the answer you asked for, not the one you may need.
"3>0" is wrong. Parameter 3 is clip ammo. Just remove it and it will count the last shot.

Here you can read information about game events
http://wiki.amxmodx.org/Half-Life_1_...ents#CurWeapon
It is adding a one shot without really shot, i think its better add a 3!-1 for count zero.

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-27-2013 , 18:55   Re: Shot event (Method)
Reply With Quote #6

VEN's method is ok.
You can shorten it like this : http://forums.alliedmods.net/showthr...05#post1725505
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 07-28-2013 , 00:19   Re: Shot event (Method)
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
VEN's method is ok.
You can shorten it like this : http://forums.alliedmods.net/showthr...05#post1725505
Thanks, but the given code from my first post its working, it only use the 3rd paramter with 3!-1

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-28-2013 , 02:15   Re: Shot event (Method)
Reply With Quote #8

But you have more code to proceed in callback.
With VEN's method, you don't need to call any native in order to filter shots.

Difference is trivial, but there is still some ;)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-28-2013 at 02:16.
ConnorMcLeod is offline
r3p
BANNED
Join Date: Jul 2013
Old 07-30-2013 , 00:43   Re: Shot event (Method)
Reply With Quote #9

thanks McLonor i need to much
r3p is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-30-2013 , 01:05   Re: Shot event (Method)
Reply With Quote #10

other problem, other thread, are you new here ???
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 15:53.


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