Here is the code:
Syntax: Select all
import path
from configobj import ConfigObj
from mathlib import Vector
from entities.entity import Entity
from listeners import OnLevelInit
from listeners.tick import Delay
@OnLevelInit
def map_start(map):
Delay(0, create_spawn_point, (map,))
maps_path = ConfigObj(path.Path(__file__).dirname() + '/spawn_points.ini')
def create_spawn_point(map):
for i in maps_path:
x = int(maps_path['maps'][i][map]['tx'])
y = int(maps_path['maps'][i][map]['ty'])
z = int(maps_path['maps'][i][map]['tz'])
t_spawn = Entity.create('info_player_terrorist')
t_spawn.spawn()
t_spawn.origin = Vector(x,y,z)
Here is the ini file
Syntax: Select all
[maps]
[[de_dust2]]
[[1]]
tx = "0"
ty = "0"
tz = "0"
I don't get why it keeps giving me this error:
Code: Select all
[Source.Python]
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\listeners\tick.py", line 79, in _tick
self.pop(0).execute()
File "..\addons\source-python\packages\source-python\listeners\tick.py", line 160, in execute
return self.callback(*self.args, **self.kwargs)
File "..\addons\source-python\plugins\spawn_points\spawn_points.py", line 19, in create_spawn_point
x = int(maps_path['maps'][i][map]['tx'])
File "..\addons\source-python\packages\site-packages\configobj.py", line 554, in __getitem__
val = dict.__getitem__(self, key)
KeyError: 'maps'