AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how register private event ? (https://forums.alliedmods.net/showthread.php?t=113047)

waterforces 12-23-2009 02:34

how register private event ?
 
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

ConnorMcLeod 12-23-2009 02:44

Re: how register private event ?
 
Check steamid in client_authorized forward, then store your id in a global variable, and check it each time Damage message is sent.

waterforces 12-23-2009 03:20

Re: how register private event ?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1027907)
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

joropito 12-23-2009 10:21

Re: how register private event ?
 
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.

waterforces 12-24-2009 00:14

Re: how register private event ?
 
Quote:

Originally Posted by joropito (Post 1028240)
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?

joropito 12-24-2009 00:35

Re: how register private event ?
 
client_authorized is called when you have authenticated by STEAM

client_putinserver is called after resources download and precache

waterforces 12-24-2009 01:53

Re: how register private event ?
 
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

ConnorMcLeod 12-24-2009 02:19

Re: how register private event ?
 
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
    
}




All times are GMT -4. The time now is 04:15.

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