Page 1 of 1
edict_t.GetKeyValue() problem
Posted: Sun Dec 09, 2012 7:17 pm
by Tuck
i can set the keyvalue 'gravity' with out any problem and it works perfectly but when i want to get the value but i get 0.0 when infacts it's no where near that value..
Engine bug or source python problem ?
Posted: Sun Dec 09, 2012 7:56 pm
by L'In20Cible
Hey Tuck,
Just tested, works fine for me.
Syntax: Select all
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid
@Event
def player_jump(GameEvent):
player = PlayerEntity(index_from_userid(GameEvent.GetInt('userid')))
print(player.edict.GetKeyValue('gravity'))
player.edict.SetKeyValueFloat('gravity', 0.5)
print(player.edict.GetKeyValue('gravity'))
L'In20Cible
Posted: Sun Dec 09, 2012 8:19 pm
by Tuck
i think it's because im not doing it like that but im "creating/getting" a new edict_t before getting it ?
basicly in player jump u set it and in player_say i would receieve it for example
Posted: Sun Dec 09, 2012 8:26 pm
by L'In20Cible
Well, nope. The player edict_t object stay the same so the value of m_flGravity stay the same unless you (or the engine as well) change it. The problem is surely somewhere else in your code but without it, I can't help you.
L'In20Cible
Posted: Sun Dec 09, 2012 8:36 pm
by Tuck
might be because 0.0 is default return value, will have to test once more, will prob post tommorow with a better explaination of the problem
Posted: Sun Dec 09, 2012 8:50 pm
by Tuck
My bad was because it returned 0.0 as default value when not set, however shouldn't it be 1.0 by default ? :/
Posted: Sun Dec 09, 2012 9:41 pm
by satoon101
You would think that the value "should" be 1.0, but it isn't. That is not the fault of the plugin, however, as that will be the same value no matter what plugin you are using. It is simply the value Valve sets it to. On another note, if you set a player's gravity to 0.0 after having changed it to another value, it has the same effect of setting it to 1.0. I'm not sure why this is, but it is.
Satoon