AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Radius [Still need help] (https://forums.alliedmods.net/showthread.php?t=163330)

usaexelent 07-29-2011 06:26

Radius [Still need help]
 
How can i find every player id in my setted origin?
find_ent_in_sphere - I don't know how to use this

Exolent[jNr] 07-29-2011 10:58

Re: Radius
 
Code:
// set starting entity new ent = -1; // this is the center of the sphere that you want to check around new Float:origin[3]; // the maximum distance away from the origin new Float:radius = 100.0; while((ent = find_ent_in_sphere(ent, origin, radius))) {     // ent is inside "radius" distance to "origin" }

usaexelent 07-29-2011 15:23

Re: Radius
 
So how can do that when you shoot lightning, on the end origin would be a blast radius?

This is my code:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new g_Beam
new g_Explode

public plugin_precache()
{
    
g_Beam precache_model("sprites/laserbeam.spr")
    
g_Explode precache_model("sprites/zerogxplode-big2.spr")
}
public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("laser""lasershoot")
}


public 
lasershoot(id)
{
    if(
task_exists(id))
    {
    
remove_task(id)    
    }
    new 
originEnd[3]
    new 
origin[3]
    
get_user_origin(id,origin,0)
    
    
get_user_origin(id,originEnd,3)
    new 
EntIdBodypart
    get_user_aiming
(id,EntId,Bodypart)
    
    if(
is_user_connected(EntId))
    {
    new 
VictimOrigin[3]
    
get_user_origin(id,VictimOrigin,0)
    
    if(
Bodypart == HIT_HEAD)
    {
        if(
get_user_health(id) > 50)
        {
        
set_user_health(EntId,get_user_health(EntId)-50)
        }
        else
        {
        
set_user_health(EntId,0)
        
message_begin(MSG_ALLget_user_msgid("DeathMsg"), {0,0,0}, 0);
        
write_byte(id);
        
write_byte(EntId);
        
write_byte(0);
        
write_string("1");
        
message_end();
        }
    }
    else
    {
    
    if(
get_user_health(id) > 10)
        {
        
ExecuteHamB(Ham_TakeDamageidinflictorattackerFloat:damagedamagebits); 
        }
        else
        {
        
set_user_health(EntId,0)
        
message_begin(MSG_ALLget_user_msgid("DeathMsg"), {0,0,0}, 0);
        
write_byte(id);
        
write_byte(EntId);
        
write_byte(0);
        
write_string("");
        
message_end();
        }
    
    }
}
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMPOINTS)
    
// this is where the beginning of the beam is
    
write_coord(origin[0]) // x
    
write_coord(origin[1]) // y
    
write_coord(origin[2]) // z
    // this is where the end of the beam is
    
write_coord(originEnd[0]) // x
    
write_coord(originEnd[1]) // y
    
write_coord(originEnd[2]) // z
    // this is the sprite index, as we got in plugin_precache)
    
write_short(g_Beam)
    
// this is the starting frame, it's generally best to leave this at 1
    
write_byte(1)
    
// frame rate in 0.1s
    
write_byte(20)
    
// how long it lasts in 0.1 seconds (10 for 1 second)
    
write_byte(7)
    
// line width in 0.1s
    
write_byte(15)
    
// amplitude (how much it goes off the line)
    
write_byte(15)
    
// r, g, b
    
write_byte(255)
    
write_byte(10)
    
write_byte(5)
    
// brightness
    
write_byte(255)
    
// scroll speed
    
write_byte(100)
    
message_end()
    



Exolent[jNr] 07-29-2011 15:59

Re: Radius
 
Display an explosion sprite, then damage players in the radius, even toss them away from the blast if you want to get fancy.

usaexelent 07-29-2011 16:05

Re: Radius
 
And how do i make that they would be pushed from the blast??
I never understanded how do they do that

usaexelent 07-29-2011 16:09

Re: Radius
 
Quote:

Originally Posted by Exolent[jNr] (Post 1521059)
Code:
// set starting entity new ent = -1; // this is the center of the sphere that you want to check around new Float:origin[3]; // the maximum distance away from the origin new Float:radius = 100.0; while((ent = find_ent_in_sphere(ent, origin, radius))) {     // ent is inside "radius" distance to "origin" }

Could you give me an example?

PHP Code:

new ent = -1;

// this is the center of the sphere that you want to check around
new Float:origin[3];

// the maximum distance away from the origin
new Float:radius 100.0;

while((
ent find_ent_in_sphere(entoriginradius)))
{
    
// ent is inside "radius" distance to "origin"
set_user_health(ent,get_user_health(ent)-50)

Is this is correct


Exolent[jNr] 07-29-2011 16:10

Re: Radius
 
Code:
blast_origin = /* blast origin */ player_origin = /* origin of player to push away */ velocity = player_origin - blast_origin velocity *= (radius - velocity.length) / (radius * velocity.length) * /* push power */ set velocity

There's some pseudo-code.
It shouldn't be hard for you to turn that into real code since the logic is already there.

usaexelent 07-29-2011 16:23

Re: Radius
 
Is my code above is good?

Exolent[jNr] 07-29-2011 16:25

Re: Radius
 
find_ent_in_sphere() can return non-player entities, so you should loop to <= max players.

usaexelent 07-29-2011 16:31

Re: Radius
 
PHP Code:

new ent = -1

// this is the center of the sphere that you want to check around 
new Float:origin[3]; 

// the maximum distance away from the origin 
new Float:radius 100.0

while((
ent find_ent_in_sphere(entoriginradius))) 

    
// ent is inside "radius" distance to "origin" 
if(is_user_connected(id))
set_user_health(ent,get_user_health(ent)-50


Will this do?


All times are GMT -4. The time now is 00:46.

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