[HL2:DM] Spawn a Christmas Tree

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[HL2:DM] Spawn a Christmas Tree

Postby Painkiller » Wed Dec 20, 2017 4:32 pm

Hello I have a old eventscripts Plugin here.

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Python
from __future__ import with_statement
import cPickle as pickle

from path import path

# EventScripts
import es
import cmdlib
import gamethread

# =============================================================================
# >> IMPORTS
# =============================================================================
# Command to create a model
CREATE_CMD = '!spawn'

# Command to delete a command
DELETE_CMD = '!delete'

# Model to spawn
MODEL_PATH = 'models_kit/xmas/xmastree.mdl'

# Admins
ADMINS = [
'STEAM_0:1:21953651',
'steamid',
'steamid',
]


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
BASE_PATH = path(__file__).parent
CURRENT_MAP = es.ServerVar('eventscripts_currentmap')


# =============================================================================
# >> CLASSES
# =============================================================================
class Database(set):
def __init__(self, pathto):
self.path = path(pathto)
self.data = {}

def load(self):
self.clear()
if not self.path.isfile():
return

with self.path.open() as f:
try:
self.data = pickle.load(f)

except EOFError:
pass

def save(self):
self.data[str(CURRENT_MAP)] = list(self)
with self.path.open('w') as f:
pickle.dump(self.data, f)

def loadMap(self, mapname):
self.clear()
self.update(self.data.get(mapname, set()))

database = Database(BASE_PATH.joinpath('models.db'))


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
cmdlib.registerSayCommand(CREATE_CMD, spawnModel, 'Spawns a model')
cmdlib.registerSayCommand(DELETE_CMD, deleteModel, 'Deletes a model')
database.load()

def unload():
cmdlib.unregisterSayCommand(CREATE_CMD)
cmdlib.unregisterSayCommand(DELETE_CMD)


# =============================================================================
# >> GAME EVENTS
# =============================================================================
def es_map_start(ev):
database.loadMap(ev['mapname'])
spawnModels()


# =============================================================================
# >> CALLBACKS
# =============================================================================
def spawnModel(userid, args):
if es.getplayersteamid(userid) not in ADMINS:
return

es.server.insertcmd('es_xprop_dynamic_create %i %s'% (userid, MODEL_PATH))
gamethread.delayed(0.5, continueSpawnModel)

def continueSpawnModel():
index = es.getInt('eventscripts_lastgive')
database.add(es.entitygetvalue(index, 'origin'))
database.save()

def deleteModel(userid, args):
if es.getplayersteamid(userid) not in ADMINS:
return

names = dict((index, es.entitygetvalue(index, 'targetname')
) for index in es.getEntityIndexes())

es.server.insertcmd('es_xentsetname %i ViewedModel'% userid)
gamethread.delayed(0.5, continueDeleteModel, (userid, names))

def continueDeleteModel(userid, names):
for index in es.getEntityIndexes():
if es.entitygetvalue(index, 'targetname') != 'ViewedModel':
continue

if abs(int(es.entitygetvalue(index, 'modelindex')) - es.precachemodel(MODEL_PATH)) > 1:
es.setentityname(index, names[index])
continue

origin = es.entitygetvalue(index, 'origin')
es.fire(userid, 'ViewedModel', 'Kill')
database.discard(origin)
database.save()
break


# =============================================================================
# >> FUNCTIONS
# =============================================================================
def spawnModels():
es.precachemodel(MODEL_PATH)
for origin in database:
index = es.createentity('prop_dynamic')
es.entitysetvalue(index, 'origin', origin)
es.entitysetvalue(index, 'model', 'models/' + MODEL_PATH)
es.server.insertcmd('es_xspawnentity %i'% index)


And here is the model.db

Code: Select all

