AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fakedamage doesnt damage? (https://forums.alliedmods.net/showthread.php?t=160080)

r4ndomz 06-24-2011 21:50

Fakedamage doesnt damage?
 
Why isnt it working? I used code from blockmaker, and it isnt working even though when i use blockmaker damage works fine.

PHP Code:

    if (halflife_time() >= gfNextDamageTime[attacker])
    {
        if (
get_user_health(id) > 0)
        {
            new 
name[33], message[33], damage;
            
get_user_name(attackername32);
            
damage get_pcvar_num(hns_hurtdamage);

            
format(message32"%s has crushed you!"name)

            
fakedamage(idmessagedamageDMG_CRUSH);
        }
        else
        {
            
set_user_frags(attackerget_user_frags(attacker) + 1);
            
cs_set_user_deaths(idcs_get_user_deaths(id) + 1);

            
make_deathmsg(attackerid0"worldspawn");
            
update_scoreboard(id0);
        }
        
        
gfNextDamageTime[id] = halflife_time() + 0.5;
    } 


fysiks 06-25-2011 00:22

Re: Fakedamage doesnt damage?
 
Do you even know if that code is being executed? Just because it "works in blockmaker" does not guarantee that it will work outside of blockmaker unless you make it work.

You need to try and debug it and see what is and isn't being executed. Then, when you find that out you will likely be able to solve the problem yourself. If you can't solve it and you at least have it narrowed down then you have a valid reason for posting.

Even then, you should post the whole code to get the quickest response, so instead of writing this essay I could be checking your code.

/rant

RollerBlades 06-25-2011 08:10

Re: Fakedamage doesnt damage?
 
Quote:

Originally posted by Hawk552 who lets his cat approve | unapprove plugins

If your post contains the word "blockmaker" anywhere in this forum and not in this sticky, it will instantly be trashed.

Go to the Suggestions / Requests board instead.

Erox902 06-25-2011 09:41

Re: Fakedamage doesnt damage?
 
have you even added the float gfNextDamageTime? and what is executing it?

-----EDIT-----
and btw as said many many times don't copy paste -.-

Exolent[jNr] 06-25-2011 11:29

Re: Fakedamage doesnt damage?
 
http://www.amxmodx.org/funcwiki.php?...mage&go=search

The damage parameter is a float value, not an integer.

Hunter-Digital 06-25-2011 13:38

Re: Fakedamage doesnt damage?
 
And 2nd param isn't a "message", it's the attacking entity's classname.
Quote:

fakedamage(idvictim, const szClassname[], Float:takedmgdamage, damagetype)
I don't know if classnames allow spaces.

Still, it's more efficient to use ham:
Code:

ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits)
because it uses only one module native, compared to the fakedamage() stock which has serval module native calls.

r4ndomz 06-25-2011 15:38

Re: Fakedamage doesnt damage?
 
Yes fysiks, it is being executed. I thought i said it wasnt damaging. It IS in fact making noise and emitting blood. So it must be executing. Hunter-Digital, what would a players classname be? ERox, of course i have..thats quite obvious i would have to do that. Most of my errors i have solved myself before checking back at this thread, but it still isnt damaging unless i set the players health -5

Quote:

and btw as said many many times don't copy paste -.-
there is no way im wasting my time typing when i can copy and paste

Yes, i am trying to recreate igz's damage on top thing
full code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <cstrike>
#include <fun>

stock update_scoreboard(idattrib 0)
{
    
// 0 == Nothing
    // 1 == DEAD
    // 2 == BOMB
    // 4 == VIP
    
message_begin(MSG_ALLget_user_msgid("ScoreAttrib"));
    
write_byte(id);
    
write_byte(attrib);
    
message_end();
    
    return 
PLUGIN_HANDLED;
}

new const 
PLUGIN[] = "HideNSeek: Pain on Top";
new const 
VERSION[] = "1.0";

new 
Float:gfNextHurtTime[33];
new 
g_MaxPlayers;
new 
blood

public plugin_precache()
{
    
blood precache_model("sprites/blood.spr")
}

public 
plugin_init( )
{
    
register_pluginPLUGINVERSION"r4nDoMz" );
    
register_forward(FM_Touch"fwdTouch"0);

    
g_MaxPlayers global_get(glb_maxClients);
}

