| xeroblood |
03-07-2005 16:41 |
Quote:
Originally Posted by TotalNoobScripter
couldnt prethink be executed many times before a bullet is launched?
or does prethink execute the same speed as how fast the bullets fire from the gun at full-auto?
If it was faster than the full-auto rate, then my code will be acting as if someone shot 2 bullets instead of 1.
|
Didn't you at least try what I mentioned?? Maybe it will work!! :P
If it doesnt work, as Avalanche stated, try this:
Code:
#define MAX_PLAYERS 32
// Tracks players Shots-Fired: [0]=WeaponID, [1]=Ammo
new g_nCurWeapon[MAX_PLAYERS][2]
public plugin_init()
{
register_event( "CurWeapon", "Event_ShotFired", "b" )
}
public Event_ShotFired( id )
{
// Players current weapon data..
new weaponID = read_data( 2 )
new wAmmo = read_data( 3 )
if( g_nCurWeapon[id-1][0] != weaponID ) // User Changed Weapons..
{
g_nCurWeapon[id-1][0] = weaponID
g_nCurWeapon[id-1][1] = wAmmo
return PLUGIN_CONTINUE
}
if( g_nCurWeapon[id-1][1] < wAmmo ) // User Reloaded..
{
g_nCurWeapon[id-1][1] = wAmmo
return PLUGIN_CONTINUE
}
if( g_nCurWeapon[id-1][1] == wAmmo ) // User did something else, but didn't shoot..
return PLUGIN_CONTINUE
// This far means user shot his/her gun..
// Save new weapon data..
g_nCurWeapon[id-1][1] = wAmmo
g_nCurWeapon[id-1][0] = weaponID
// Now you can do stuff, like:
// Get the origin of weapon hit-point
new nPoint[3]
get_user_origin( id, nPoint, 3 )
// blah blah blah...
return PLUGIN_CONTINUE
}
I used that method in my Proximity Mines Plugin...
Or, even still, you could simply Flag the First method I mentioned (with client_prethink) and essentially track how many times it is actually called, then just use some simple logic to execute code on the first occurence only..
|