Raised This Month: $ Target: $400
 0% 

get_user_hitzones error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
m0v3
Member
Join Date: May 2009
Old 08-10-2009 , 05:54   get_user_hitzones error
Reply With Quote #1

Hi.

I can't get user hitzones in a right way , and I don't understand what's not right... for example
Code:
new hitzones = get_user_hitzones ( id , 0 )
This ends for an error message
Code:
[FUN] Player out of range (0)
. What could be wrong ? When I write in this way
Code:
new hitzones = get_user_hitzones ( id , 2 )
, everything is fine , hitzones are shown in the way they are. Can anyone help... ?

Regards
m0v3 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-10-2009 , 05:54   Re: get_user_hitzones error
Reply With Quote #2

Show more code
__________________
xPaw is offline
m0v3
Member
Join Date: May 2009
Old 08-10-2009 , 05:58   Re: get_user_hitzones error
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say show" "xp_rod" )


}

public 
xp_rod(id) {
     
    new 
hitzones get_user_hitzonesid )
    
    
client_print(0,print_chat,"Hitzonos - %i "hitzones )
    return 
PLUGIN_HANDLED
    


Last edited by m0v3; 08-10-2009 at 06:22.
m0v3 is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 08-10-2009 , 12:46   Re: get_user_hitzones error
Reply With Quote #4

You need to get a target. 0 is invalid.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 08-10-2009 , 18:24   Re: get_user_hitzones error
Reply With Quote #5

maybe new victim = read_data(2) ?? id realy know what he want to do
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
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
m0v3
Member
Join Date: May 2009
Old 08-11-2009 , 11:48   Re: get_user_hitzones error
Reply With Quote #7

Yeach , this is true if I want to get hitzones of a specific player to a specific player. But even the get_user_hitzones description tells :
Quote:
To get what bodyparts a player can hit when firing, set the player's index to index and target to 0.
Why doesn't that work ? I know I can loop through all the players , and in Exolent[jNr]'s way I'll get what bodyparts client can hit on each of playing users. But if all the results are the same as I can have set
PHP Code:
set_user_hitzonesclient 
, then it would be better for me just to get if I have set the hitzones specific , or they are default. Your solution is much longer than just one command, so I'm wondering why it isn't working , if description tells it should ?

Last edited by m0v3; 08-11-2009 at 12:00.
m0v3 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-11-2009 , 15:55   Re: get_user_hitzones error
Reply With Quote #8

Quote:
Originally Posted by m0v3 View Post
Yeach , this is true if I want to get hitzones of a specific player to a specific player. But even the get_user_hitzones description tells : Why doesn't that work ? I know I can loop through all the players , and in Exolent[jNr]'s way I'll get what bodyparts client can hit on each of playing users. But if all the results are the same as I can have set
PHP Code:
set_user_hitzonesclient 
, then it would be better for me just to get if I have set the hitzones specific , or they are default. Your solution is much longer than just one command, so I'm wondering why it isn't working , if description tells it should ?
If you used set_user_hitzones( client, 0, ( hitzones ) ), then you can still use my code.
You still have to supply a target to get_user_hitzones( ) because it checks if it is a player.

Code:
public MyFunction( client ) {     new iHitzones;     for( new iTarget = 1; iTarget <= g_iMaxPlayers; iTarget++ )     {         if( is_user_connected( iTarget ) )         {             iHitzones = get_user_hitzones( client, iTarget );                         break;         }     }         // iHitzones = body parts where client can hit other players     // Note: This is only true for all targets IF you used 0 as target in set_user_hitzones( ) }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
m0v3
Member
Join Date: May 2009
Old 08-12-2009 , 05:08   Re: get_user_hitzones error
Reply With Quote #9

Thank you , I think I'll use this method , it will be faster than trying to get that command work as it should
m0v3 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 18:22.


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