Raised This Month: $ Target: $400
 0% 

Check Target Infront of you


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 02-26-2007 , 20:12   Check Target Infront of you
Reply With Quote #1

How would you check if a player is infront of you?

Also the other thing is how do you show somebody is taking damage and possibly died from something else like a Kick in cs?
Saw this code in a ClusterGernade..Don't get it.. Can't remeber how this stuff works. To much ( GAY ) Java.

//http://www.amxmodx.org/funcwiki.php?go=func&id=262
How do you know all the different types?
Code:
		//Displays who killed who
		message_begin( 2, 83 )
		write_byte( WhatDoYouPut? )
		write_byte( WhatDoYouPut )
		write_byte( 0 ) //No idea what this does
		write_string( "grenade" )
		message_end()
I was going to try something like:
Code:
		new origin[3], target[3];
		if(cmd_target(id, target))
		{
			get_user_origin(id,origin)
			if(get_distance(origin,target) > 2)
			{
			}
		}

Last edited by Styles; 02-26-2007 at 20:27.
Styles is offline
Send a message via AIM to Styles
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 02-26-2007 , 20:40   Re: Check Target Infront of you
Reply With Quote #2

To check if a player is in front of you. You can try using is_in_viewcone.

PHP Code:
/* SDK function - checks if an origin is in an entity's view cone
 * Set use3d to 1 to do the calculation in 3D. Otherwise it will be in 2D.
 */
native is_in_viewcone(entityFloat:origin[3], use3d 0); 
For damage, you have to do it in the Damage event. As for a custom deathmsg use the stock make_deathmsg from message_stock.inc.

PHP Code:
message_begin(MSG_ALLget_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
write_byte(headshot);
write_string(weapon);
message_end(); 
Since their is no sprite for a weapon "kick" it will show a skull instead.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 02-26-2007 , 20:41   Re: Check Target Infront of you
Reply With Quote #3

Well what If i needed something that would do 20 damage a time. No headshots or anything. Just like that. ?
How do you deal the damage? and The target is the gun infront of you with Victim. Killer is your players name right?
Styles is offline
Send a message via AIM to Styles
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 02-26-2007 , 21:01   Re: Check Target Infront of you
Reply With Quote #4

- Try fakedamage from engine.

PHP Code:
fakedamage(idvictimszClassname[],Float:takedmgdamage,damagetype
eg.

PHP Code:
fakedamage(victim"my_big_boot"20.0DMG_CRUSH
Damage type refence:

PHP Code:
// Instant damage values for use with gmsgDamage 3rd value write_long(BIT)
#define DMG_GENERIC                     0           // Generic damage was done
#define DMG_CRUSH                       (1<<0)      // Crushed by falling or moving object
#define DMG_BULLET                      (1<<1)      // Shot
#define DMG_SLASH                       (1<<2)      // Cut, clawed, stabbed
#define DMG_BURN                        (1<<3)      // Heat burned
#define DMG_FREEZE                      (1<<4)      // Frozen
#define DMG_FALL                        (1<<5)      // Fell too far
#define DMG_BLAST                       (1<<6)      // Explosive blast damage
#define DMG_CLUB                        (1<<7)      // Crowbar, punch, headbutt
#define DMG_SHOCK                       (1<<8)      // Electric shock
#define DMG_SONIC                       (1<<9)      // Sound pulse shockwave
#define DMG_ENERGYBEAM                  (1<<10)     // Laser or other high energy beam 
#define DMG_NEVERGIB                    (1<<12)     // With this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB                   (1<<13)     // With this bit OR'd in, any damage type can be made to gib victims upon death.
#define DMG_DROWN                       (1<<14)     // Drowning
#define DMG_PARALYZE                    (1<<15)     // Slows affected creature down
#define DMG_NERVEGAS                    (1<<16)     // Nerve toxins, very bad
#define DMG_POISON                      (1<<17)     // Blood poisioning
#define DMG_RADIATION                   (1<<18)     // Radiation exposure
#define DMG_DROWNRECOVER                (1<<19)     // Drowning recovery
#define DMG_ACID                        (1<<20)     // Toxic chemicals or acid burns
#define DMG_SLOWBURN                    (1<<21)     // In an oven
#define DMG_SLOWFREEZE                  (1<<22)     // In a subzero freezer
#define DMG_MORTAR                      (1<<23)     // Hit by air raid (done to distinguish grenade from mortar)
#define DMG_TIMEBASED                   (~(0x3fff)) // Mask for time-based damage 
- In the DeathMsg, it's actually the player's IDs
Reference:http://wiki.amxmodx.org/index.php/Ha...vents#DeathMsg
eg.
PHP Code:
make_deathmsg(killervictim0"my_big_boot"
(will show a skull because there is no sprite for a my_big_boot)
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 02-26-2007 , 21:27   Re: Check Target Infront of you
Reply With Quote #5

k Thanks that lloks like it will work! The thing I still don't get is the, if the person is RIGHT infront of you, I looked at the thing you said, it looks like a radius around you.
Styles is offline
Send a message via AIM to Styles
Lord_Destros
Veteran Member
Join Date: Jul 2004
Location: With stupid.
Old 02-26-2007 , 22:23   Re: Check Target Infront of you
Reply With Quote #6

Code:
/* SDK function - checks if an origin is in an entity's view cone
 * Set use3d to 1 to do the calculation in 3D. Otherwise it will be in 2D.
 */
native is_in_viewcone(entity, Float:origin[3], use3d = 0);
As cheap suit said, the above is for checking if the entity is within the players sight.

Code:
Float: get_user_aiming ( index, &id, &body, [ distance = 9999 ] )
If you want to check if the person is within the cross hair then use this.

To check the distance of the player you can run a trace_line.
__________________
Quote:
Originally Posted by Twilight Suzuka
Don't worry m'lord. The turtles day will come.
Lord_Destros is offline
Send a message via AIM to Lord_Destros
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 02-26-2007 , 22:27   Re: Check Target Infront of you
Reply With Quote #7

get_user_aiming THATS IT lol I couldn't remeber k, so its get_user_aiming( index, VICTIM, Body?!, 2);
Styles is offline
Send a message via AIM to Styles
Davidos
Senior Member
Join Date: Feb 2005
Old 02-27-2007 , 02:44   Re: Check Target Infront of you
Reply With Quote #8

Quote:
Originally Posted by styles View Post
get_user_aiming THATS IT lol I couldn't remeber k, so its get_user_aiming( index, VICTIM, Body?!, 2);

Yeah, index would be id


Write it like this if you want to make an IF statement:


Code:
new target, body   // the enemy and the enemies' body public checkaimdistance(id) // id stands for the player using it {      get_user_aiming(id, target, body)   // registers if a user is aiming when this command is being used      if(get_entity_distance(id, target) < 200)   // runs the command when the user is in reach (200 ? units?)      {              //put the stuff it needs to do here, ex.              client_print(id, print_chat, "You are looking at a player in the range of 3/4 footsteps")  // if a player is in the range when you //use the command, it will show you that the target is in range... to loop this make it a set_task } // like so set_task(1.0,"checkaimdistance",0,"",0,"b") // b stands for loop, 1.0 is the time it is run, now every second... //yet this could lag alot if a user keeps looking at another user. //If you want it to be realistic like kick you could put it every 20 seconds //--by making 1.0 to 20.0 and adding your kick command
__________________
Roar.

Last edited by Davidos; 02-27-2007 at 02:48.
Davidos 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 00:41.


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