Raised This Month: $ Target: $400
 0% 

get_user_hitzones error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-10-2009 , 19:28   Re: get_user_hitzones error
Reply With Quote #6

From fun.cpp:
Code:
static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_user_hitzones(index = 0, target = 0, body = 255); = 3 arguments
{
	// Sets user hitzones.
	// params[1] = the one(s) who shoot(s), shooter
	int shooter = params[1];

	// params[2] = the one getting hit
	int gettingHit = params[2];

	// params[3] = specified hit zones
	int hitzones = params[3];

	//set_user_hitzones(id, 0, 0) // Makes ID not able to shoot EVERYONE - id can shoot on 0 (all) at 0
	//set_user_hitzones(0, id, 0) // Makes EVERYONE not able to shoot ID - 0 (all) can shoot id at 0
	if (shooter == 0 && gettingHit == 0) {
		for (int i = 1; i <= gpGlobals->maxClients; i++) {
			for (int j = 1; j <= gpGlobals->maxClients; j++) {
				g_bodyhits[i][j] = hitzones;
			}
			//g_zones_toHit[i] = hitzones;
			//g_zones_getHit[i] = hitzones;
		}
	}
	else if (shooter == 0 && gettingHit != 0) {
		// "All" shooters, target (gettingHit) should be existing player id
		CHECK_PLAYER(gettingHit);
		// Where can all hit gettingHit?
		for (int i = 1; i <= gpGlobals->maxClients; i++)
			g_bodyhits[i][gettingHit] = hitzones;
	}
	else if (shooter != 0 && gettingHit == 0) {
		// Shooter can hit all in bodyparts.
		CHECK_PLAYER(shooter);
		for (int i = 1; i <= gpGlobals->maxClients; i++)
			g_bodyhits[shooter][i] = hitzones;
	}
	else {
		// Specified, where can player A hit player B?
		CHECK_PLAYER(shooter);
		CHECK_PLAYER(gettingHit);
		g_bodyhits[shooter][gettingHit] = hitzones;
	}

	return 1;
}

static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_user_hitzones(index, target); = 2 arguments
{
	int shooter = params[1];
	CHECK_PLAYER(shooter);
	int target = params[2];
	CHECK_PLAYER(target);
	return g_bodyhits[shooter][target];
}
set_user_hitzones( player, target, hitzones );

When using 0 for player or target, it loops through all players to set the value.

Therefore, if you set the hitzones like this:
Code:
public MyFunction( client ) {     set_user_hitzones( client, 0, 0 ); }

Then you can get them like this:
Code:
new g_iMaxPlayers; public plugin_init( ) {     g_iMaxPlayers = get_maxplayers( ); } public MyFunction( client ) {     new iHitzone;     for( new iTarget = 1; iTarget <= g_iMaxPlayers; iTarget++ )     {         if( is_user_connected( iTarget ) )         {             iHitzone = get_user_hitzones( client, iTarget );                         // code here         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
 



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 18:22.


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