AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   type player name in chat when he is on a breakable entity. (https://forums.alliedmods.net/showthread.php?t=309922)

Obada8 08-12-2018 13:13

type player name in chat when he is on a breakable entity.
 
Hi guys, i need to detect a player who walk on a breakable entity and the output is a chat type his name.

For example:

If player walk on a breakable then the chat output is: PlayerName is on a breakable. and if he got a way from it chat msg said: PlayerName is away from breakable.

Thanks.

Ghosted 08-12-2018 13:24

Re: type player name in chat when he is on a breakable entity.
 
Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>

#define BREAKABLE_KEY_OFFSET EV_INT_bInDuck
new const BREAKABLE_KEY = -581932; // random number for increase performance in check

new bool:PlayerTouchingBreakable[33];

public plugin_init()
{
        RegisterHam(Ham_Spawn, "func_breakable", "Ham_BreakableSpawn_Post", 1);
}

public Ham_BreakableSpawn_Post(EntityID)
{
        entity_set_int(EntityID, BREAKABLE_KEY_OFFSET, BREAKABLE_KEY);
}

public client_PreThink(PlayerID)
{
        if (!is_user_alive(PlayerID))
                return;
       
        static GroundEntity;
       
        if ((GroundEntity = entity_get_edict(PlayerID, EV_ENT_groundentity)) <= 0)
                return;
       
        if (entity_get_int(GroundEntity, BREAKABLE_KEY_OFFSET) != BREAKABLE_KEY)
        {
                if (PlayerTouchingBreakable[PlayerID])
                        PlayerTouchingBreakable[PlayerID] = false;
               
                return;
        }
       
        if (!PlayerTouchingBreakable[PlayerID])
        {
                PlayerTouchingBreakable[PlayerID];
                // Touched, your code here...
        }
}

Not tested

Obada8 08-13-2018 10:30

Re: type player name in chat when he is on a breakable entity.
 
Thanks, i'll test this, but how you know that bro?

Can you tell me?

Obada8 08-13-2018 10:43

Re: type player name in chat when he is on a breakable entity.
 
Not work bro :(

Ghosted 08-13-2018 11:24

Re: type player name in chat when he is on a breakable entity.
 
Quote:

Originally Posted by Obada8 (Post 2609957)
Not work bro :(

Don't tell me that you haven't added anything in that code

Obada8 08-13-2018 15:08

Re: type player name in chat when he is on a breakable entity.
 
Quote:

Originally Posted by Ghosted (Post 2609961)
Don't tell me that you haven't added anything in that code

I do this,,,,

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>

#define BREAKABLE_KEY_OFFSET EV_INT_bInDuck
new const BREAKABLE_KEY = -581932// random number for increase performance in check

new bool:PlayerTouchingBreakable[33];

public 
plugin_init()
{
    
RegisterHam(Ham_Spawn"func_breakable""Ham_BreakableSpawn_Post"1);
}

public 
Ham_BreakableSpawn_Post(EntityID)
{
    
entity_set_int(EntityIDBREAKABLE_KEY_OFFSETBREAKABLE_KEY);
}

public 
client_PreThink(PlayerID)
{
    if (!
is_user_alive(PlayerID))
        return;
    
    static 
GroundEntity;
    
    if ((
GroundEntity entity_get_edict(PlayerIDEV_ENT_groundentity)) <= 0)
        return;
    
    if (
entity_get_int(GroundEntityBREAKABLE_KEY_OFFSET) != BREAKABLE_KEY)
    {
        if (
PlayerTouchingBreakable[PlayerID])
            
PlayerTouchingBreakable[PlayerID] = false;
        
        return;
    }
    
    if (!
PlayerTouchingBreakable[PlayerID])
    {
        
PlayerTouchingBreakable[PlayerID];
        
client_print(idprint_chat"You touched breakable!")
    }


But the message didn't appear.

Ghosted 08-13-2018 15:37

Re: type player name in chat when he is on a breakable entity.
 
Quote:

Originally Posted by Obada8 (Post 2609981)
But the message didn't appear.

Ehm, an uncompillable code?

Code:

client_print(id, print_chat, "You touched breakable!")

Obada8 08-13-2018 18:29

Re: type player name in chat when he is on a breakable entity.
 
Quote:

Originally Posted by Ghosted (Post 2609989)
Ehm, an uncompillable code?

Code:

client_print(id, print_chat, "You touched breakable!")

No bro, I can compile it, i compile it and add the plugin to my server, but when i walk on the breakable there is no message appear.


All times are GMT -4. The time now is 06:22.

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