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

getplayerhandle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stas3
Junior Member
Join Date: Jul 2011
Location: ukraine
Old 07-26-2011 , 14:15   getplayerhandle
Reply With Quote #1

1.

PHP Code:
"1"
{
   
"classname"   "player"
   "handle"   "1572865"

How to get "handle" ? In Eventscripts it's es.getplayerhandle(<userid>)

The only thing I figured out you can get an index of weapon, which keeps the player, then you can learn "handle" to the parameter m_hOwnerEntity. Is there an easier option? I can not find commands.

2. FindEntityByClassname loops through all the indices from 0 to GetEntityCount() ?

--
SourceMod Good, but not enough information and tips on using commands
__________________
My English is bad

Last edited by stas3; 07-26-2011 at 14:19.
stas3 is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-26-2011 , 14:33   Re: getplayerhandle
Reply With Quote #2

1. http://docs.sourcemod.net/api/index....d=show&id=934&

2. http://docs.sourcemod.net/api/index....ad=show&id=43&

It looks through all entities starting from where you say. It's basically a pass-thru function to the engine, so the SM developer may not even know exactly how it works unless he looked through the sdk.
__________________
Greyscale is offline
stas3
Junior Member
Join Date: Jul 2011
Location: ukraine
Old 07-26-2011 , 14:54   Re: getplayerhandle
Reply With Quote #3

1. No, realy "handle" = 1589249, but EntIndexToEntRef show me -2145894399

And I came across another question: why do I see in chat:

PHP Code:
1
2
1

As if SDKHook carried out twice, but it also should not be.

PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"hegrenade_projectile"))
    {
        
SDKHook(entitySDKHook_SpawnHook_EntitySpawned);
    }
}

public 
Hook_EntitySpawned(entity)
{
    
PrintToChatAll("1");

    new 
gren_hOwner GetEntPropEnt(entityProp_Send"m_hOwnerEntity"), knife_index;
    for (new 
1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i) || !IsPlayerAlive(i) || (knife_index GetPlayerWeaponSlot(i2)) < MaxClients) continue;
        if (
GetEntPropEnt(knife_indexProp_Send"m_hOwnerEntity") == gren_hOwner)
        {
            
PrintToChatAll("2");
            
//SDKUnhook(entity, SDKHook_Spawn, Hook_EntitySpawned);
            
break;
        }
    }

--
and: If I know the handle, can get the index of a parent?
__________________
My English is bad

Last edited by stas3; 07-26-2011 at 14:58.
stas3 is offline
Pawn 3-pg
Senior Member
Join Date: Jul 2009
Old 07-26-2011 , 15:37   Re: getplayerhandle
Reply With Quote #4

Some entities are spawned more than once. Just add this to the end of Hook_EntitySpawned so it only gets called once.
PHP Code:
SDKUnhook(entitySDKHook_SpawnHook_EntitySpawned); 
I'm not sure what you are trying to get for the "handle". The m_hOwnerEntity on a weapon should equal the client index (from 1 to MaxClients).

Why do you need this handle? What do you intend to do with it?
Pawn 3-pg is offline
stas3
Junior Member
Join Date: Jul 2011
Location: ukraine
Old 07-26-2011 , 15:56   Re: getplayerhandle
Reply With Quote #5

Quote:
Originally Posted by Pawn 3-pg View Post
Just add this to the end of Hook_EntitySpawned so it only gets called once.
I do not see how to do it in SDKHook.

Quote:
Originally Posted by Pawn 3-pg View Post
Why do you need this handle? What do you intend to do with it?
I want to create the effect of grenades for certain players. handle is needed to determine what the flying grenade belongs to a given player. I do not know what m_hOwnerEntity == client_index, this is very strange, just m_hOwnerEntity usually has the form like: 1552385. And this is clearly not a client index.

But it works, thanks for the tip.
__________________
My English is bad
stas3 is offline
stas3
Junior Member
Join Date: Jul 2011
Location: ukraine
Old 07-27-2011 , 13:11   Re: getplayerhandle
Reply With Quote #6

I have already asked the question, but nobody answered. Please tell me how to create such a structure (keyvalues)

PHP Code:
"group"
{
    
"STEAM_1"
    
{
        
"k"    "1"
        "d"    "3"
    
}

In the wiki there is no information about it, no examples.

PHP Code:
public OnPluginStart()
{
    new 
Handle:kv CreateKeyValues("group");

    
// .....

    
KeyValuesToFile(kv"x.txt");

    
CloseHandle(kv);

__________________
My English is bad
stas3 is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 07-27-2011 , 15:13   Re: getplayerhandle
Reply With Quote #7

http://wiki.alliedmods.net/KeyValues...eMod_Scripting)

I googled "sourcemod wiki keyvalues"

Quote:
I want to create the effect of grenades for certain players. handle is needed to determine what the flying grenade belongs to a given player. I do not know what m_hOwnerEntity == client_index, this is very strange, just m_hOwnerEntity usually has the form like: 1552385. And this is clearly not a client index.
Use SetEntPropEnt

Use the client index (1-64) for the 'other' parameter and it will set the entity handle for you. I don't know if you would use Prop_Send or Prop_Data for whatever property you're setting. Just try both and see what works.
__________________
Greyscale is offline
stas3
Junior Member
Join Date: Jul 2011
Location: ukraine
Old 07-27-2011 , 15:50   Re: getplayerhandle
Reply With Quote #8

Quote:
Originally Posted by Greyscale View Post
http://wiki.alliedmods.net/KeyValues...eMod_Scripting)

I googled "sourcemod wiki keyvalues"
I've read wiki, that's asking because I do not understand. (Question about m_hOwnerEntity closed, I have long made what I wanted)

------
I found (the issue is closed.) It is a pity that so little help on the forums.
__________________
My English is bad

Last edited by stas3; 07-27-2011 at 16:32. Reason: I found
stas3 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 13:28.


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