(dp1
S'dm_luna_park_b45a'
p2
(lp3
S'-281.413696 1682.018677 0.031254'
p4
asS'dm_arctic_vendetta_snow_v22'
p5
(lp6
S'9831.826172 6146.264160 114.681389'
p7
aS'2700.904053 2603.878906 380.170868'
p8
aS'6930.022949 5980.709961 -12.421646'
p9
aS'1754.798828 2093.501953 1020.968933'
p10
aS'3137.123047 8893.179688 10.299122'
p11
aS'8400.678711 3978.257324 360.505554'
p12
aS'2021.772461 3345.492188 1051.414307'
p13
aS'8560.695312 2404.508301 -26.557186'
p14
aS'7788.248047 -79.158188 12.374084'
p15
aS'5360.776855 2827.093262 -129.232895'
p16
aS'4329.771484 3794.291504 -32.000000'
p17
aS'10516.040039 5653.026367 1022.990601'
p18
aS'5812.360840 2556.272217 -94.345596'
p19
aS'3158.714600 2417.264893 912.316711'
p20
aS'7728.103027 8529.957031 13.491150'
p21
aS'9340.493164 1557.142212 376.610992'
p22
aS'5352.660156 2530.134277 -98.676117'
p23
aS'8997.498047 5499.284180 19.591461'
p24
aS'1948.076660 4049.167969 1042.629395'
p25
aS'4107.127441 -439.956177 18.674660'
p26
aS'3761.905273 5514.848633 497.492981'
p27
aS'7259.688965 -745.781433 3.896805'
p28
aS'8815.140625 1496.007812 388.895630'
p29
aS'7315.735352 2315.176514 -12.863613'
p30
aS'3503.313477 7555.949219 -32.000000'
p31
aS'5374.470703 8206.772461 -56.252888'
p32
aS'4250.471191 -146.929871 20.906326'
p33
aS'3500.497070 202.470383 97.158669'
p34
aS'5339.740234 1920.745117 -77.640541'
p35
aS'3605.641846 -966.889282 43.882275'
p36
aS'5363.697754 1628.981323 -53.773151'
p37
aS'3366.608398 84.013962 99.794937'
p38
aS'10064.241211 4581.676758 1025.398926'
p39
aS'5761.795410 1926.237427 -94.324684'
p40
aS'3408.340088 7230.166016 -28.325409'
p41
aS'3582.787598 8895.040039 15.744625'
p42
aS'2725.826416 217.980804 124.150589'
p43
aS'3848.835205 917.764893 645.361938'
p44
aS'6013.979980 8172.448242 -49.664162'
p45
aS'1791.533447 2498.955811 1024.014648'
p46
aS'3550.297363 2056.629395 578.543701'
p47
aS'5793.427246 2210.002686 -84.722885'
p48
aS'2398.495850 3707.254639 1015.114624'
p49
aS'5817.653320 2911.935791 -138.892441'
p50
aS'7232.126953 764.368347 19.802231'
p51
aS'2189.734375 2481.112305 479.281799'
p52
aS'2705.722412 882.304443 117.999985'
p53
aS'3971.178223 6606.687012 0.589256'
p54
aS'5732.807129 1666.211060 -93.526062'
p55
aS'7520.655762 3258.554688 394.519196'
p56
aS'5345.228516 2202.135010 -80.014046'
p57
aS'8278.788086 1526.039795 372.958435'
p58
aS'3429.389160 4692.530273 -28.695591'
p59
aS'3158.259766 2982.561279 91.350128'
p60
aS'3689.185791 4217.557129 -17.172852'
p61
aS'3901.676514 -944.214417 29.064491'
p62
aS'8245.845703 8731.109375 -32.000000'
p63
aS'6774.657227 8198.980469 34.780365'
p64
asS'dm_x-mastree_2'
p65
(lp66
S'2514.594727 -1601.765747 0.000008'
p67
aS'2093.430664 -1742.009766 5.703640'
p68
aS'2113.131836 -2880.183105 0.000000'
p69
aS'1218.924927 125.188904 -0.000015'
p70
aS'477.231384 -63.355499 0.000000'
p71
aS'1047.772583 -713.107300 128.031250'
p72
aS'2115.125000 -73.568207 0.000015'
p73
aS'985.183472 -2579.326904 0.000008'
p74
aS'1860.355469 -2124.768066 5.206642'
p75
aS'20.115540 -518.934814 0.000015'
p76
asS'dm_xmas_night_v2'
p77
(lp78
S'-1905.785400 375.094513 207.761963'
p79
aS'-4218.519531 1162.807861 847.628967'
p80
aS'-1612.097656 -3902.046387 195.189011'
p81
aS'-1952.331299 -3914.572754 195.189011'
p82
aS'557.928955 -1670.311279 195.189011'
p83
aS'-2112.191895 1323.881836 259.189026'
p84
aS'348.275757 391.575531 437.957764'
p85
aS'-1176.379028 -3880.966309 195.189026'
p86
aS'513.135742 -3243.252930 371.189026'
p87
aS'-2317.744385 -3917.313232 195.189011'
p88
aS'-121.539062 -1657.747559 195.189011'
p89
asS'dm_office_christmas_bm'
p90
(lp91
S'-1225.753052 705.359070 -326.184814'
p92
aS'1139.648560 -1624.087158 -320.064056'
p93
aS'-1140.478516 -698.553772 -328.000000'
p94
asS'dm_kyra_xmas1'
p95
(lp96
S'1388.798340 -313.552155 -392.968750'
p97
asS'dm_winterislands_moded'
p98
(lp99
S'-2245.017090 -4738.812012 56.031250'
p100
aS'5308.480469 -3274.358398 56.031250'
p101
aS'4086.270264 -4652.570801 56.031250'
p102
aS'3379.745605 2552.185547 56.031254'
p103
aS'5724.284180 751.903442 56.031254'
p104
aS'4514.309570 -3848.471191 56.031254'
p105
aS'-917.713867 3685.470947 56.031250'
p106
aS'-2864.975586 1961.260498 56.031250'
p107
aS'-5937.370117 1525.979492 56.031254'
p108
aS'1011.423340 -6142.780273 56.031250'
p109
aS'2261.008057 2754.218506 56.031250'
p110
aS'2777.583008 2382.294678 56.031250'
p111
aS'1935.935791 3732.905029 56.031250'
p112
aS'3343.203613 -598.096313 56.031250'
p113
aS'892.978760 3088.466064 56.031250'
p114
aS'-6356.893555 506.166565 56.031250'
p115
aS'1778.097290 -6316.889160 56.031254'
p116
aS'5627.683105 -5225.884766 56.031250'
p117
aS'1346.451660 3739.694824 56.031250'
p118
aS'6271.010254 -2908.386230 56.031250'
p119
aS'1575.795410 2198.946289 56.031250'
p120
aS'-3445.348633 -2341.528076 547.839050'
p121
aS'3080.126953 -5806.520508 56.031250'
p122
aS'7076.843750 -4566.247559 56.031250'
p123
aS'4485.061523 555.301819 56.031254'
p124
aS'-2229.921631 -6607.561523 56.031250'
p125
aS'1256.976562 3220.353760 56.031250'
p126
aS'4576.651855 3188.597412 56.031250'
p127
aS'153.053299 3015.499268 56.031254'
p128
aS'3126.173828 2013.409180 56.031250'
p129
aS'313.594482 -6099.831055 56.031250'
p130
aS'-6070.604004 -3713.444824 56.031258'
p131
aS'2488.930420 -4750.884766 56.031250'
p132
aS'-768.370422 -7129.045410 56.031250'
p133
aS'6905.703613 -1093.026001 56.031250'
p134
aS'3064.261719 -3941.018066 56.031250'
p135
aS'4235.537109 1076.046387 56.031250'
p136
aS'4675.271484 80.142494 56.031250'
p137
aS'-1472.110962 2844.298584 56.031250'
p138
aS'6253.965820 -882.674438 56.031250'
p139
aS'-3851.059082 4276.872559 56.031250'
p140
aS'-7135.968750 -3075.031738 57.848183'
p141
aS'-5463.414551 -5086.865234 56.031250'
p142
aS'5714.270020 255.284607 56.031250'
p143
aS'5976.321289 -1734.902954 56.031250'
p144
aS'-5189.589355 3310.563721 56.031250'
p145
aS'5142.320801 -3619.829834 56.031250'
p146
aS'924.689087 -6711.137695 56.031250'
p147
aS'697.107300 2416.991455 56.031250'
p148
aS'3293.634277 -4703.980469 56.031250'
p149
aS'1059.327026 2657.398682 56.031250'
p150
aS'1620.227417 -4914.289062 56.031250'
p151
aS'2994.387451 -5405.608887 56.031250'
p152
aS'-4584.739258 716.561646 88.000000'
p153
aS'4838.216797 -789.951904 56.031254'
p154
aS'-1495.783813 -4191.857422 56.031250'
p155
aS'-5884.283691 -1470.822388 56.031250'
p156
aS'6735.372070 -1800.830566 56.031250'
p157
aS'6681.811035 -17.875122 56.031254'
p158
aS'-5450.433105 -2015.365845 96.228233'
p159
aS'2902.658203 3074.934082 56.031250'
p160
aS'243.978455 2708.221680 56.031250'
p161
aS'196.635010 -6903.146484 56.031250'
p162
aS'-606.204529 -5088.531250 56.031250'
p163
aS'-5460.577637 -797.988281 87.338120'
p164
aS'728.395508 3730.431641 56.031250'
p165
aS'-4458.743164 -4662.725098 56.031250'
p166
aS'-3668.357178 -5608.412109 56.031254'
p167
aS'191.762939 -4452.702148 56.031250'
p168
aS'-579.924866 4104.040039 56.031254'
p169
aS'-894.914124 3072.327637 56.031250'
p170
aS'-5812.665527 2029.542847 56.031250'
p171
aS'2243.273682 -5022.793457 56.031250'
p172
aS'-847.554321 -5975.847168 56.031250'
p173
aS'1699.455078 1865.208496 56.031250'
p174
aS'-5052.595215 1979.442261 56.031250'
p175
aS'-5104.900391 -4604.017090 56.031250'
p176
aS'-3127.584229 -6401.561523 56.031250'
p177
aS'2498.757080 -6048.292969 56.031250'
p178
aS'6522.812988 672.582947 56.031250'
p179
aS'-963.571228 -1704.583496 56.031250'
p180
aS'-4883.241211 3889.617676 56.031250'
p181
aS'-2580.036621 4243.306152 56.031250'
p182
aS'-5989.494141 2.602905 56.031250'
p183
aS'-3746.435791 1909.038574 56.031250'
p184
aS'3432.202881 -5060.020020 56.031250'
p185
aS'-6237.666992 942.960815 56.031250'
p186
aS'1078.752686 -4970.913086 56.031250'
p187
aS'-1078.947632 -6975.938477 56.031250'
p188
aS'-6575.399902 -2378.724854 56.031250'
p189
aS'-4917.045898 4.012421 89.324844'
p190
aS'3413.513672 98.299988 56.031250'
p191
aS'4513.216797 -481.235352 56.031250'
p192
aS'-3792.166748 -4891.972656 56.031250'
p193
aS'6418.243164 -1724.750977 56.031250'
p194
aS'-2988.315186 2771.118164 56.031250'
p195
aS'5223.292480 96.989304 56.031250'
p196
aS'4864.009277 -3091.586426 56.031250'
p197
aS'-6182.161133 -3238.200928 56.031250'
p198
aS'-3362.951904 -5248.756348 56.031250'
p199
aS'-206.927917 3623.059082 56.031250'
p200
aS'2222.991455 2056.195557 56.031250'
p201
aS'-5681.117188 3206.742920 56.031250'
p202
aS'1299.489502 -5660.921875 56.031254'
p203
aS'297.139343 3587.444824 56.031250'
p204
aS'4465.933105 -5368.297363 56.031250'
p205
aS'5237.121582 544.554871 56.031250'
p206
aS'5940.981445 -157.203110 56.031250'
p207
aS'5536.908203 2324.310547 56.031250'
p208
aS'1710.254272 -5163.794434 56.031250'
p209
aS'-6654.594727 -1527.226562 56.031242'
p210
aS'-5667.419434 2694.020020 56.031250'
p211
aS'-6379.911133 -727.857178 56.031258'
p212
aS'5227.700684 -1652.078735 56.031250'
p213
aS'9183.968750 -1703.031982 109.027985'
p214
aS'-4802.906738 445.123169 88.000000'
p215
aS'7382.080566 -957.556030 56.031250'
p216
aS'-4189.352051 2699.824951 56.031250'
p217
aS'5927.568848 -5764.065430 56.031250'
p218
aS'3725.844971 -91.737366 56.031250'
p219
aS'-4380.180664 4049.273682 56.031250'
p220
aS'3523.392822 973.343994 56.031250'
p221
aS'-5763.372559 -4555.864258 56.031250'
p222
aS'-2151.999023 2979.611572 56.031254'
p223
aS'-3282.350830 -4811.578125 56.031250'
p224
aS'-1357.161377 1649.623657 56.031250'
p225
aS'-1155.641602 -5262.628906 56.031250'
p226
aS'-5753.438965 -4049.246338 56.031250'
p227
aS'-4722.938965 -5702.482422 56.031250'
p228
aS'-1464.493530 388.339783 56.031250'
p229
aS'4918.516113 -4278.391602 56.031250'
p230
aS'-1020.243286 -4354.100586 56.031250'
p231
aS'-4631.443359 2404.286133 56.031250'
p232
aS'6251.427246 1615.923462 56.031250'
p233
aS'5394.797852 -2618.016846 56.031250'
p234
aS'-1077.103516 -656.194702 56.031250'
p235
aS'3979.121094 -3942.861084 56.031250'
p236
aS'-3942.663086 3945.395020 56.031250'
p237
aS'-2294.707520 -5537.947266 56.031250'
p238
aS'-5041.457031 2745.445557 56.031250'
p239
aS'-4163.941895 375.496674 89.745872'
p240
aS'-4361.527344 -5253.153320 56.031250'
p241
aS'-5709.122070 911.851562 56.031250'
p242
aS'7080.375977 -343.555542 56.031250'
p243
aS'2960.606934 -4609.847168 56.031250'
p244
aS'3981.938965 519.805908 56.031250'
p245
aS'-4089.644531 3341.001709 56.031250'
p246
aS'6361.026367 -644.144531 56.031254'
p247
aS'-2773.942627 -5368.558594 56.031250'
p248
aS'6960.575684 -2133.685059 56.031250'
p249
aS'-1897.233643 -5350.561523 56.031254'
p250
aS'3908.272705 1846.816772 56.031254'
p251
aS'533.681763 -5537.639160 56.031250'
p252
aS'3395.392578 484.487061 56.031250'
p253
aS'5226.267090 -388.794861 56.031250'
p254
aS'-1582.078247 3584.156982 56.031250'
p255
aS'-1295.990234 -6513.579590 56.031250'
p256
aS'-5412.666504 1754.086182 56.031250'
p257
aS'4016.909180 -619.109863 56.031250'
p258
aS'2406.187988 3318.683838 56.031250'
p259
aS'-6072.473145 -2695.015869 56.031258'
p260
aS'4033.921143 -5406.911133 56.031250'
p261
asS'dm_coldruins_xmasmod'
p262
(lp263
S'2500.807373 1633.337769 322.763428'
p264
aS'2556.950928 3454.541260 86.680199'
p265
aS'2099.093018 545.036499 92.461441'
p266
aS'601.101807 3515.190918 189.330582'
p267
aS'741.942566 402.290985 78.286240'
p268
aS'945.381104 2313.739502 114.998596'
p269
asS'dm_winterchill_r2'
p270
(lp271
S'-1499.069824 1615.648926 76.031235'
p272
aS'-2832.863037 963.754517 -27.968750'
p273
asS'dm_7hour_snow8_bm'
p274
(lp275
S'-1754.988525 -1895.082397 -287.968750'
p276
aS'-1830.196045 -138.670547 -255.968750'
p277
aS'-1754.330200 -2322.354004 -287.968750'
p278
aS'-1349.280518 -208.472656 59.620224'
p279
asS'dm_biohazard_tg'
p280
(lp281
S'1612.684692 -142.256332 -23.968750'
p282
asS'dm_ob_attack_house_xmas'
p283
(lp284
S'-853.411987 -776.288452 5.031250'
p285
aS'-276.016296 231.586639 20.031250'
p286
aS'-283.491455 -1148.458130 5.031250'
p287
asS'dm_lostarena_snow'
p288
(lp289
S'-106.296501 741.932007 -255.968750'
p290
aS'902.716309 -357.425171 -255.968750'
p291
aS'-462.216187 -922.574585 -255.968750'
p292
asS'dm_forest_of_pain_snow'
p293
(lp294
S'-2011.913086 -1869.466919 255.472534'
p295
aS'-2019.157837 1024.851685 255.742294'
p296
aS'-923.137085 -1669.325562 2.000000'
p297
aS'-2020.554443 -48.201912 256.344635'
p298
aS'1948.448608 395.668732 237.062790'
p299
aS'1867.429565 -510.780273 314.374237'
p300
aS'-1644.454224 131.314178 2.000000'
p301
aS'-2020.611450 492.527710 256.164490'
p302
aS'506.840027 1977.780029 383.044098'
p303
aS'-2011.923706 -864.472046 254.621262'
p304
aS'-2018.195312 1452.107666 255.581909'
p305
aS'-2011.880981 -1635.480469 254.796814'
p306
aS'-1262.604492 2014.648071 241.206573'
p307
aS'1267.589966 -58.307457 250.506378'
p308
aS'-2020.583130 241.021988 256.532745'
p309
aS'-424.384979 1990.098145 255.799896'
p310
aS'-1474.986938 -2019.991455 255.014557'
p311
aS'1970.038940 1033.703857 215.809952'
p312
aS'-2012.135254 -316.306824 255.053497'
p313
aS'-796.096069 1981.412354 212.799927'
p314
aS'-2013.562500 1240.663208 254.995422'
p315
aS'-2019.246826 1674.041260 255.712830'
p316
aS'-2011.858765 -609.710999 254.712585'
p317
aS'-2020.558350 791.287598 256.101471'
p318
aS'-2011.899170 -1403.030029 254.832092'
p319
aS'-277.869385 -514.940979 255.155640'
p320
aS'1954.920532 662.588501 221.227097'
p321
aS'-1731.703613 -2024.421875 255.867676'
p322
aS'-2011.921997 -1148.666748 254.772995'
p323
asS'dm_snowcapped_r1'
p324
(lp325
S'1567.576294 -765.703979 48.031250'
p326
aS'-214.947800 2275.433105 144.000000'
p327
aS'-1141.622192 1987.861938 146.443298'
p328
aS'1567.158447 1056.397095 48.031250'
p329
asS'dm_whitehaven'
p330
(lp331
S'725.921509 -242.897156 -135.968750'
p332
aS'-413.532715 -1683.994873 -511.968750'
p333
aS'52.578545 -823.281860 -14.861816'
p334
aS'-527.130310 -556.437866 -421.356781'
p335
aS'-551.968750 -558.123657 -431.235962'
p336
asS'dm_4christmas'
p337
(lp338
S'-1544.187622 -313.592529 286.031250'
p339
aS'-2628.602539 -400.078033 286.031250'
p340
aS'-2582.698975 -1152.223999 398.031250'
p341
aS'-1652.940918 502.763672 398.031250'
p342
asS'dm_icepick'
p343
(lp344
S'451.960327 -1273.040405 32.031250'
p345
aS'1086.634521 1091.401001 32.000000'
p346
aS'-168.822571 772.350220 32.000000'
p347
aS'427.030029 -416.486481 32.000000'
p348
aS'-818.018311 172.563858 32.000000'
p349
asS'dm_resistance_hurtlocker_v2'
p350
(lp351
S'-33.816429 -920.284424 -1235.949829'
p352
asS'dm_ff_snow_village_beta4'
p353
(lp354
S'1693.524414 967.149658 -63.968750'
p355
aS'-3213.108887 -714.120361 -63.968750'
p356
aS'1408.872925 -1392.423584 0.935410'
p357
aS'-2582.693359 -1611.439209 86.283875'
p358
aS'-2326.961426 215.367966 -63.968750'
p359
aS'-558.459595 576.141968 197.596008'
p360
aS'947.640503 817.858215 -63.968781'
p361
aS'-1409.426270 -1299.736084 120.031250'
p362
aS'644.926941 -1887.758545 -63.968781'
p363
aS'-410.801300 -537.969666 2.637089'
p364
aS'474.002838 901.139099 4.031250'
p365
aS'-2426.903320 -694.841431 1.307434'
p366
aS'579.175842 362.522125 4.031250'
p367
aS'351.183655 -297.518433 -63.968750'
p368
aS'1563.903076 -465.799347 32.009903'
p369
asS'dm_frost'
p370
(lp371
S'1977.623047 -1687.217407 63.999992'
p372
aS'2615.460938 -876.655212 63.999992'
p373
aS'-250.928528 344.456635 64.000000'
p374
aS'1346.118652 936.878906 63.999992'
p375
aS'1097.531128 -1889.977539 64.000000'
p376
aS'2135.785889 -838.793518 64.000000'
p377
aS'1035.429199 141.341156 63.999992'
p378
asS'dm_winterbox_beta03a'
p379
(lp380
S'53.847755 -566.291138 0.000008'
p381
aS'130.485825 1837.595459 160.000000'
p382
asS'dm_kabah_christmas'
p383
(lp384
S'2493.909912 -665.665405 0.000008'
p385
aS'572.678284 -2427.317383 -0.020760'
p386
aS'587.539429 -623.364624 -0.000008'
p387
aS'2659.190430 -2463.487061 0.319031'
p388
asS'dm_crossfire_winter'
p389
(lp390
S'-104.819733 1405.579590 0.000004'
p391
aS'51.787262 652.278015 -1.161098'
p392
aS'319.330017 663.572571 -6.299690'
p393
aS'127.089165 1015.476379 -5.669712'
p394
aS'649.413513 902.674683 -1.116966'
p395
aS'68.803444 2621.313232 -133.744904'
p396
aS'-419.107819 956.505615 6.250450'
p397
aS'453.845642 1426.282715 0.000000'
p398
as.


Can anybody ported to SP please?

Thank you in advance and Merry Christmas to all.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Spawn a Christmas Tree

Postby Ayuto » Wed Dec 20, 2017 8:40 pm

Here you are:

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Python
import json

from path import Path
from collections import defaultdict

# Source.Python
from entities.entity import Entity
from commands.typed import TypedSayCommand
from engines.server import global_vars
from engines.precache import Model
from listeners import OnServerActivate
from players.entity import Player
from mathlib import Vector


# =============================================================================
# >> CONSTANTS
# =============================================================================
# Command to create a model
CREATE_CMD = '!spawn'

# Command to delete a model
DELETE_CMD = '!delete'

# Model to spawn
TREE_MODEL = Model('models_kit/xmas/xmastree.mdl')
#TREE_MODEL = Model('models/props/de_dust/door01a.mdl')

# Path where the database is stored
BASE_PATH = Path(__file__).parent


# =============================================================================
# >> CLASSES
# =============================================================================
class Database(defaultdict):
def __init__(self, file_path):
super().__init__(set)
self.file_path = file_path

def load(self):
self.clear()
if not self.file_path.isfile():
return

with self.file_path.open() as f:
for map_name, points in json.load(f).items():
self[map_name].update(Vector(*p) for p in points)

def save(self):
if not self:
return

with self.file_path.open('w') as f:
tmp = dict()
for map_name, points in self.items():
tmp[map_name] = tuple(tuple(p) for p in points)

# Do a pretty dump
json.dump(tmp, f, indent=4, separators=(',', ':'))

def add_spawn_point(self, map_name, point):
self[map_name].add(point)

def remove_spawn_point(self, map_name, point):
self[map_name].discard(point)

def get_spawn_points(self, map_name):
return self[map_name]

database = Database(BASE_PATH / 'points.json')
database.load()


# =============================================================================
# >> EVENTS/COMMANDS
# =============================================================================
@OnServerActivate
def on_server_activate(edicts, edict_count, max_clients):
spawn_models(global_vars.map_name)

@TypedSayCommand(CREATE_CMD, 'xmastree.create')
def on_create_xmastree(info):
player = Player(info.index)
origin = player.view_coordinates
create_tree(origin)

database.add_spawn_point(global_vars.map_name, origin)
database.save()

@TypedSayCommand(DELETE_CMD, 'xmastree.delete')
def on_delete_xmastree(info):
player = Player(info.index)
entity = player.view_entity
if entity.target_name != 'xmastree':
return

database.remove_spawn_point(global_vars.map_name, entity.origin)
database.save()

entity.remove()


# =============================================================================
# >> FUNCTIONS
# =============================================================================
def spawn_models(map_name):
for origin in database.get_spawn_points(map_name):
create_tree(origin)

def create_tree(origin):
entity = Entity.create('prop_dynamic')
entity.target_name = 'xmastree'
entity.origin = origin
entity.model = TREE_MODEL
entity.spawn()

I also had to convert your pickle database (for compatibility and security reasons). Save this to points.json (not model.db):

Code: Select all

{
    "dm_4christmas":[
        [
            -2582.698974609375,
            -1152.2239990234375,
            398.03125
        ],
        [
            -1652.94091796875,
            502.763671875,
            398.03125
        ],
        [
            -2628.6025390625,
            -400.0780334472656,
            286.03125
        ],
        [
            -1544.1876220703125,
            -313.592529296875,
            286.03125
        ]
    ],
    "dm_7hour_snow8_bm":[
        [
            -1754.3302001953125,
            -2322.35400390625,
            -287.96875
        ],
        [
            -1754.988525390625,
            -1895.0823974609375,
            -287.96875
        ],
        [
            -1830.196044921875,
            -138.67054748535156,
            -255.96875
        ],
        [
            -1349.280517578125,
            -208.47265625,
            59.62022399902344
        ]
    ],
    "dm_arctic_vendetta_snow_v22":[
        [
            2189.734375,
            2481.1123046875,
            479.28179931640625
        ],
        [
            9340.4931640625,
            1557.1422119140625,
            376.6109924316406
        ],
        [
            3605.641845703125,
            -966.8892822265625,
            43.88227462768555
        ],
        [
            3503.3134765625,
            7555.94921875,
            -32.0
        ],
        [
            8245.845703125,
            8731.109375,
            -32.0
        ],
        [
            3408.340087890625,
            7230.166015625,
            -28.325408935546875
        ],
        [
            3429.38916015625,
            4692.5302734375,
            -28.69559097290039
        ],
        [
            6013.97998046875,
            8172.4482421875,
            -49.664161682128906
        ],
        [
            5352.66015625,
            2530.13427734375,
            -98.67611694335938
        ],
        [
            4107.12744140625,
            -439.9561767578125,
            18.674659729003906
        ],
        [
            4329.771484375,
            3794.29150390625,
            -32.0
        ],
        [
            3971.17822265625,
            6606.68701171875,
            0.5892559885978699
        ],
        [
            6774.6572265625,
            8198.98046875,
            34.780364990234375
        ],
        [
            2725.826416015625,
            217.98080444335938,
            124.15058898925781
        ],
        [
            9831.826171875,
            6146.26416015625,
            114.68138885498047
        ],
        [
            2700.904052734375,
            2603.87890625,
            380.1708679199219
        ],
        [
            3550.29736328125,
            2056.62939453125,
            578.543701171875
        ],
        [
            6930.02294921875,
            5980.7099609375,
            -12.421646118164062
        ],
        [
            8815.140625,
            1496.0078125,
            388.8956298828125
        ],
        [
            5812.36083984375,
            2556.272216796875,
            -94.34559631347656
        ],
        [
            7788.248046875,
            -79.15818786621094,
            12.37408447265625
        ],
        [
            7259.68896484375,
            -745.7814331054688,
            3.8968050479888916
        ],
        [
            7728.10302734375,
            8529.95703125,
            13.49114990234375
        ],
        [
            3848.835205078125,
            917.764892578125,
            645.3619384765625
        ],
        [
            3901.676513671875,
            -944.2144165039062,
            29.064491271972656
        ],
        [
            2705.722412109375,
            882.304443359375,
            117.99998474121094
        ],
        [
            3366.6083984375,
            84.01396179199219,
            99.79493713378906
        ],
        [
            5374.470703125,
            8206.7724609375,
            -56.25288772583008
        ],
        [
            3582.78759765625,
            8895.0400390625,
            15.744625091552734
        ],
        [
            5817.6533203125,
            2911.935791015625,
            -138.89244079589844
        ],
        [
            5339.740234375,
            1920.7451171875,
            -77.64054107666016
        ],
        [
            8997.498046875,
            5499.2841796875,
            19.591461181640625
        ],
        [
            2398.495849609375,
            3707.254638671875,
            1015.1146240234375
        ],
        [
            3500.4970703125,
            202.4703826904297,
            97.1586685180664
        ],
        [
            5732.80712890625,
            1666.2110595703125,
            -93.52606201171875
        ],
        [
            10064.2412109375,
            4581.6767578125,
            1025.39892578125
        ],
        [
            5793.42724609375,
            2210.002685546875,
            -84.72288513183594
        ],
        [
            3689.185791015625,
            4217.55712890625,
            -17.1728515625
        ],
        [
            3158.259765625,
            2982.561279296875,
            91.35012817382812
        ],
        [
            3761.9052734375,
            5514.8486328125,
            497.49298095703125
        ],
        [
            10516.0400390625,
            5653.0263671875,
            1022.9906005859375
        ],
        [
            8278.7880859375,
            1526.039794921875,
            372.95843505859375
        ],
        [
            5345.228515625,
            2202.135009765625,
            -80.01404571533203
        ],
        [
            5363.69775390625,
            1628.9813232421875,
            -53.77315139770508
        ],
        [
            8400.6787109375,
            3978.25732421875,
            360.50555419921875
        ],
        [
            4250.47119140625,
            -146.92987060546875,
            20.906326293945312
        ],
        [
            1948.07666015625,
            4049.16796875,
            1042.62939453125
        ],
        [
            5360.77685546875,
            2827.09326171875,
            -129.23289489746094
        ],
        [
            1754.798828125,
            2093.501953125,
            1020.9689331054688
        ],
        [
            3137.123046875,
            8893.1796875,
            10.299121856689453
        ],
        [
            1791.533447265625,
            2498.955810546875,
            1024.0146484375
        ],
        [
            7232.126953125,
            764.3683471679688,
            19.802230834960938
        ],
        [
            3158.714599609375,
            2417.264892578125,
            912.3167114257812
        ],
        [
            5761.79541015625,
            1926.2374267578125,
            -94.3246841430664
        ],
        [
            2021.7724609375,
            3345.4921875,
            1051.414306640625
        ],
        [
            7520.65576171875,
            3258.5546875,
            394.5191955566406
        ],
        [
            7315.7353515625,
            2315.176513671875,
            -12.86361312866211
        ],
        [
            8560.6953125,
            2404.50830078125,
            -26.557186126708984
        ]
    ],
    "dm_biohazard_tg":[
        [
            1612.6846923828125,
            -142.25633239746094,
            -23.96875
        ]
    ],
    "dm_coldruins_xmasmod":[
        [
            601.101806640625,
            3515.19091796875,
            189.33058166503906
        ],
        [
            945.381103515625,
            2313.739501953125,
            114.99859619140625
        ],
        [
            741.9425659179688,
            402.2909851074219,
            78.28623962402344
        ],
        [
            2099.093017578125,
            545.0364990234375,
            92.46144104003906
        ],
        [
            2500.807373046875,
            1633.3377685546875,
            322.763427734375
        ],
        [
            2556.950927734375,
            3454.541259765625,
            86.6801986694336
        ]
    ],
    "dm_crossfire_winter":[
        [
            319.33001708984375,
            663.5725708007812,
            -6.299689769744873
        ],
        [
            -419.1078186035156,
            956.505615234375,
            6.250450134277344
        ],
        [
            127.08916473388672,
            1015.4763793945312,
            -5.669712066650391
        ],
        [
            649.4135131835938,
            902.6746826171875,
            -1.1169660091400146
        ],
        [
            68.8034439086914,
            2621.313232421875,
            -133.74490356445312
        ],
        [
            51.787261962890625,
            652.2780151367188,
            -1.1610980033874512
        ],
        [
            -104.81973266601562,
            1405.57958984375,
            3.999999989900971e-06
        ],
        [
            453.84564208984375,
            1426.28271484375,
            0.0
        ]
    ],
    "dm_ff_snow_village_beta4":[
        [
            947.6405029296875,
            817.8582153320312,
            -63.968780517578125
        ],
        [
            -2582.693359375,
            -1611.439208984375,
            86.28387451171875
        ],
        [
            -2326.96142578125,
            215.3679656982422,
            -63.96875
        ],
        [
            -3213.10888671875,
            -714.120361328125,
            -63.96875
        ],
        [
            -2426.9033203125,
            -694.8414306640625,
            1.3074339628219604
        ],
        [
            644.9269409179688,
            -1887.758544921875,
            -63.968780517578125
        ],
        [
            474.0028381347656,
            901.1390991210938,
            4.03125
        ],
        [
            579.1758422851562,
            362.5221252441406,
            4.03125
        ],
        [
            1563.903076171875,
            -465.7993469238281,
            32.00990295410156
        ],
        [
            351.18365478515625,
            -297.5184326171875,
            -63.96875
        ],
        [
            -558.4595947265625,
            576.1419677734375,
            197.59600830078125
        ],
        [
            1408.8729248046875,
            -1392.423583984375,
            0.9354100227355957
        ],
        [
            1693.5244140625,
            967.149658203125,
            -63.96875
        ],
        [
            -1409.42626953125,
            -1299.736083984375,
            120.03125
        ],
        [
            -410.8013000488281,
            -537.9696655273438,
            2.6370890140533447
        ]
    ],
    "dm_forest_of_pain_snow":[
        [
            -1474.9869384765625,
            -2019.991455078125,
            255.01455688476562
        ],
        [
            -923.1370849609375,
            -1669.3255615234375,
            2.0
        ],
        [
            1954.9205322265625,
            662.5885009765625,
            221.2270965576172
        ],
        [
            -1731.70361328125,
            -2024.421875,
            255.86767578125
        ],
        [
            -277.869384765625,
            -514.9409790039062,
            255.1556396484375
        ],
        [
            1867.4295654296875,
            -510.7802734375,
            314.3742370605469
        ],
        [
            -2020.5831298828125,
            241.02198791503906,
            256.5327453613281
        ],
        [
            -2011.899169921875,
            -1403.030029296875,
            254.83209228515625
        ],
        [
            -2020.6114501953125,
            492.5277099609375,
            256.16448974609375
        ],
        [
            -1644.4542236328125,
            131.31417846679688,
            2.0
        ],
        [
            -424.3849792480469,
            1990.09814453125,
            255.79989624023438
        ],
        [
            -2011.9130859375,
            -1869.4669189453125,
            255.4725341796875
        ],
        [
            1970.0389404296875,
            1033.703857421875,
            215.80995178222656
        ],
        [
            -2020.558349609375,
            791.28759765625,
            256.1014709472656
        ],
        [
            -2011.8587646484375,
            -609.7109985351562,
            254.71258544921875
        ],
        [
            -2020.554443359375,
            -48.20191192626953,
            256.3446350097656
        ],
        [
            1267.5899658203125,
            -58.307456970214844,
            250.50637817382812
        ],
        [
            -2018.1953125,
            1452.107666015625,
            255.5819091796875
        ],
        [
            -2011.9219970703125,
            -1148.666748046875,
            254.7729949951172
        ],
        [
            -2011.9237060546875,
            -864.4720458984375,
            254.6212615966797
        ],
        [
            -2012.13525390625,
            -316.30682373046875,
            255.05349731445312
        ],
        [
            -2013.5625,
            1240.6632080078125,
            254.99542236328125
        ],
        [
            -2019.1578369140625,
            1024.8516845703125,
            255.74229431152344
        ],
        [
            -796.0960693359375,
            1981.412353515625,
            212.7999267578125
        ],
        [
            1948.4486083984375,
            395.6687316894531,
            237.0627899169922
        ],
        [
            -1262.6044921875,
            2014.6480712890625,
            241.20657348632812
        ],
        [
            506.84002685546875,
            1977.780029296875,
            383.0440979003906
        ],
        [
            -2011.8809814453125,
            -1635.48046875,
            254.79681396484375
        ],
        [
            -2019.246826171875,
            1674.041259765625,
            255.71282958984375
        ]
    ],
    "dm_frost":[
        [
            1035.42919921875,
            141.34115600585938,
            63.99999237060547
        ],
        [
            -250.92852783203125,
            344.4566345214844,
            64.0
        ],
        [
            2615.4609375,
            -876.6552124023438,
            63.99999237060547
        ],
        [
            1977.623046875,
            -1687.2174072265625,
            63.99999237060547
        ],
        [
            1346.11865234375,
            936.87890625,
            63.99999237060547
        ],
        [
            1097.5311279296875,
            -1889.9775390625,
            64.0
        ],
        [
            2135.785888671875,
            -838.7935180664062,
            64.0
        ]
    ],
    "dm_icepick":[
        [
            427.030029296875,
            -416.4864807128906,
            32.0
        ],
        [
            -818.018310546875,
            172.56385803222656,
            32.0
        ],
        [
            451.9603271484375,
            -1273.0404052734375,
            32.03125
        ],
        [
            -168.82257080078125,
            772.3502197265625,
            32.0
        ],
        [
            1086.634521484375,
            1091.4010009765625,
            32.0
        ]
    ],
    "dm_kabah_christmas":[
        [
            572.6782836914062,
            -2427.3173828125,
            -0.020759999752044678
        ],
        [
            587.5394287109375,
            -623.3646240234375,
            -7.999999979801942e-06
        ],
        [
            2659.1904296875,
            -2463.487060546875,
            0.3190310001373291
        ],
        [
            2493.909912109375,
            -665.6654052734375,
            7.999999979801942e-06
        ]
    ],
    "dm_kyra_xmas1":[
        [
            1388.79833984375,
            -313.5521545410156,
            -392.96875
        ]
    ],
    "dm_lostarena_snow":[
        [
            902.71630859375,
            -357.4251708984375,
            -255.96875
        ],
        [
            -106.29650115966797,
            741.9320068359375,
            -255.96875
        ],
        [
            -462.2161865234375,
            -922.5745849609375,
            -255.96875
        ]
    ],
    "dm_luna_park_b45a":[
        [
            -281.4136962890625,
            1682.0186767578125,
            0.03125400096178055
        ]
    ],
    "dm_ob_attack_house_xmas":[
        [
            -853.4119873046875,
            -776.2884521484375,
            5.03125
        ],
        [
            -276.01629638671875,
            231.58663940429688,
            20.03125
        ],
        [
            -283.491455078125,
            -1148.4581298828125,
            5.03125
        ]
    ],
    "dm_office_christmas_bm":[
        [
            1139.6485595703125,
            -1624.087158203125,
            -320.0640563964844
        ],
        [
            -1225.7530517578125,
            705.3590698242188,
            -326.184814453125
        ],
        [
            -1140.478515625,
            -698.5537719726562,
            -328.0
        ]
    ],
    "dm_resistance_hurtlocker_v2":[
        [
            -33.816429138183594,
            -920.284423828125,
            -1235.9498291015625
        ]
    ],
    "dm_snowcapped_r1":[
        [
            1567.5762939453125,
            -765.7039794921875,
            48.03125
        ],
        [
            -214.9477996826172,
            2275.43310546875,
            144.0
        ],
        [
            1567.158447265625,
            1056.3970947265625,
            48.03125
        ],
        [
            -1141.6221923828125,
            1987.8619384765625,
            146.44329833984375
        ]
    ],
    "dm_whitehaven":[
        [
            -413.53271484375,
            -1683.994873046875,
            -511.96875
        ],
        [
            -527.1303100585938,
            -556.4378662109375,
            -421.3567810058594
        ],
        [
            -551.96875,
            -558.1236572265625,
            -431.2359619140625
        ],
        [
            52.57854461669922,
            -823.2818603515625,
            -14.86181640625
        ],
        [
            725.9215087890625,
            -242.89715576171875,
            -135.96875
        ]
    ],
    "dm_winterbox_beta03a":[
        [
            130.48582458496094,
            1837.595458984375,
            160.0
        ],
        [
            53.847755432128906,
            -566.2911376953125,
            7.999999979801942e-06
        ]
    ],
    "dm_winterchill_r2":[
        [
            -2832.863037109375,
            963.7545166015625,
            -27.96875
        ],
        [
            -1499.06982421875,
            1615.64892578125,
            76.03123474121094
        ]
    ],
    "dm_winterislands_moded":[
        [
            2777.5830078125,
            2382.294677734375,
            56.03125
        ],
        [
            -5450.43310546875,
            -2015.3658447265625,
            96.22823333740234
        ],
        [
            5714.27001953125,
            255.28460693359375,
            56.03125
        ],
        [
            3725.844970703125,
            -91.73736572265625,
            56.03125
        ],
        [
            2960.60693359375,
            -4609.84716796875,
            56.03125
        ],
        [
            -4917.0458984375,
            4.012421131134033,
            89.32484436035156
        ],
        [
            1575.79541015625,
            2198.9462890625,
            56.03125
        ],
        [
            -5753.43896484375,
            -4049.246337890625,
            56.03125
        ],
        [
            2261.008056640625,
            2754.218505859375,
            56.03125
        ],
        [
            4485.0615234375,
            555.3018188476562,
            56.031253814697266
        ],
        [
            1011.42333984375,
            -6142.7802734375,
            56.03125
        ],
        [
            4016.9091796875,
            -619.10986328125,
            56.03125
        ],
        [
            -1464.4935302734375,
            388.33978271484375,
            56.03125
        ],
        [
            4918.51611328125,
            -4278.3916015625,
            56.03125
        ],
        [
            4235.537109375,
            1076.04638671875,
            56.03125
        ],
        [
            3413.513671875,
            98.29998779296875,
            56.03125
        ],
        [
            5237.12158203125,
            544.5548706054688,
            56.03125
        ],
        [
            -1020.2432861328125,
            -4354.1005859375,
            56.03125
        ],
        [
            3064.26171875,
            -3941.01806640625,
            56.03125
        ],
        [
            -2245.01708984375,
            -4738.81201171875,
            56.03125
        ],
        [
            -2988.315185546875,
            2771.1181640625,
            56.03125
        ],
        [
            -4722.93896484375,
            -5702.482421875,
            56.03125
        ],
        [
            -4631.443359375,
            2404.2861328125,
            56.03125
        ],
        [
            -4089.64453125,
            3341.001708984375,
            56.03125
        ],
        [
            -2580.03662109375,
            4243.30615234375,
            56.03125
        ],
        [
            1699.455078125,
            1865.20849609375,
            56.03125
        ],
        [
            -1077.103515625,
            -656.1947021484375,
            56.03125
        ],
        [
            3981.93896484375,
            519.805908203125,
            56.03125
        ],
        [
            297.13934326171875,
            3587.44482421875,
            56.03125
        ],
        [
            1256.9765625,
            3220.353759765625,
            56.03125
        ],
        [
            -3362.951904296875,
            -5248.75634765625,
            56.03125
        ],
        [
            4864.00927734375,
            -3091.58642578125,
            56.03125
        ],
        [
            4465.93310546875,
            -5368.29736328125,
            56.03125
        ],
        [
            6251.42724609375,
            1615.9234619140625,
            56.03125
        ],
        [
            6905.70361328125,
            -1093.0260009765625,
            56.03125
        ],
        [
            -6072.47314453125,
            -2695.015869140625,
            56.03125762939453
        ],
        [
            -3746.435791015625,
            1909.03857421875,
            56.03125
        ],
        [
            -6575.39990234375,
            -2378.724853515625,
            56.03125
        ],
        [
            6361.0263671875,
            -644.14453125,
            56.031253814697266
        ],
        [
            -1078.9476318359375,
            -6975.9384765625,
            56.03125
        ],
        [
            3343.20361328125,
            -598.0963134765625,
            56.03125
        ],
        [
            191.762939453125,
            -4452.7021484375,
            56.03125
        ],
        [
            -579.9248657226562,
            4104.0400390625,
            56.031253814697266
        ],
        [
            -847.5543212890625,
            -5975.84716796875,
            56.03125
        ],
        [
            1778.0972900390625,
            -6316.88916015625,
            56.031253814697266
        ],
        [
            1710.2542724609375,
            -5163.79443359375,
            56.03125
        ],
        [
            -6356.8935546875,
            506.16656494140625,
            56.03125
        ],
        [
            -5667.41943359375,
            2694.02001953125,
            56.03125
        ],
        [
            -6654.5947265625,
            -1527.2265625,
            56.03124237060547
        ],
        [
            -3668.357177734375,
            -5608.412109375,
            56.031253814697266
        ],
        [
            5627.68310546875,
            -5225.884765625,
            56.03125
        ],
        [
            2498.757080078125,
            -6048.29296875,
            56.03125
        ],
        [
            -6182.1611328125,
            -3238.200927734375,
            56.03125
        ],
        [
            5308.48046875,
            -3274.3583984375,
            56.03125
        ],
        [
            -206.92791748046875,
            3623.05908203125,
            56.03125
        ],
        [
            4033.921142578125,
            -5406.9111328125,
            56.03125
        ],
        [
            -606.2045288085938,
            -5088.53125,
            56.03125
        ],
        [
            -1357.161376953125,
            1649.6236572265625,
            56.03125
        ],
        [
            892.978759765625,
            3088.466064453125,
            56.03125
        ],
        [
            4576.65185546875,
            3188.597412109375,
            56.03125
        ],
        [
            1346.45166015625,
            3739.69482421875,
            56.03125
        ],
        [
            5394.7978515625,
            -2618.016845703125,
            56.03125
        ],
        [
            -5412.66650390625,
            1754.086181640625,
            56.03125
        ],
        [
            2406.18798828125,
            3318.683837890625,
            56.03125
        ],
        [
            5940.9814453125,
            -157.20310974121094,
            56.03125
        ],
        [
            -6379.9111328125,
            -727.857177734375,
            56.03125762939453
        ],
        [
            -1155.6416015625,
            -5262.62890625,
            56.03125
        ],
        [
            3432.202880859375,
            -5060.02001953125,
            56.03125
        ],
        [
            2243.273681640625,
            -5022.79345703125,
            56.03125
        ],
        [
            -768.3704223632812,
            -7129.04541015625,
            56.03125
        ],
        [
            5536.908203125,
            2324.310546875,
            56.03125
        ],
        [
            -1582.0782470703125,
            3584.156982421875,
            56.03125
        ],
        [
            4675.271484375,
            80.14249420166016,
            56.03125
        ],
        [
            5223.29248046875,
            96.98930358886719,
            56.03125
        ],
        [
            1620.2274169921875,
            -4914.2890625,
            56.03125
        ],
        [
            5227.70068359375,
            -1652.0787353515625,
            56.03125
        ],
        [
            2994.387451171875,
            -5405.60888671875,
            56.03125
        ],
        [
            1078.752685546875,
            -4970.9130859375,
            56.03125
        ],
        [
            533.6817626953125,
            -5537.63916015625,
            56.03125
        ],
        [
            -5937.3701171875,
            1525.9794921875,
            56.031253814697266
        ],
        [
            4513.216796875,
            -481.2353515625,
            56.03125
        ],
        [
            -5104.900390625,
            -4604.01708984375,
            56.03125
        ],
        [
            -5463.41455078125,
            -5086.865234375,
            56.03125
        ],
        [
            924.6890869140625,
            -6711.1376953125,
            56.03125
        ],
        [
            3908.272705078125,
            1846.8167724609375,
            56.031253814697266
        ],
        [
            7080.3759765625,
            -343.5555419921875,
            56.03125
        ],
        [
            -917.7138671875,
            3685.470947265625,
            56.03125
        ],
        [
            3395.392578125,
            484.487060546875,
            56.03125
        ],
        [
            -5812.66552734375,
            2029.5428466796875,
            56.03125
        ],
        [
            -5189.58935546875,
            3310.563720703125,
            56.03125
        ],
        [
            -4189.35205078125,
            2699.824951171875,
            56.03125
        ],
        [
            -2773.942626953125,
            -5368.55859375,
            56.03125
        ],
        [
            -2864.9755859375,
            1961.260498046875,
            56.03125
        ],
        [
            2488.930419921875,
            -4750.884765625,
            56.03125
        ],
        [
            3979.12109375,
            -3942.861083984375,
            56.03125
        ],
        [
            -2229.921630859375,
            -6607.5615234375,
            56.03125
        ],
        [
            4086.270263671875,
            -4652.57080078125,
            56.03125
        ],
        [
            -3282.350830078125,
            -4811.578125,
            56.03125
        ],
        [
            -1295.990234375,
            -6513.57958984375,
            56.03125
        ],
        [
            -5884.28369140625,
            -1470.8223876953125,
            56.03125
        ],
        [
            -3792.166748046875,
            -4891.97265625,
            56.03125
        ],
        [
            5226.26708984375,
            -388.79486083984375,
            56.03125
        ],
        [
            4514.3095703125,
            -3848.47119140625,
            56.031253814697266
        ],
        [
            4838.216796875,
            -789.951904296875,
            56.031253814697266
        ],
        [
            -1472.1109619140625,
            2844.298583984375,
            56.03125
        ],
        [
            6271.01025390625,
            -2908.38623046875,
            56.03125
        ],
        [
            697.1072998046875,
            2416.991455078125,
            56.03125
        ],
        [
            -4584.7392578125,
            716.5616455078125,
            88.0
        ],
        [
            9183.96875,
            -1703.031982421875,
            109.02798461914062
        ],
        [
            5976.3212890625,
            -1734.9029541015625,
            56.03125
        ],
        [
            2902.658203125,
            3074.93408203125,
            56.03125
        ],
        [
            -5041.45703125,
            2745.445556640625,
            56.03125
        ],
        [
            -4883.2412109375,
            3889.61767578125,
            56.03125
        ],
        [
            1059.3270263671875,
            2657.398681640625,
            56.03125
        ],
        [
            -1897.233642578125,
            -5350.5615234375,
            56.031253814697266
        ],
        [
            6735.3720703125,
            -1800.83056640625,
            56.03125
        ],
        [
            -6237.6669921875,
            942.9608154296875,
            56.03125
        ],
        [
            196.635009765625,
            -6903.146484375,
            56.03125
        ],
        [
            -1495.7838134765625,
            -4191.857421875,
            56.03125
        ],
        [
            -5052.59521484375,
            1979.4422607421875,
            56.03125
        ],
        [
            2222.991455078125,
            2056.195556640625,
            56.03125
        ],
        [
            -5989.494140625,
            2.602905035018921,
            56.03125
        ],
        [
            6960.57568359375,
            -2133.68505859375,
            56.03125
        ],
        [
            -2151.9990234375,
            2979.611572265625,
            56.031253814697266
        ],
        [
            3293.63427734375,
            -4703.98046875,
            56.03125
        ],
        [
            -3942.6630859375,
            3945.39501953125,
            56.03125
        ],
        [
            7382.08056640625,
            -957.5560302734375,
            56.03125
        ],
        [
            5927.56884765625,
            -5764.0654296875,
            56.03125
        ],
        [
            -4802.90673828125,
            445.1231689453125,
            88.0
        ],
        [
            -6070.60400390625,
            -3713.44482421875,
            56.03125762939453
        ],
        [
            313.594482421875,
            -6099.8310546875,
            56.03125
        ],
        [
            -3445.3486328125,
            -2341.528076171875,
            547.8390502929688
        ],
        [
            3379.74560546875,
            2552.185546875,
            56.031253814697266
        ],
        [
            1299.489501953125,
            -5660.921875,
            56.031253814697266
        ],
        [
            -7135.96875,
            -3075.03173828125,
            57.848182678222656
        ],
        [
            -4458.7431640625,
            -4662.72509765625,
            56.03125
        ],
        [
            243.97845458984375,
            2708.2216796875,
            56.03125
        ],
        [
            -2294.70751953125,
            -5537.947265625,
            56.03125
        ],
        [
            5142.32080078125,
            -3619.829833984375,
            56.03125
        ],
        [
            3126.173828125,
            2013.4091796875,
            56.03125
        ],
        [
            -5460.57763671875,
            -797.98828125,
            87.33811950683594
        ],
        [
            5724.2841796875,
            751.9034423828125,
            56.031253814697266
        ],
        [
            6522.81298828125,
            672.5829467773438,
            56.03125
        ],
        [
            -5763.37255859375,
            -4555.8642578125,
            56.03125
        ],
        [
            7076.84375,
            -4566.24755859375,
            56.03125
        ],
        [
            -4163.94189453125,
            375.4966735839844,
            89.7458724975586
        ],
        [
            6418.2431640625,
            -1724.7509765625,
            56.03125
        ],
        [
            -3127.584228515625,
            -6401.5615234375,
            56.03125
        ],
        [
            -3851.05908203125,
            4276.87255859375,
            56.03125
        ],
        [
            -5709.1220703125,
            911.8515625,
            56.03125
        ],
        [
            728.3955078125,
            3730.431640625,
            56.03125
        ],
        [
            3523.392822265625,
            973.343994140625,
            56.03125
        ],
        [
            -963.5712280273438,
            -1704.58349609375,
            56.03125
        ],
        [
            -5681.1171875,
            3206.742919921875,
            56.03125
        ],
        [
            3080.126953125,
            -5806.5205078125,
            56.03125
        ],
        [
            153.0532989501953,
            3015.499267578125,
            56.031253814697266
        ],
        [
            6253.9658203125,
            -882.6744384765625,
            56.03125
        ],
        [
            -4361.52734375,
            -5253.1533203125,
            56.03125
        ],
        [
            6681.81103515625,
            -17.8751220703125,
            56.031253814697266
        ],
        [
            -4380.1806640625,
            4049.273681640625,
            56.03125
        ],
        [
            1935.935791015625,
            3732.905029296875,
            56.03125
        ],
        [
            -894.9141235351562,
            3072.32763671875,
            56.03125
        ]
    ],
    "dm_x-mastree_2":[
        [
            1860.35546875,
            -2124.76806640625,
            5.206642150878906
        ],
        [
            1047.7725830078125,
            -713.1072998046875,
            128.03125
        ],
        [
            20.11553955078125,
            -518.934814453125,
            1.4999999621068127e-05
        ],
        [
            1218.9249267578125,
            125.18890380859375,
            -1.4999999621068127e-05
        ],
        [
            2093.4306640625,
            -1742.009765625,
            5.703639984130859
        ],
        [
            2115.125,
            -73.56820678710938,
            1.4999999621068127e-05
        ],
        [
            477.23138427734375,
            -63.355499267578125,
            0.0
        ],
        [
            985.1834716796875,
            -2579.326904296875,
            7.999999979801942e-06
        ],
        [
            2113.1318359375,
            -2880.18310546875,
            0.0
        ],
        [
            2514.5947265625,
            -1601.7657470703125,
            7.999999979801942e-06
        ]
    ],
    "dm_xmas_night_v2":[
        [
            -1612.09765625,
            -3902.04638671875,
            195.1890106201172
        ],
        [
            557.928955078125,
            -1670.311279296875,
            195.1890106201172
        ],
        [
            -4218.51953125,
            1162.807861328125,
            847.6289672851562
        ],
        [
            -121.5390625,
            -1657.74755859375,
            195.1890106201172
        ],
        [
            -1952.331298828125,
            -3914.57275390625,
            195.1890106201172
        ],
        [
            348.2757568359375,
            391.5755310058594,
            437.957763671875
        ],
        [
            -1905.785400390625,
            375.0945129394531,
            207.761962890625
        ],
        [
            -2112.19189453125,
            1323.8818359375,
            259.18902587890625
        ],
        [
            513.1357421875,
            -3243.2529296875,
            371.18902587890625
        ],
        [
            -1176.3790283203125,
            -3880.96630859375,
            195.18902587890625
        ],
        [
            -2317.744384765625,
            -3917.313232421875,
            195.1890106201172
        ]
    ]
}
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Spawn a Christmas Tree

Postby satoon101 » Wed Dec 20, 2017 9:02 pm

Since this is for HL2:DM, round_start will need to be changed to OnLevelInit or another listener that fires when the map starts.
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Spawn a Christmas Tree

Postby Ayuto » Thu Dec 21, 2017 9:34 am

Thanks! Originally, I used OnLevelInit (just like the original script does), but I was testing on CS:S and creating entities at time crashes the server. Now, I changed it back to OnLevelInit.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Spawn a Christmas Tree

Postby Painkiller » Sat Dec 23, 2017 12:51 pm

Thanks first for the fast processing

Somehow my server does not start anymore.

Code: Select all

Using Breakpad minidump system. Version: 4014252 AppID: 232370
Setting breakpad minidump AppID = 232370
Using breakpad crash handler
Loaded 11 VPK file hashes from /home/akooh/gameserver/christmas/hl2mp/hl2mp_pak.vpk for pure server operation.
Loaded 11 VPK file hashes from /home/akooh/gameserver/christmas/hl2mp/hl2mp_pak.vpk for pure server operation.
Loaded 1218 VPK file hashes from /home/akooh/gameserver/christmas/hl2/hl2_textures.vpk for pure server operation.
Loaded 574 VPK file hashes from /home/akooh/gameserver/christmas/hl2/hl2_sound_vo_english.vpk for pure server operation.
Loaded 383 VPK file hashes from /home/akooh/gameserver/christmas/hl2/hl2_sound_misc.vpk for pure server operation.
Loaded 446 VPK file hashes from /home/akooh/gameserver/christmas/hl2/hl2_misc.vpk for pure server operation.
Loaded 5 VPK file hashes from /home/akooh/gameserver/christmas/platform/platform_misc.vpk for pure server operation.
ConVarRef mat_dxlevel doesn't point to an existing ConVar
server_srv.so loaded for "Half-Life 2 Deathmatch"
Unable to load plugin "..\hl2mp\addons\daf\bin\dosattackfix"
Unable to load plugin "../hl2mp/addons/plr_i486"
Spawn/Chat Protection;  Loading...
Spawn/Chat Protection;  Loaded
[Source.Python] Loading...
[Source.Python] Loaded successfully.
maxplayers set to 16
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
[SP] Loading plugin 'admin'...
MOTDPlayer package is not installed, MoTD frontend will be disabled.
[SP] Successfully loaded plugin 'admin'.
[SP] Loading plugin 'ads'...
[SP] Successfully loaded plugin 'ads'.
[SP] Loading plugin 'country_tag'...
[SP] Successfully loaded plugin 'country_tag'.
[SP] Loading plugin 'deathmsg'...
[SP] Successfully loaded plugin 'deathmsg'.
[SP] Loading plugin 'download'...
[SP] Successfully loaded plugin 'download'.
[SP] Loading plugin 'earbleed'...
[SP] Successfully loaded plugin 'earbleed'.
[SP] Loading plugin 'fog'...
[SP] Successfully loaded plugin 'fog'.
[SP] Loading plugin 'gamedesc'...
[SP] Successfully loaded plugin 'gamedesc'.
[SP] Loading plugin 'headshot'...
[SP] Successfully loaded plugin 'headshot'.
[SP] Loading plugin 'killcam'...
[SP] Successfully loaded plugin 'killcam'.
[SP] Loading plugin 'map_cycle'...
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully
Variable was updated successfully

[SP] Encountered a Warning:
  File '../addons/source-python/packages/site-packages/jinja2/filters.py', line 24: DeprecationWarning
    Flags not at the start of the expression \w+(?u)

Entered load()...
Loaded mapcycle.json (first try)
Added 69 valid maps
Added 69 maps to the !nominate menu
Reloaded map list from JSON
Variable was updated successfully
mc_timelimit was -1, set to the value of mp_timelimit (mp_timelimit = 0.0)
[SP] Successfully loaded plugin 'map_cycle'.
[SP] Loading plugin 'mapoverlayremove'...
[SP] Successfully loaded plugin 'mapoverlayremove'.
[SP] Loading plugin 'parachute'...
[SP] Successfully loaded plugin 'parachute'.
[SP] Loading plugin 'savescore'...
[SP] Successfully loaded plugin 'savescore'.
[SP] Loading plugin 'scoreboard'...
[SP] Successfully loaded plugin 'scoreboard'.
[SP] Loading plugin 'sound_trigger'...
[SP] Successfully loaded plugin 'sound_trigger'.
[SP] Loading plugin 'weapon_drop'...
[SP] Successfully loaded plugin 'weapon_drop'.
[SP] Loading plugin 'webshort'...
[SP] Successfully loaded plugin 'webshort'.
[SP] Loading plugin 'welcome'...
[SP] Successfully loaded plugin 'welcome'.
[SP] Loading plugin 'winter'...
[SP] Successfully loaded plugin 'winter'.
Unknown command "port"
ConVarRef dev_loadtime_map_start doesn't point to an existing ConVar
WARNING: Port 27005 was unavailable - bound to port 27016 instead
WARNING: Port 27020 was unavailable - bound to port 27029 instead
Network: IP 176.9.155.153, mode MP, dedicated Yes, ports 28080 SV / 27016 CL
Spawn/Chat Protection;  LevelShutDown
Entered OnLevelShutdown listener
Initializing Steam libraries for secure Internet server
[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
Setting breakpad minidump AppID = 320
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Setting breakpad minidump AppID = 232370
No account token specified; logging into anonymous game server account.  (Use sv_setsteamaccount to login to a persistent account.)
Spawn/Chat Protection;  Level "dm_rocks_christmas_v5" has been loaded
Spawn/Chat Protection;  LoadEventsFromFile("addons/sc_protect.res") -> ok (87)
Entered OnLevelInit listener (map_name=dm_rocks_christmas_v5)...
Loaded mapcycle.json (first try)
Added 69 valid maps
Added 69 maps to the !nominate menu
Recent map names: dm_rocks_christmas_v5
crash_20171223134901_1.dmp[22550]: Uploading dump (out-of-process)
/tmp/dumps/crash_20171223134901_1.dmp
Segmentation fault (core dumped)
Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem
Sa 23. Dez 13:49:02 CET 2017: Server restart in 10 seconds
crash_20171223134901_1.dmp[22550]: Finished uploading minidump (out-of-process): success = yes
crash_20171223134901_1.dmp[22550]: response: Discarded=1
crash_20171223134901_1.dmp[22550]: file ''/tmp/dumps/crash_20171223134901_1.dmp'', upload yes: ''Discarded=1''
./start28080.sh: Zeile 4: 22282 Getötet                screen ./srcds_run -game hl2mp +ip 176.9.155.153 +port 28080 +map dm_rocks_christmas_v5 -maxplayers 20
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Spawn a Christmas Tree

Postby Ayuto » Sat Dec 23, 2017 3:36 pm

Okay, I have updated the code above to use OnServerActivate. Please try again with the new code.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Spawn a Christmas Tree

Postby Painkiller » Sat Dec 23, 2017 3:54 pm

There is one more mistake.


Code: Select all

[SP] Loading plugin 'winter'...
L 12/23/2017 - 16:52:36: server_cvar: "sv_tags" "increased_maxplayers"
L 12/23/2017 - 16:52:36: server_cvar: "sv_tags" "increased_maxplayers"

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
    plugin._load()
  File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "../addons/source-python/plugins/winter/winter.py", line 83
    def on_server_activate(edicts, edict_count, max_clients)
                                                           ^

SyntaxError: invalid syntax


[SP] Plugin 'winter' was unable to be loaded.


Edit: Edit: Well I could fix the syntax.
But with the command! Spawn, nothing appears.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Spawn a Christmas Tree

Postby Ayuto » Sun Dec 24, 2017 10:55 am

I have fixed the syntax error. The reason why you are not seeing anything is probably, because you model path is not correct. Where is your model stored?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] Spawn a Christmas Tree

Postby satoon101 » Sun Dec 24, 2017 2:08 pm

It could also be that you haven't set up your authorization, as the above plugin uses SP's authorization instead of a list of SteamIDs directly written into the plugin:
http://wiki.sourcepython.com/general/config-auth.html
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Spawn a Christmas Tree

Postby Painkiller » Sun Dec 24, 2017 3:21 pm

The path in the plugin does not seem to be correct.

TREE_MODEL = Model('models_kit/xmas/xmastree.mdl')
to
TREE_MODEL = Model('models/models_kit/xmas/xmastree.mdl')

Now works


Thanks to Ayuto

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 22 guests