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
}
}
}
__________________