A problem with "set_prop_int"

Please post any questions about developing your plugin here. Please use the search function before posting!
redbol
Junior Member
Posts: 2
Joined: Wed Apr 13, 2016 2:16 pm

A problem with "set_prop_int"

Postby redbol » Tue Jun 13, 2017 2:59 pm

Image

Code: Select all

from events import Event
from entities.entity import Entity
from players.helpers import index_from_userid
from messages import SayText2

HIDEHUD_RADAR = 1 << 12

@Event('player_jump')
def _player_jump(game_event):
   userid = game_event['userid']
   index = index_from_userid(userid)
   index.set_prop_int('m_iHideHud', HIDEHUD_RADAR)


sp info

Code: Select all

Date          : 2017-06-13 14:57:44.855341
OS            : Windows-7-6.1.7601-SP1
Game          : csgo
SP version    : 581
Server plugins:
   00: Metamod:Source 1.10.7-dev
   01: Source.Python, (C) 2012-2016, Source.Python Team.
SP plugins:
   00: test


What is the problem?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: A problem with "set_prop_int"

Postby Ayuto » Tue Jun 13, 2017 3:03 pm

set_prop_int doesn't exist. It's called set_property_int.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: A problem with "set_prop_int"

Postby satoon101 » Tue Jun 13, 2017 7:43 pm

Also, that property is already a part of our entity data:
https://github.com/Source-Python-Dev-Te ... er.ini#L23

And, the flags for that property are already stored in an Enum:
https://github.com/Source-Python-Dev-Te ... ts.py#L180

Not to mention, your code seems to be missing a step, as the index is an integer, and not a Player object.

All-in-all, you're code could simply be:

Syntax: Select all

from events import Event
from players.constants import HideHudFlags
from players.entity import Player

@Event('player_jump')
def _player_jump(game_event):
userid = game_event['userid']
player = Player.from_userid(userid)
player.hidden_huds |= HideHudFlags.RADAR


Also, in the future, please use [python][/python] when posting Python code on the forums.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 18 guests