AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   why this not work? (https://forums.alliedmods.net/showthread.php?t=331702)

LondoN 04-02-2021 19:25

why this not work?
 
i used a simple logic for getting player position in the map (upward) and slay if they are on a position up than a range. but didn't work, any solution or other method?

Code:

#include < amxmodx >
#include < amxmisc >
#include < engine >
#include < hamsandwich >

#define Y_AXIS_MAX                50
#define TASK_CHECK_ORIGIN        2932
#define ID_ORIGIN        (taskid - TASK_CHECK_ORIGIN)

new g_EntityOrigin [ 33 ] [ 3 ];

public plugin_init ( )        RegisterHam ( Ham_Spawn, "player", "OnPlayerSpawnPost", 1 );
public client_death ( iEntity, iVictim, ShouldGIB )        if ( task_exists ( iVictim + TASK_CHECK_ORIGIN ) ) remove_task ( iVictim + TASK_CHECK_ORIGIN );
public OnPlayerSpawnPost ( iEntity ) {
        if ( is_user_connected ( iEntity ) && is_user_alive ( iEntity ) ) {
                get_user_origin ( iEntity, g_EntityOrigin [ iEntity ] );
                set_task ( 25.0, "CheckOrigin", iEntity + TASK_CHECK_ORIGIN, .flags="b" );
        }
}

public CheckOrigin ( taskid ) {
        new iEntity = ID_ORIGIN;
        new iCurrentEntityOrigin [ 3 ];
        get_user_origin ( iEntity, iCurrentEntityOrigin );

        /*
        X - Determines your position East/West in the map. A positive value increases your position to the East. ...
        Y - Determines your position up/down in the map. A positive value increases your position upward. ...
        Z - Determines your position South/North in the map.
        */

        if ( iCurrentEntityOrigin [ 1 ] - g_EntityOrigin [ iEntity ] [ 1 ] >= Y_AXIS_MAX )
                user_silentkill ( iEntity );
}


Bugsy 04-02-2021 19:46

Re: why this not work?
 
1. Dont code like that, it kills readability.

2. Change

new iEntity = taskid

to

new iEntity = taskid - TASK_CHECK_ORIGIN;

LondoN 04-04-2021 02:00

Re: why this not work?
 
Quote:

Originally Posted by Bugsy (Post 2742800)
1. Dont code like that, it kills readability.

2. Change

new iEntity = taskid

to

new iEntity = taskid - TASK_CHECK_ORIGIN;

Code:

#define ID_ORIGIN        (taskid - TASK_CHECK_ORIGIN)
Code:

new iEntity = ID_ORIGIN;
i can't understand why isn't working. distance from the ground (spawnpoint) must be in the range (curentorigin-spawnorigin >= max_range in air, then slay

JocAnis 04-04-2021 06:48

Re: why this not work?
 
From when is [ 1 ] axis for vertical distance? Use [ 2 ] / z

Also:
Quote:

Originally Posted by Bugsy (Post 2742800)
1. Dont code like that, it kills readability.



All times are GMT -4. The time now is 02:56.

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