Raised This Month: $32 Target: $400
 8% 

Solved Limited Map Zone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 08:59   Limited Map Zone
Reply With Quote #1

I'm using this modified code originally created by Natsheh, to create a zone that would slap users who are outside of it, but it just kills me instantly as soon as I type /create.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <xs>

new const g_szSprite[ ] = "sprites/laserbeam.spr";

new 
g_iSprite;

public 
plugin_init( )
{    
    
register_clcmd"say /create""@CreateZone" );
}

public 
plugin_precache( ) 

    
g_iSprite precache_modelg_szSprite ); 


@
CreateZoneid )
{
    new 
Float:fOrigin_Center]
    
pevidpev_originfOrigin_Center );
    
    const 
iDivide 128;
    new 
Float:fOrigin]
    
//new Float:fAngle[ 3 ], Float:AngleMulScalar = ( 360.0 / iDivide ), Float:fVector[ 3 ];
    //const Float:iRadius = 500.0;
    
    
new Array:aTempArray ArrayCreatesizeof fOrigin);
    
    for( new 
iiDividei++ )
    {
        
//angle_vector( fAngle, ANGLEVECTOR_RIGHT, fVector );
        //xs_vec_mul_scalar( fVector, iRadius, fVector );
        //xs_vec_add( fOrigin_Center, fVector, fOrigin );
        
        
ArrayPushArrayaTempArrayfOrigin );
        
        
//fAngle[ 1 ] += AngleMulScalar;
        
CreateWallfOrigin /*,fAngle*/ );
    }
    
    new 
szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"ach" );
    
    for( new 
iFloat:fUserOrigin]; iNumi++ )
    {
        
iTempID szPlayers];
        
peviTempIDpev_originfUserOrigin );
        
        for( new 
xArraySizeaTempArray ); x++ )
        {
            
ArrayGetArrayaTempArrayxfOrigin );
            
            if( 
fUserOrigin] < fOrigin] || fUserOrigin] < fOrigin] ||
                    
fUserOrigin] > fOrigin] || fUserOrigin] < fOrigin] )
            {
                
user_slapiTempIDrandom_num210 ) )
            }
        }
    }
    
    
ArrayDestroyaTempArray );
}

CreateWallFloat:fOrigin]/*, Float:fAngle[ 3 ]*/)
{  
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_BEAMPOINTS )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordGetMaxHeight( ) )
    
write_shortg_iSprite 
    
write_byte
    
write_byte
    
write_byte10 
    
write_byte60 
    
write_byte
    
write_byte255 )
    
write_byte)
    
write_byte)
    
write_byte127 )
    
write_byte)
    
message_end( );
}  

Float:GetMaxHeight( )

    new  
pcCurrent;
    new 
Float:fStartPoint];
    
    while ( ( 
engfuncEngFunc_PointContents fStartPoint ) == CONTENTS_EMPTY ) || (  engfuncEngFunc_PointContents fStartPoint ) == CONTENTS_SOLID ) )
    {
        
fStartPoint] += 5.0
    }
    
    
pcCurrent engfuncEngFunc_PointContents fStartPoint ); 

    if( 
pcCurrent == CONTENTS_SKY )
    {
        return 
fStartPoint] -= 20.0;
    }
    return 
0.0

__________________

Last edited by edon1337; 07-29-2018 at 17:04.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-29-2018 , 09:19   Re: Limited Map Zone
Reply With Quote #2

I think you should break after user_slap, probably it keeps slapping the player until he dies. Maybe you can use a task to periodically slap the player while he's in the zone.
__________________

Last edited by HamletEagle; 07-29-2018 at 09:19.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 09:27   Re: Limited Map Zone
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
I think you should break after user_slap, probably it keeps slapping the player until he dies. Maybe you can use a task to periodically slap the player while he's in the zone.
Yea thanks I'm not dying instantly now, still no beam appears, am I setting it wrong?
__________________

Last edited by edon1337; 07-29-2018 at 12:55.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-29-2018 , 09:27   Re: Limited Map Zone
Reply With Quote #4

Code:
if( fUserOrigin[ 0 ] < fOrigin[ 0 ] || fUserOrigin[ 0 ] < fOrigin[ 0 ] ||
                    fUserOrigin[ 1 ] > fOrigin[ 1 ] || fUserOrigin[ 1 ] < fOrigin[ 1 ] )
Why that code checks same thing twice
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
Old 07-29-2018, 09:29
edon1337
This message has been deleted by edon1337.
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 12:45   Re: Limited Map Zone
Reply With Quote #5

I made something but it slaps me when I'm close to the beams, like, I'm within the radius but stay close to them, it slaps me. Also when I'm in the radius but in the sky.

PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < xs >

new const g_szSprite[ ] = "sprites/laserbeam.spr";

new 
g_iSprite;

public 
plugin_init( )
{
    
register_clcmd"say /sphere""OnSphere" );
    
register_clcmd"say /remove""OnRemove" );
}

