Raised This Month: $ Target: $400
 0% 

how register private event ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
waterforces
New Member
Join Date: Dec 2009
Old 12-23-2009 , 02:34   how register private event ?
Reply With Quote #1

In my script I register a event "Damage"; I want the event active when I am losing HP,
========================================
register_event("Damage", "imdamage", "b", "2!0")
......
public imdamage(id)
{
......
}

========================================
but I find the event will happen when anyone is losing his life.

who can give me a register_event method that only respond my damage?

Or, who can teach me how to judge if the id that event give is my userid?

Thanks
waterforces is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-23-2009 , 02:44   Re: how register private event ?
Reply With Quote #2

Check steamid in client_authorized forward, then store your id in a global variable, and check it each time Damage message is sent.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
waterforces
New Member
Join Date: Dec 2009
Old 12-23-2009 , 03:20   Re: how register private event ?
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Check steamid in client_authorized forward, then store your id in a global variable, and check it each time Damage message is sent.
It's maybe a good idea,Thanks! but I dont want modify standard admin.amxx.
I want the function is just implemented in my script. Is there a function of AMX can get current player's ID?

Thanks
waterforces is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-23-2009 , 10:21   Re: how register private event ?
Reply With Quote #4

you don't need to modify admin.amxx

As Connor said, add a control for each user at client_authorized or client_putinserver and the use that control to choose between players if you should activate or not the event.

When you register the event it's for all players so inside your function you must control which users get affected or not.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
waterforces
New Member
Join Date: Dec 2009
Old 12-24-2009 , 00:14   Re: how register private event ?
Reply With Quote #5

Quote:
Originally Posted by joropito View Post
you don't need to modify admin.amxx

As Connor said, add a control for each user at client_authorized or client_putinserver and the use that control to choose between players if you should activate or not the event.

When you register the event it's for all players so inside your function you must control which users get affected or not.
Thanks, but I just want to active my damage event, I dont care other players damage event .

after I put in server, Do I get the my client_authorized or client_putinserver event?

Is there a way to get my ID after I login game?

Last edited by waterforces; 12-24-2009 at 00:21.
waterforces is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-24-2009 , 00:35   Re: how register private event ?
Reply With Quote #6

client_authorized is called when you have authenticated by STEAM

client_putinserver is called after resources download and precache
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
waterforces
New Member
Join Date: Dec 2009
Old 12-24-2009 , 01:53   Re: how register private event ?
Reply With Quote #7

Sorry for my mistake.
I dont know if the script plugin is able to run in client. If the plugin can be run in client, the plugin need know if the event is for the player in this client.
but if the plugin can just be run in server, there is no this problem.

Now I think that the script plugin is run in server.

I test the function with bot in one pc, so I have this question.

Now my question is:
Does the script run in server?

I write a plugin that send data via socket, the destination IP is "127.0.0.1"; If I open a net server "192.168.0.100:27015" with this plugin. the client is "192.168.0.101", then, which PC will receive the socket data from that plugin?

Thanks
waterforces is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-24-2009 , 02:19   Re: how register private event ?
Reply With Quote #8

PHP Code:
#include <amxmodx>

new const VERSION[] = "0.0.1"

new g_iMyId

public plugin_init()
{
    
register_plugin("your event"VERSION"ConnorMcLeod")

    
register_event("Damage""Event_Damage""b"/*your filters here*/)
}

public 
client_authorized(id)
{
    static const 
szMySteamId[] = "STEAM_0:1:23456789"

    
new szSteamId[32]
    
get_user_authid(idszSteamIdcharsmax(szSteamId))

    if( 
equal(szSteamIdszMySteamId) )
    {
        
g_iMyId id
    
}
    else if( 
id == g_iMyId )
    {
        
g_iMyId 0
    
}
}

public 
client_disconnectid )
{
    if( 
id == g_iMyId )
    {
        
g_iMyId 0
    
}
}

public 
Event_Damageid )
{
    if( 
id == g_iMyId )
    {
        
// do stuff here
    
}

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

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 04:15.


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