AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hit indicator (https://forums.alliedmods.net/showthread.php?t=184082)

Liverwiz 04-30-2012 16:40

hit indicator
 
I can't seem to get a hit indicator to work at all. nothing seems to print. here's my code.

PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Damage""event_damage""be""2!0")
    
    
g_SyncOb CreateHudSyncObj()
}

public 
event_damage(id)
{
    new 
pi_attackerIDp_weaponp_hitzone
    pi_attackerID 
get_user_attacker(idp_weaponp_hitzone)

    new 
i_damage read_data(2)
    
    
client_print(pi_attackerIDprint_chat"You hit him!")
    
    
set_hudmessage(1811811810.0, -0.510.14.00.020.02, -1)
    
ShowSyncHudMsg(pi_attackerIDg_SyncOb"X")
    
    return 
PLUGIN_CONTINUE


as you can see all it will do is print an X to where i'd assume would be a little lower than the crosshair. but it doesn't. any ideas?

Bilal Pro 04-30-2012 17:27

Re: hit indicator
 
Try to use HamTakeDamage

Liverwiz 04-30-2012 18:02

Re: hit indicator
 
Quote:

Originally Posted by Bilal Pro (Post 1699528)
Try to use HamTakeDamage

i'll see how that goes. But i don't understand why this isn't working....at all.

Liverwiz 04-30-2012 19:31

Re: hit indicator
 
I tried using Ham_TakeDamage, but it still doesn't work. Here is my code:

PHP Code:

//init
    
RegisterHam(Ham_TakeDamage"player""ham_dammich"1)

public 
ham_dammich(victimIDinflictorIDattackerIDFloat:f_damagetype)
{
    if(
get_pcvar_num(g_pcvar_toggle)==|| !is_user_alive(victimID) || !is_user_alive(attackerID))
        return 
HAM_HANDLED
    
    
new sz_attackerMsg[32] = "Hit:"
    
new sz_victimMsg[32] = "Damage:"
    
    
client_print(attackerIDprint_chat"You hit him!")
    
    
format(sz_attackerMsg31"%s %d"sz_attackerMsgfloatround(f_damage))
    
format(sz_victimMsg31"%s -%d"sz_victimMsgfloatround(f_damage))
    
    
client_print(attackerIDprint_centersz_attackerMsg)
    
client_print(victimIDprint_centersz_victimMsg)
    
    
set_hudmessage(1811811810.0, -0.510.14.00.020.02, -1)
    
ShowSyncHudMsg(attackerIDg_SyncOb"X")
    
    return 
HAM_IGNORED



<VeCo> 05-01-2012 12:41

Re: hit indicator
 
You can format the strings directly in the client_print native - there's no need to make variables and use format.

Liverwiz 05-01-2012 16:59

Re: hit indicator
 
Quote:

Originally Posted by <VeCo> (Post 1699992)
You can format the strings directly in the client_print native - there's no need to make variables and use format.

I know. I have plans for this code that will need that functionality.

But can ANYONE help me figure out why this won't show the X to the attacker, or any of the prints when damage is done. Its driving me mad. I've looked at 3 different examples of similar functionality and it should work. Am i missing anything? Is the server stupid? Is my compiler a craphole? Here's my current code, shortened to keep the extraneous code out of people's minds.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <float>
#include <hamsandwich>
//init
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage"player""ham_dammich"1)
    
g_SyncOb CreateHudSyncObj()


public 
ham_dammich(victimIDinflictorIDattackerIDFloat:f_damagetype)
{
    if(
get_pcvar_num(g_pcvar_toggle)==|| !is_user_alive(victimID) || !is_user_alive(attackerID))
        return 
HAM_HANDLED
    
    client_print
(attackerIDprint_chat"You hit him!")
    
    
set_hudmessage(1811811810.0, -1.510.14.00.020.02, -1)
    
ShowSyncHudMsg(attackerIDg_SyncOb"X")
    
    
set_hudmessage(181001.00.510.14.00.020.02, -1)
    
ShowSyncHudMsg(victimIDg_SyncOb"Run!")
    
    return 
HAM_HANDLED


it doesn't show anything. Not once. Shots taken slow, or at real-time playing. HELP! 2 plugins are suffering. :grrr:

Liverwiz 05-13-2012 12:52

Re: hit indicator
 
I'm going to be blatant.

Bump.

<VeCo> 05-13-2012 13:06

Re: hit indicator
 
I tested it now.
The chat message works fine.
The "X" HUD message doesn't show - you have typed -1.5 as Y coordinate, but that's wrong, you meant -1.0?

Liverwiz 05-13-2012 13:31

Re: hit indicator
 
Quote:

Originally Posted by <VeCo> (Post 1708259)
I tested it now.
The chat message works fine.
The "X" HUD message doesn't show - you have typed -1.5 as Y coordinate, but that's wrong, you meant -1.0?

Its weird that it works for you but not in my servers. I meant -1.5 to be just a little lower than the -1.0 so i know its off the crosshair and off your center of mass. I'll take your suggestion into account and test it again when i can get my server back up.

Just wondering, what makes the "-1.5" wrong? Is it just obscure to move in half-marks or does the float really not work like that?

<VeCo> 05-13-2012 13:39

Re: hit indicator
 
The maximum is 1.0, the minimum is 0.0 (-1.0 is centered), another values will be outside the screen.


All times are GMT -4. The time now is 07:54.

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