public 
fwdTouch(idattacker)
{
    if( !
pev_valid(id) || !pev_valid(attacker)
    || !(
id <= g_MaxPlayers) || !(attacker <= g_MaxPlayers)
    || !
is_user_alive(id) || !is_user_alive(attacker) )
    {
        return 
FMRES_IGNORED;
    }

    if( 
cs_get_user_team(id) == cs_get_user_team(attacker) )
    {
        return 
FMRES_IGNORED;
    }
    
    new 
Float:vidOrigin[3], Float:vattackerOrigin[3];
    
pev(idpev_originvidOrigin);
    
pev(attackerpev_originvattackerOrigin);
    
    if( !(
49.0 < (vattackerOrigin[2] - vidOrigin[2]) < 73.0) )
    {
        return 
FMRES_IGNORED;
    }

    if (
halflife_time() >= gfNextHurtTime[attacker])
    {
        if (
get_user_health(id) > 0)
        {
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
            
write_byte(TE_BLOODSPRITE);
            
write_coord(vidOrigin[0]);
            
write_coord(vidOrigin[1]);
            
write_coord(vidOrigin[2]);
            
write_short(blood);
            
write_short(blood);
            
write_byte(229);
            
write_byte(12);
            
message_end();

            
fakedamage(id"player"5.0DMG_GENERIC);
        }
        else
        {
            
set_user_frags(attackerget_user_frags(attacker) + 1);
            
cs_set_user_deaths(idcs_get_user_deaths(id) + 1);

            
make_deathmsg(attackerid0"worldspawn");
            for( new 
0g_MaxPlayersi++ )
            {
                
update_scoreboard(i0);
            }
        }
        
        
gfNextHurtTime[attacker] = halflife_time() + 0.5;
    }

    return 
FMRES_IGNORED;


Everything works perfectly. I just dont get damaged when im stepped on

Edit: of course. I somehow fixed it. I think it was exolents post that did it. But i have a new problem, it doesnt emit the blood anymore, and when i die from being stepped on it says i killed myself instead of the player whos stepping on me. How can i fix that? Oh and im pretty sure the else code from get_user_health > 0 isnt being called. How do i get it to call without constantly giving score? I get warning about vidOrigin from the blood message also.

Hunter-Digital 06-25-2011 17:30

Re: Fakedamage doesnt damage?
 
Like I said, the classname is the created entity which attacks... I dunno what happens if you create a "player" entity.

Still, why don't you just use ham, you can trigger damage from another player, choose weapon and damage type.

r4ndomz 06-26-2011 11:31

Re: Fakedamage doesnt damage?
 
Quote:

Originally Posted by Hunter-Digital (Post 1496458)
Like I said, the classname is the created entity which attacks... I dunno what happens if you create a "player" entity.

Still, why don't you just use ham, you can trigger damage from another player, choose weapon and damage type.

I looked at the include file for fakedamage. It creates an entity and names it by the classname. I dont know whether or not it matters if the classname is correct. Since you can trigger damage from another player, ill try using that. Thanks.

edit: how can i somehow hook when a player kills another player that way? I added client prints all over the code and i found that when a person dies the else code isnt being executed

Brian965 06-26-2011 18:39

Re: Fakedamage doesnt damage?
 
:D

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <cstrike>
#include <fun>

stock update_scoreboard(idattrib 0)
{
    
// 0 == Nothing
    // 1 == DEAD
    // 2 == BOMB
    // 4 == VIP
    
message_begin(MSG_ALLget_user_msgid("ScoreAttrib"));
    
write_byte(id);
    
write_byte(attrib);
    
message_end();
    
    return 
PLUGIN_HANDLED;
}

new const 
PLUGIN[] = "HideNSeek: Pain on Top";
new const 
VERSION[] = "1.0";

new 
Float:gfNextHurtTime[33];
new 
g_MaxPlayers;
new 
blood

public plugin_precache()
{
    
blood precache_model("sprites/blood.spr")
}

public 
plugin_init( )
{
    
register_pluginPLUGINVERSION"r4nDoMz" );
    
register_forward(FM_Touch"fwdTouch"0);

    
g_MaxPlayers global_get(glb_maxClients);
}

native hnsxp_get_user_xp(client);

native hnsxp_set_user_xp(clientxp);

stock hnsxp_add_user_xp(clientxp)
{
    return 
hnsxp_set_user_xp(clienthnsxp_get_user_xp(client) + xp);
}

