Raised This Month: $ Target: $400
 0% 

Weapon toss units


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
outsiderlv
Senior Member
Join Date: Mar 2010
Old 07-08-2010 , 15:24   Weapon toss units
Reply With Quote #1

How can i get the distance from the player who dropped a deagle between the drop pont of the deagle? I think its simular to lj stats.
outsiderlv is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-08-2010 , 16:14   Re: Weapon toss units
Reply With Quote #2

This is how i did it.
PHP Code:
#include <amxmodx>
#include <engine>

#pragma semicolon 1
#define VERSION "1.0"

new Floatthroworigin[3];
new 
Floatdroporigin[3];

public 
plugin_init()
{
    
register_plugin("Drop Distance"VERSION"Drekes");
    
    
register_touch("weaponbox""worldspawn""Fwd_Weapon_Touch");
    
    
register_clcmd("drop""cmd_drop");
}

public 
cmd_drop(id)
    
entity_get_vector(idEV_VEC_originthroworigin);
    
public 
Fwd_Weapon_Touch(weaponworld)
{
    
entity_get_vector(weaponEV_VEC_origindroporigin);
    
    
check_distance();
}

public 
check_distance()
{
    new 
Floatdistance get_distance_f(throworigindroporigin);
    
    
client_print(0print_chat"Drop distance: %.1f"distance);

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
outsiderlv
Senior Member
Join Date: Mar 2010
Old 07-08-2010 , 23:47   Re: Weapon toss units
Reply With Quote #3

And how can i do it with spray? From the ground to the middle of a spray. I tried to do something with impulse and decal, but no results.. <_<

Last edited by outsiderlv; 07-09-2010 at 01:41.
outsiderlv is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-09-2010 , 03:08   Re: Weapon toss units
Reply With Quote #4

This might help: http://forums.alliedmods.net/showthread.php?p=58076

Basically, you hook the SVC_TEMPENTITY message, check for first param is it's TE_PLAYERDECAL (112), get the origin and calculate, easy.
__________________

Last edited by Hunter-Digital; 07-09-2010 at 05:10. Reason: it's hooking SVC_TEMPENTITY, my bad.
Hunter-Digital is offline
outsiderlv
Senior Member
Join Date: Mar 2010
Old 07-09-2010 , 03:55   Re: Weapon toss units
Reply With Quote #5

Damnn.. 2 hard for me.. Can u make a sample? I think register_event("23", "newspray", "a", "1=112") is the main thing..
outsiderlv is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-09-2010 , 05:09   Re: Weapon toss units
Reply With Quote #6

Actally it's hooking the SVC_TEMPENTITY (wich is 23) message and first param as TE_PLAYERDECAL... wich is 112.

TE_PLAYERDECAL params from include/message_const.inc
Code:
#define TE_PLAYERDECAL              112
// write_byte(TE_PLAYERDECAL)
// write_byte(playerindex)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(entity???)
// write_byte(decal number)
// [optional] write_short(model index)
the #define is the define for using it, the rest with // are informations about message parameters, that are between message_begin(msgtype, SVC_TEMPENTITY) and message_end()...

So... after knowing that I would do the following:

PHP Code:
#include <amxmodx>
#include <engine>

public plugin_init()
{
      
/* SVC_TEMPENTITY (event #23) event, trigger if parameter 1 is equal to 112 (TE_PLAYERDECAL) */
      
register_event("23""player_spray""a""1=112")
}

public 
player_spray()
{
      new 
id read_data(2/* as seen in the include, player index is the second parameter */
      
new iOrigin[3]

      
iOrigin[0] = read_data(3/* and of course, the coordinates... */
      
iOrigin[1] = read_data(4)
      
iOrigin[2] = read_data(5)

      
/* you can get the rest of parameters too if you need them */

      /* now, what you needed... distance... */

      
new iPlayerOrigin[3]

      
get_user_origin(idiPlayerOrigin)

      new 
iDistance get_distance(iPlayerOriginiOrigin)

      
client_print(idprint_chat"Distance to your spray: %d"iDistance)

easy :}

Note: not actually tested, but should work.
__________________

Last edited by Hunter-Digital; 07-09-2010 at 05:58.
Hunter-Digital is offline
outsiderlv
Senior Member
Join Date: Mar 2010
Old 07-09-2010 , 05:38   Re: Weapon toss units
Reply With Quote #7

It says something about argument type mismatch (argument 1) @ register_event(SVC_TEMPENTITY, "player_spray", "a", "1=112")

Last edited by outsiderlv; 07-09-2010 at 05:46.
outsiderlv is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-09-2010 , 05:54   Re: Weapon toss units
Reply With Quote #8

Yeah, SVC_TEMPENTITY is an int, not a string xD fixed and tested, works just fine.
__________________
Hunter-Digital is offline
outsiderlv
Senior Member
Join Date: Mar 2010
Old 07-09-2010 , 06:22   Re: Weapon toss units
Reply With Quote #9

It shows 0.000 units all the time.. Works only if %d ...<_< I need %.3f
And yes.. i need to measure the distance not from player, but from ground.

Last edited by outsiderlv; 07-09-2010 at 06:55.
outsiderlv is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-09-2010 , 14:10   Re: Weapon toss units
Reply With Quote #10

Use get_distance_f then if you want float... the code I wrote works because I tested it... but detects distance from player to spray... you want from ground (walkable ground, not wall ?) to the entity ? I dunno, trace line or something... from the player's origin so that it doesn't collide with something else down the wall.
__________________
Hunter-Digital 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 07:05.


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