edict_t.GetKeyValue() problem

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

edict_t.GetKeyValue() problem

Postby Tuck » Sun Dec 09, 2012 7:17 pm

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 ?
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sun Dec 09, 2012 7:56 pm

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'))


Code: Select all

0.000000
0.500000


L'In20Cible
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Dec 09, 2012 8:19 pm

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
-Tuck
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sun Dec 09, 2012 8:26 pm

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Dec 09, 2012 8:36 pm

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
-Tuck
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sun Dec 09, 2012 8:50 pm

My bad was because it returned 0.0 as default value when not set, however shouldn't it be 1.0 by default ? :/
-Tuck
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Dec 09, 2012 9:41 pm

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

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 8 guests