This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Radius [Still need help]


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-29-2011 , 17:03   Re: Radius
Reply With Quote #11

It's better to just check <= max players since the loop will stop after the last player, thus being more efficient.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 07-29-2011 , 17:04   Re: Radius
Reply With Quote #12

hmmm.... Very good idea thanks for explaining
usaexelent is offline
Send a message via Skype™ to usaexelent
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 07-29-2011 , 17:12   Re: Radius
Reply With Quote #13

So the code should look like this?
PHP Code:
new getmaxplayers
getmaxplayers 
get_maxplayers()
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)) <= getmaxplayers)  
{  
    
// ent is inside "radius" distance to "origin"  
set_user_health(ent,get_user_health(ent)-50)  


Last edited by usaexelent; 07-29-2011 at 17:22.
usaexelent is offline
Send a message via Skype™ to usaexelent
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 07-29-2011 , 17:29   Re: Radius
Reply With Quote #14

Where ever i Shoot Everybody dies, Could some one look in to my code and say to me what wrong?

PHP Code:
/* Plugin generated by AMXX-Studio */

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

new g_Beam
new g_Explode
new bool:ready[33]
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 
client_PreThink(id)
{
    new 
wpnid get_user_weapon(id);
    new 
button pev(idpev_button);
    
    
//if(wpnid == CSW_USP)
    //{    
        
if(button IN_ATTACK2)
        {    
            
lasershoot(id)
        }
        
    
//}
}

public 
lasershoot(id)
{

    
//if(ready[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)
        {
        
set_user_health(EntId,get_user_health(EntId)-10)
        }
        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()
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_EXPLOSION)
    
write_coord(originEnd[0])
    
write_coord(originEnd[1])
    
write_coord(originEnd[2])
    
write_short(g_Explode)
    
write_byte(25)
    
write_byte(10)
    
write_byte(0)
    
message_end()
    
new 
getmaxplayers
getmaxplayers 
get_maxplayers()
new 
ent = -1;   

// this is the center of the sphere that you want to check around   

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

while((
ent find_ent_in_sphere(entoriginEndradius)) <= getmaxplayers)   
{   
    
// ent is inside "radius" distance to "origin"   
set_user_health(ent,get_user_health(ent)-50)   
}
    
ready[id] = false
    set_task
(3.0"Lready")
    
//}
}
public 
Lready(id)
{
    
ready[id] = false
}
public 
client_connect(id)
{
    
ready[id] = true

usaexelent is offline
Send a message via Skype™ to usaexelent
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-29-2011 , 17:43   Re: Radius
Reply With Quote #15

You changed the Float origin into the integer array origin, which is not correct.
Also, check if player is alive inside the loop before setting health.
Another thing, that radius is way too small.
The minimum distance between players is 32 units, and that's when they are standing on flat ground next to each other perfectly on the X/Y axis.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 07-29-2011 , 18:05   Re: Radius
Reply With Quote #16

PHP Code:
/* Plugin generated by AMXX-Studio */

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

new g_Beam
new g_Explode
new bool:ready[33]
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 
client_PreThink(id)
{
    new 
wpnid get_user_weapon(id);
    new 
button pev(idpev_button);
    
    
//if(wpnid == CSW_USP)
    //{    
        
if(button IN_ATTACK2)
        {    
            
lasershoot(id)
        }
        
    
//}
}

public 
lasershoot(id)
{

    
//if(ready[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)
        {
        
set_user_health(EntId,get_user_health(EntId)-10)
        }
        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()
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_EXPLOSION)
    
write_coord(originEnd[0])
    
write_coord(originEnd[1])
    
write_coord(originEnd[2])
    
write_short(g_Explode)
    
write_byte(25)
    
write_byte(10)
    
write_byte(0)
    
message_end()
    
new 
getmaxplayers
getmaxplayers 
get_maxplayers()
new 
ent = -1;   

// this is the center of the sphere that you want to check around   

// the maximum distance away from the origin   
new Float:radius 56.0;   
float:originEnd
while((ent find_ent_in_sphere(entoriginEndradius)) <= getmaxplayers)   
{   
    
// ent is inside "radius" distance to "origin" 
if(is_user_alive(ent))
set_user_health(ent,get_user_health(ent)-50)   
}
    
ready[id] = false
    set_task
(3.0"Lready")
    
//}
}
public 
Lready(id)
{
    
ready[id] = false
}
public 
client_connect(id)
{
    
ready[id] = true

Still if i charge lightning it kill everybody.I noticed that it kill every body if i kill any player
usaexelent is offline
Send a message via Skype™ to usaexelent
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 20:46.


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