Raised This Month: $51 Target: $400
 12% 

Fakedamage doesnt damage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 06-24-2011 , 21:50   Fakedamage doesnt damage?
Reply With Quote #1

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;
    } 
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME
r4ndomz is offline
Send a message via Skype™ to r4ndomz
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2011 , 00:22   Re: Fakedamage doesnt damage?
Reply With Quote #2

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
__________________
fysiks is online now
RollerBlades
Senior Member
Join Date: Feb 2011
Location: Sweden
Old 06-25-2011 , 08:10   Re: Fakedamage doesnt damage?
Reply With Quote #3

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.

Last edited by RollerBlades; 06-25-2011 at 08:12.
RollerBlades is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 06-25-2011 , 09:41   Re: Fakedamage doesnt damage?
Reply With Quote #4

have you even added the float gfNextDamageTime? and what is executing it?

-----EDIT-----
and btw as said many many times don't copy paste -.-
Erox902 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-25-2011 , 11:29   Re: Fakedamage doesnt damage?
Reply With Quote #5

http://www.amxmodx.org/funcwiki.php?...mage&go=search

The damage parameter is a float value, not an integer.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-25-2011 , 13:38   Re: Fakedamage doesnt damage?
Reply With Quote #6

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.
__________________
Hunter-Digital is offline
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 06-25-2011 , 15:38   Re: Fakedamage doesnt damage?
Reply With Quote #7

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.
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME

Last edited by r4ndomz; 06-25-2011 at 16:19.
r4ndomz is offline
Send a message via Skype™ to r4ndomz
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-25-2011 , 17:30   Re: Fakedamage doesnt damage?
Reply With Quote #8

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.
__________________
Hunter-Digital is offline
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 06-26-2011 , 11:31   Re: Fakedamage doesnt damage?
Reply With Quote #9

Quote:
Originally Posted by Hunter-Digital View Post
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
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME

Last edited by r4ndomz; 06-26-2011 at 13:25.
r4ndomz is offline
Send a message via Skype™ to r4ndomz
Brian965
Member
Join Date: Jun 2008
Old 06-26-2011 , 18:39   Re: Fakedamage doesnt damage?
Reply With Quote #10



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;

__________________
anyways this is My signature.. http://AwPHnS.CoM is my clans site.
Brian965 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 21:01.


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