AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_hitzones error (https://forums.alliedmods.net/showthread.php?t=99859)

m0v3 08-10-2009 05:54

get_user_hitzones error
 
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

xPaw 08-10-2009 05:54

Re: get_user_hitzones error
 
Show more code

m0v3 08-10-2009 05:58

Re: get_user_hitzones error
 
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
    



AntiBots 08-10-2009 12:46

Re: get_user_hitzones error
 
You need to get a target. 0 is invalid.

One 08-10-2009 18:24

Re: get_user_hitzones error
 
maybe new victim = read_data(2) ?? id realy know what he want to do :D

Exolent[jNr] 08-10-2009 19:28

Re: get_user_hitzones error
 
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         }     } }

m0v3 08-11-2009 11:48

Re: get_user_hitzones error
 
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 ?

Exolent[jNr] 08-11-2009 15:55

Re: get_user_hitzones error
 
Quote:

Originally Posted by m0v3 (Post 896398)
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( ) }

m0v3 08-12-2009 05:08

Re: get_user_hitzones error
 
Thank you , I think I'll use this method , it will be faster than trying to get that command work as it should :)


All times are GMT -4. The time now is 18:22.

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