public 
fwdTouch(idattacker)
{
    if( !
pev_valid(id) || !pev_valid(attacker)
    || !(
id <= g_MaxPlayers) || !(attacker <= g_MaxPlayers)
    || !
is_user_alive(id) || !is_user_alive(attacker) )
    {
        return 
FMRES_IGNORED;
    }

    if( 
cs_get_user_team(id) == cs_get_user_team(attacker) )
    {
        return 
FMRES_IGNORED;
    }
    
    new 
Float:vidOrigin[3], Float:vattackerOrigin[3];
    
pev(idpev_originvidOrigin);
    
pev(attackerpev_originvattackerOrigin);
    
    if( !(
49.0 < (vattackerOrigin[2] - vidOrigin[2]) < 73.0) )
    {
        return 
FMRES_IGNORED;
    }

    if (
halflife_time() >= gfNextHurtTime[attacker])
    {
        if (
get_user_health(id) > 10)
        {
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
            
write_byte(TE_BLOODSPRITE);
            
write_coord(vidOrigin[0]);
            
write_coord(vidOrigin[1]);
            
write_coord(vidOrigin[2]);
            
write_short(blood);
            
write_short(blood);
            
write_byte(229);
            
write_byte(12);
            
message_end();

            
fakedamage(id"player"5.0DMG_GENERIC);
        }
        else
        {
        new 
name1[42];
        new 
name2[42];
        static 
Float:fFrags;
        
get_user_name(attackername132);
        
get_user_name(idname232);
        
set_hudmessage(255255255, -1.0, -1.006.04.0);
        
show_hudmessage(0"%s just goomba stomped %s!"name1name2);
         
make_deathmsg(attacker,id,0,"goomba");
        
pev(idpev_fragsfFrags);
        
set_pev(idpev_fragsfFrags float(1));
        
fakedamage(id"Goomba Stomp"10000.0DMG_GENERIC);
        
        
hnsxp_add_user_xp(attacker50);
        
client_print(attacker,print_chat"***You got 50 XP for Goomba Stomping!***");
        
        for( new 
0g_MaxPlayersi++ )
         
update_scoreboard(i0);
     
        }
        
        
gfNextHurtTime[attacker] = halflife_time() + 0.5;
    }

    return 
FMRES_IGNORED;



r4ndomz 06-26-2011 20:39

Re: Fakedamage doesnt damage?
 
Quote:

Originally Posted by Brian965 (Post 1497375)
:D

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <cstrike>
#include <fun>

stock update_scoreboard(idattrib 0)
{
    
// 0 == Nothing
    // 1 == DEAD
    // 2 == BOMB
    // 4 == VIP
    
message_begin(MSG_ALLget_user_msgid("ScoreAttrib"));
    
write_byte(id);
    
write_byte(attrib);
    
message_end();
    
    return 
PLUGIN_HANDLED;
}

new const 
PLUGIN[] = "HideNSeek: Pain on Top";
new const 
VERSION[] = "1.0";

new 
Float:gfNextHurtTime[33];
new 
g_MaxPlayers;
new 
blood

public plugin_precache()
{
    
blood precache_model("sprites/blood.spr")
}

public 
plugin_init( )
{
    
register_pluginPLUGINVERSION"r4nDoMz" );
    
register_forward(FM_Touch"fwdTouch"0);

    
g_MaxPlayers global_get(glb_maxClients);
}

native hnsxp_get_user_xp(client);

native hnsxp_set_user_xp(clientxp);

stock hnsxp_add_user_xp(clientxp)
{
    return 
hnsxp_set_user_xp(clienthnsxp_get_user_xp(client) + xp);
}

