Retreiving 'CBasePlayer.m_iFOV' ?

Please post any questions about developing your plugin here. Please use the search function before posting!
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Retreiving 'CBasePlayer.m_iFOV' ?

Postby Tuck » Thu Aug 23, 2012 5:32 pm

Could some one show me an example of how to retrieve a players 'CBasePlayer.m_iFOV', 'CBasePlayer.localdata.m_Local.m_bDucked' and CBasePlayer.m_fFlags

Thanks, in advance
-Tuck
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Aug 23, 2012 7:34 pm

Basicly what i want to retrieve about a player is, is he zoomed in on sniper, is he crouching or is he in the air

on css i used these to retrieve it :/
-Tuck
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Aug 24, 2012 12:18 am

Tuck wrote:Basicly what i want to retrieve about a player is, is he zoomed in on sniper, is he crouching or is he in the air

on css i used these to retrieve it :/


I guess your-name-here or some other C++ writer teamed up with him will be creating a playerlib-like library when all the other, more neccessary things are done. So, be patient =)
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Fri Aug 24, 2012 3:19 am

I don't want to retrieve it from the player class i want it to retrieve it from the player entity ?
-Tuck
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Fri Aug 24, 2012 5:57 am

The player entitiy is an instance of the player class (which inherits from other classes such as CBaseEntitiy).
But that functionality is not in SP yet afaik.
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sat Aug 25, 2012 5:47 am

Omega_K2 wrote:The player entitiy is an instance of the player class (which inherits from other classes such as CBaseEntitiy).
But that functionality is not in SP yet afaik.


Its high up on our list of things to work on, but you are correct. We do not currently have this functionality yet!
User avatar
ashbash1987
Developer
Posts: 20
Joined: Tue Jul 10, 2012 12:01 pm
Location: Sheffield, UK
Contact:

Postby ashbash1987 » Sun Aug 26, 2012 3:30 pm

Getting entity props is now in the latest code commit for SP. I don't know when the next full build will be available (or you could build it yourself if you are able to do so), but when it is available you'll be able to do something like this:

Syntax: Select all

from Source import Entity
from Source import Player
from events.decorator import Event

@Event
def round_start(GameEvent):
for player in Player.Players():
entity = Player.EdictOfPlayer(player)
entity.SetPropInt("CBasePlayer.m_iHealth", 1)

The example above will set all player's health values to 1 at the start of a round.

The methods that are available on the edict instance are are follows:

Get methods
  • GetPropInt(propName)
  • GetPropFloat(propName)
  • GetPropVector(propName)
  • GetPropVectorXY(propName)
  • GetPropString(propName)
  • GetPropLong(propName)

Set Methods
  • SetPropInt(propName, propValue)
  • SetPropFloat(propName, propValue)
  • SetPropVector(propName, propValue)
  • SetPropVectorXY(propName, propValue)
  • SetPropString(propName, propValue)
  • SetPropLong(propName, propValue)
The methods will check to ensure that you are getting/setting the correct type, so you shouldn't be able to do SetPropFloat("CBasePlayer.m_iHealth") for example
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Sun Aug 26, 2012 4:16 pm

Awesome :D

I think that is one of the features I've been desperatly waiting for :P
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Sun Aug 26, 2012 4:55 pm

Omega_K2 wrote:Awesome :D

I think that is one of the features I've been desperatly waiting for :P


I am going to release a build with this very shortly.
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Thu Aug 30, 2012 8:58 pm

Looks great, but just one question. Why don't you merge all (or most, atleast int, float and long) into one method, instead of multiple same methods with just different type? Since C++ does support function overloading, and Python doesn't even have to know anything about it.
your-name-here
Developer
Posts: 168
Joined: Sat Jul 07, 2012 1:58 am

Postby your-name-here » Thu Aug 30, 2012 9:17 pm

Mahi wrote:Looks great, but just one question. Why don't you merge all (or most, atleast int, float and long) into one method, instead of multiple same methods with just different type? Since C++ does support function overloading, and Python doesn't even have to know anything about it.


I flip the question onto you, why should we merge it all into one method? Having split methods makes it crystal clear what you're doing. Remember, this isn't Eventscripts. The goal of Source-Python is to provide one-to-one translation of C++ to Python. When you're this close to the engine, you're going to have to deal with type. Also, wrapping overloaded functions in boost (as far as I know) requires a fair amount of extra work.
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Thu Aug 30, 2012 9:21 pm

Mahi wrote:Looks great, but just one question. Why don't you merge all (or most, atleast int, float and long) into one method, instead of multiple same methods with just different type? Since C++ does support function overloading, and Python doesn't even have to know anything about it.


That is because of how we expose the engine with boost python. Its really not that big of a deal is it?
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Fri Aug 31, 2012 4:19 am

Right, makes sense.
your-name-here wrote:The goal of Source-Python is to provide one-to-one translation of C++ to Python.

I should keep this in mind.

And it's not a big deal, was just asking out of curiosity :) I always hated es anyways.
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Sep 02, 2012 7:06 am

ES:

Syntax: Select all

(es.getplayerprop(a['id'], 'CBasePlayer.m_fFlags') & 1) == 0


What would be the equilivent ?

SP??:

Syntax: Select all

entity = Player.EdictOfPlayer(<PLAYER>)
onground = ((entity.GetPropLong('CBasePlayer.m_fFlags') & 1) == 0)
-Tuck
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sun Sep 02, 2012 7:12 am

using EasyPlayer it would be:

Syntax: Select all

SomeGuy = EasyPlayer(userid=a['id'])
SomeGuy.GetPropInt('CBasePlayer.m_fFlags')
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Sep 02, 2012 8:01 am

i dont see the difference of using "EasyPlayer or EdictofPlayer" ?

i was asking if it would return the same as it would in es since idk if es gets it as a string to then look into the flags and see if player is in the air or on ground ? :)
-Tuck
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sun Sep 02, 2012 8:15 am

Tuck wrote:i dont see the difference of using "EasyPlayer or EdictofPlayer" ?

i was asking if it would return the same as it would in es since idk if es gets it as a string to then look into the flags and see if player is in the air or on ground ? :)


Have you tried testing?
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Sep 02, 2012 8:25 am

I'm not really that much into the player flags why i was asking, I haven't messed around with python's & but the code example i wrote should work ?
-Tuck
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sun Sep 02, 2012 8:44 am

Tuck wrote:I'm not really that much into the player flags why i was asking, I haven't messed around with python's & but the code example i wrote should work ?


I am not going to test your code for you. Please test your own code before posting here. Forum Rules

If your code has a problem, then come back... But please stop asking if your code will work or not.
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Sep 02, 2012 9:18 am

Monday wrote:I am not going to test your code for you. Please test your own code before posting here. Forum Rules

If your code has a problem, then come back... But please stop asking if your code will work or not.


was simply asking if es returned string, long or int but fine if u dont know it i'll have to install es and check... (sorry to bother you..)
-Tuck

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 17 guests