public 
plugin_precache( ) 

    
g_iSprite precache_modelg_szSprite ); 



public 
OnSphereid )
{
    
set_task1.0"RenewSphere"666, .flags="b" );
}

public 
OnRemoveid )
{
    
remove_task666 );
}

public 
RenewSphere( )
{
    new 
Float:fOrigin_Center[3] = {-8.5, -0.0, -487.4};
    const 
divides 128
    new 
Float:fOrigin[3];
    new 
Float:fAngle[3], Float:AngleMulScalar = (360.0 divides), Float:fVector[3];
    const 
Float:Radius 2000.0;
    
    for(new 
idividesi++)
    {
        
angle_vector(fAngleANGLEVECTOR_RIGHTfVector);
        
xs_vec_mul_scalar(fVectorRadiusfVector);
        
xs_vec_add(fOrigin_CenterfVectorfOrigin);
        
        
CreateBeamfOrigin );
        
        
fAngle[1] += AngleMulScalar;
    }

    
// check if other players are out and slap them.
    
new ent = -1players[32], pnumignore[33];
    while( (
ent engfunc(EngFunc_FindEntityInSphereentfOrigin_CenterRadius)) > 0)
    {
        if(
is_user_alive(ent))
        {
            
ignore[ent] = true;
        }
    }

    
get_players(players,pnum,"a")
    for(new 
i,playerpnumi++)
    {
        
player players[i];
        if(
ignore[player]) continue;

        
user_slap(playerrandom_num(2,10));
    }  
}

CreateBeamFloat:fOrigin] )
{  
    
message_beginMSG_BROADCASTSVC_TEMPENTITY )
    
write_byteTE_BEAMPOINTS )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoordfOrigin] )
    
engfuncEngFunc_WriteCoord4000.0 )
    
write_shortg_iSprite 
    
write_byte
    
write_byte
    
write_byte30 
    
write_byte60 
    
write_byte
    
write_byte255 )
    
write_byte)
    
write_byte)
    
write_byte127 )
    
write_byte)
    
message_end( );

__________________

Last edited by edon1337; 07-29-2018 at 13:21.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-29-2018 , 14:53   Re: Limited Map Zone
Reply With Quote #6

Quote:
Originally Posted by edon1337 View Post
Also when I'm in the radius but in the sky.
Yes cause it is checking origins in all three dimensions and if length is higher than radius it will slap

PS: What is the point of setting tasks with such ids
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 15:16   Re: Limited Map Zone
Reply With Quote #7

Quote:
Originally Posted by Ghosted View Post
Yes cause it is checking origins in all three dimensions and if length is higher than radius it will slap
Yes, I figured as much, but there's something else, I don't know whether it's a normal thing or a miscalculation of the game:

It will be hard to understand, so make sure you read this twice:
- If I set the center origin of the zone in a high place, when you go close to the beams at the same height, you will get slapped as soon as you exceed the area, which is fine, but, if you go on a lower place, you'll get slapped even before touching the beam, is this a normal thing?

Something like this
__________________

Last edited by edon1337; 07-29-2018 at 15:23.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-29-2018 , 15:58   Re: Limited Map Zone
Reply With Quote #8

Quote:
Originally Posted by edon1337 View Post
Yes, I figured as much, but there's something else, I don't know whether it's a normal thing or a miscalculation of the game:

It will be hard to understand, so make sure you read this twice:
- If I set the center origin of the zone in a high place, when you go close to the beams at the same height, you will get slapped as soon as you exceed the area, which is fine, but, if you go on a lower place, you'll get slapped even before touching the beam, is this a normal thing?

Something like this
Thats when you checking height in length too (FIND ENT IN SPHERE Does That), if you don't want then it must be coded manually and distance will be calculated with SquareRootOf(Origin[0] * Origin[0] + Origin[1] * Origin[1])

EDIT

it will be like:

while (ent = find_ent_by_classname(ent, "player"))
{
// get user origin
// create origin which will be : playerOrigin - centerOrigin
// calculate its 2D length with that formula
// check if it is higher than ur radius
}
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 07-29-2018 at 16:01.
Ghosted is offline
Old 07-29-2018, 16:00
edon1337
This message has been deleted by edon1337.
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-29-2018 , 16:07   Re: Limited Map Zone
Reply With Quote #9

Wouldn't saving every beams origin when it is created and then checking with a task work?
PHP Code:
get_distance_f(PlayerOriginBeamOrigin) <= 0.0
__________________

Last edited by edon1337; 07-29-2018 at 16:07.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-29-2018 , 16:12   Re: Limited Map Zone
Reply With Quote #10

Quote:
Originally Posted by edon1337 View Post
Wouldn't saving every beams origin when it is created and then checking with a task work?
PHP Code:
get_distance_f(PlayerOriginBeamOrigin) <= 0.0
(4got get_distance) get_distance_f is same thing as i said there, just check distance between center origin and player and if its higher than radius slap him. Why you need to check with beams, this one is way smooth
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted 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 01:42.


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