public 
fwdTouch(idattacker)
{
    if( !
pev_valid(id) || !pev_valid(attacker)
    || !(
id <= g_MaxPlayers) || !(attacker <= g_MaxPlayers)
    || !
is_user_alive(id) || !is_user_alive(attacker) )
    {
        return 
FMRES_IGNORED;
    }

    if( 
cs_get_user_team(id) == cs_get_user_team(attacker) )
    {
        return 
FMRES_IGNORED;
    }
    
    new 
Float:vidOrigin[3], Float:vattackerOrigin[3];
    
pev(idpev_originvidOrigin);
    
pev(attackerpev_originvattackerOrigin);
    
    if( !(
49.0 < (vattackerOrigin[2] - vidOrigin[2]) < 73.0) )
    {
        return 
FMRES_IGNORED;
    }

    if (
halflife_time() >= gfNextHurtTime[attacker])
    {
        if (
get_user_health(id) > 10)
        {
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
            
write_byte(TE_BLOODSPRITE);
            
write_coord(vidOrigin[0]);
            
write_coord(vidOrigin[1]);
            
write_coord(vidOrigin[2]);
            
write_short(blood);
            
write_short(blood);
            
write_byte(229);
            
write_byte(12);
            
message_end();

            
fakedamage(id"player"5.0DMG_GENERIC);
        }
        else
        {
        new 
name1[42];
        new 
name2[42];
        static 
Float:fFrags;
        
get_user_name(attackername132);
        
get_user_name(idname232);
        
set_hudmessage(255255255, -1.0, -1.006.04.0);
        
show_hudmessage(0"%s just goomba stomped %s!"name1name2);
         
make_deathmsg(attacker,id,0,"goomba");
        
pev(idpev_fragsfFrags);
        
set_pev(idpev_fragsfFrags float(1));
        
fakedamage(id"Goomba Stomp"10000.0DMG_GENERIC);
        
        
hnsxp_add_user_xp(attacker50);
        
client_print(attacker,print_chat"***You got 50 XP for Goomba Stomping!***");
        
        for( new 
0g_MaxPlayersi++ )
         
update_scoreboard(i0);
     
        }
        
        
gfNextHurtTime[attacker] = halflife_time() + 0.5;
    }

    return 
FMRES_IGNORED;



lol brian. I love how you BEGGED me for this instead of searching :)
Twas already on the internet. Anyways. Why isnt it emitting blood? And how can i execute that code?

FoxueR 06-26-2011 22:01

Re: Fakedamage doesnt damage?
 
To get it to print that you were killed by a certain player, then assuming that you know the player will die to the damage, you have to block the next occurance of DeathMsg, run the fakedamage() call, then broadcast your own DeathMsg.

The blood is probably not showing up because of where you're standing. It's probably actually working, or with a minor tweak it would, but I suggest that you use TE_BLOODSTREAM instead:

PHP Code:

#define    TE_BLOODSTREAM              101      // Particle spray
// write_byte(TE_BLOODSTREAM)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(vector.x)
// write_coord(vector.y)
// write_coord(vector.z)
// write_byte(color)
// write_byte(speed) 


r4ndomz 06-27-2011 12:16

Re: Fakedamage doesnt damage?
 
Quote:

Originally Posted by FoxueR (Post 1497474)
To get it to print that you were killed by a certain player, then assuming that you know the player will die to the damage, you have to block the next occurance of DeathMsg, run the fakedamage() call, then broadcast your own DeathMsg.

The blood is probably not showing up because of where you're standing. It's probably actually working, or with a minor tweak it would, but I suggest that you use TE_BLOODSTREAM instead:

PHP Code:

#define    TE_BLOODSTREAM              101      // Particle spray
// write_byte(TE_BLOODSTREAM)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(vector.x)
// write_coord(vector.y)
// write_coord(vector.z)
// write_byte(color)
// write_byte(speed) 


Thanks for the idea. Why arent these commands accurate? Fakedamage and Ham Takedamage are NEVER accurate, i want it to damage the player by 5 health, and it hurts them for 2 each time. I tried brians method, it works great, but i set the damage to 500, and it does 400. why?? How can i make it so it emits a headshot sound, with armor? The dink type noise, without using emit_sound?

Exolent[jNr] 06-27-2011 12:46

Re: Fakedamage doesnt damage?
 
Quote:

Originally Posted by r4ndomz (Post 1497890)
Why arent these commands accurate? Fakedamage and Ham Takedamage are NEVER accurate, i want it to damage the player by 5 health, and it hurts them for 2 each time. I tried brians method, it works great, but i set the damage to 500, and it does 400. why??

Because you have to take armor into consideration.

r4ndomz 06-27-2011 13:18

Re: Fakedamage doesnt damage?
 
Ah thanks. How can i block only the deathmsg and the console message that says "player killed self with player"?

Why am i not getting any score when i kill someone this way? I used set_user_frags but i get nothing.


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

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