Raised This Month: $ Target: $400
 0% 

Shot event (Method)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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:52.


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