Comments (6)
There's 3 ways to write items in a new format: ESS, ESP, and SP. To start of with, here's an item (Pendant of the Blood Scarab) that gives you 50 health when you buy it as well as each time you spawn:
ESS (../addons/source-python/plugins/es_emulator/eventscripts/wcs/modules/items/pendant_of_the_blood_scarab/es_pendant_of_the_blood_scarab.txt
):
block player_spawn
{
es wcs_setfx health event_var(userid) + 50 0
}
block buycmd
{
es wcs_setfx health server_var(wcs_userid) + 50 0
}
ESP (../addons/source-python/plugins/es_emulator/eventscripts/wcs/modules/items/pendant_of_the_blood_scarab/pendant_of_the_blood_scarab.py
):
def player_spawn_(event, wcsplayer):
wcsplayer.player.health += 50
def buycmd(wcsplayer):
wcsplayer.player.health += 50
SP (../addons/source-python/plugins/wcs/modules/items/pendant_of_the_blood_scarab/__init__.py
):
from ....core.modules.items.calls import ItemEvent
@ItemEvent()
def player_spawn(event, wcsplayer):
wcsplayer.player.health += 50
@ItemEvent()
def buycmd(wcsplayer):
wcsplayer.player.health += 50
You're only supposed to use 1 of these but it won't hurt if you have all 3 files, as it'll only load 1 of them. It checks (and loads if it's found) in the following order: SP -> ESP -> ESS. If none of the files are found, there'll be a warning to notify you about it (WCS will still load - the item will just be ignored).
There's 2 other files that's required: config.json
and strings.ini
, which are located (in this case) in ../addons/source-python/plugins/wcs/modules/items/pendant_of_the_blood_scarab/
. The contents of the 2 files are as follows:
strings.ini:
[name]
en = "Pendant of the Blood Scarab"
[description]
en = "Gives you +50 health upon purchase and +50 when you spawn"
config.json:
{
"cost": 0,
"required": 0,
"dab": 1,
"duration": 1,
"count": 1,
"event": "player_spawn"
}
strings.ini
contains translated information, in this case, the item name and item description. config.json
contains information such as what the item costs, the minimum required level before it can be purchased, dab (Dead Alive Both) which is when the item can be purchased, the duration (0 = 1 round, 1 = untill death), count (how many of them can be purchased), and event.
Notes: In the ESP example, you'll notice an underscore (_) after "player_spawn". This is supposed to be there, otherwise it'd be seen as a normal event, which is not what we want.
from wcs.
Thank you very much for giving me such a detailled answer !
Appreciate the help !
from wcs.
Sorry to bother you again about this.
I am trying to load the SP version but it does not work.
I got an error while it tries to load:
Traceback (most recent call last):
File "../addons/source-python/plugins/wcs/core/modules/base.py", line 117, in _load_categories_and_values
setting = self.load(name)
File "../addons/source-python/plugins/wcs/core/modules/items/manager.py", line 108, in load
return self._load(name, 'items', ITEM_PATH, ITEM_PATH_ES, OnPluginItemLoad)
File "../addons/source-python/plugins/wcs/core/modules/base.py", line 187, in _load
self[name].module = import_module(f'wcs.modules.{module}.{name}')
File "../addons/source-python/plugins/wcs/modules/items/amulet/__init__.py", line 3, in <module>
@ItemEvent()
TypeError: __init__() missing 1 required positional argument: 'event'
[SP] Successfully loaded plugin 'wcs'.
If I use ItemEvent instead of ItemEvent() it seems like the events are not triggered.
If i use ItemEvent('player_spawn') it gives me another error:
Traceback (most recent call last):
File "../addons/source-python/plugins/wcs/core/modules/base.py", line 117, in _load_categories_and_values
setting = self.load(name)
File "../addons/source-python/plugins/wcs/core/modules/items/manager.py", line 108, in load
return self._load(name, 'items', ITEM_PATH, ITEM_PATH_ES, OnPluginItemLoad)
File "../addons/source-python/plugins/wcs/core/modules/base.py", line 187, in _load
self[name].module = import_module(f'wcs.modules.{module}.{name}')
File "../addons/source-python/plugins/wcs/modules/items/amulet/__init__.py", line 3, in <module>
@ItemEvent('player_spawn')
File "../addons/source-python/plugins/wcs/core/modules/items/calls.py", line 41, in __call__
if 'event' not in config:
TypeError: argument of type 'ItemSetting' is not iterable
Do you have an idea ?
from wcs.
Sorry to bother you again about this.
No worries.
I am trying to load the SP version but it does not work.
I got an error while it tries to load:Traceback (most recent call last): File "../addons/source-python/plugins/wcs/core/modules/base.py", line 117, in _load_categories_and_values setting = self.load(name) File "../addons/source-python/plugins/wcs/core/modules/items/manager.py", line 108, in load return self._load(name, 'items', ITEM_PATH, ITEM_PATH_ES, OnPluginItemLoad) File "../addons/source-python/plugins/wcs/core/modules/base.py", line 187, in _load self[name].module = import_module(f'wcs.modules.{module}.{name}') File "../addons/source-python/plugins/wcs/modules/items/amulet/__init__.py", line 3, in <module> @ItemEvent() TypeError: __init__() missing 1 required positional argument: 'event' [SP] Successfully loaded plugin 'wcs'.
If I use ItemEvent instead of ItemEvent() it seems like the events are not triggered.
If i use ItemEvent('player_spawn') it gives me another error:
Traceback (most recent call last): File "../addons/source-python/plugins/wcs/core/modules/base.py", line 117, in _load_categories_and_values setting = self.load(name) File "../addons/source-python/plugins/wcs/core/modules/items/manager.py", line 108, in load return self._load(name, 'items', ITEM_PATH, ITEM_PATH_ES, OnPluginItemLoad) File "../addons/source-python/plugins/wcs/core/modules/base.py", line 187, in _load self[name].module = import_module(f'wcs.modules.{module}.{name}') File "../addons/source-python/plugins/wcs/modules/items/amulet/__init__.py", line 3, in <module> @ItemEvent('player_spawn') File "../addons/source-python/plugins/wcs/core/modules/items/calls.py", line 41, in __call__ if 'event' not in config: TypeError: argument of type 'ItemSetting' is not iterable
Do you have an idea ?
Update to the newest version, and those issues should be fixed.
from wcs.
Thank you it works now.
Could you tell me where i could find a description of the many argument passed to the function (event, wcsplayer ...). And a list of arguments for each events ?
from wcs.
Thank you it works now.
Could you tell me where i could find a description of the many argument passed to the function (event, wcsplayer ...). And a list of arguments for each events ?
Right now, there's next to no documentation about it, however, if you're comfortable with Python, you can try looking at the source code. You can search for ".notify(", and it'd give you a (some what) readable list of what events there's available. The arguments depends on what you're hooking and from what. For items, it can have no arguments, "wcsplayer" or "event" and "wcsplayer". For races, you can have the same as the items except for skills, as they also provide a "variables" argument.
These questions are likely more suited in the forum thread, so I'd recommend you to ask them there, or create a new issue for each question (if they're around the same topic, just a single one is fine) you may have to make it easier to get an overview of things. Feel free to still make an issue here or in said thread, though.
from wcs.
Related Issues (20)
- WCS not parsing some races HOT 1
- Issue loading wcs HOT 23
- Conversion from index exceptions HOT 3
- [REQUEST] sound effect on levelup HOT 1
- [REQUEST] Old raceinfo/skillinfo system HOT 4
- Problems with mysql HOT 2
- Exception when player leaves the game HOT 1
- Bots keep getting kicked HOT 5
- WCS setmodel not working properly HOT 2
- setfx disguiser missing arms/gloves HOT 1
- Disguise/mole models do not match the models defined for the map HOT 3
- Slow load of database HOT 1
- [REQUEST] exclude bots from wcstop ranking HOT 1
- [QUESTION] Any way to use damage type DMG_FALL for damage commands? (Armor damage reduction) HOT 2
- Ultimates and abilities HOT 2
- Teamlimit errors preventing changerace with Zombie Reloaded V3 running HOT 1
- You do not die on changerace if you recently used kill or changed race HOT 4
- Weird option numbering for skills in old style raceinfo menu HOT 1
- WCS doesnt work on brand new server - CSGO HOT 8
- wcs cant load after using 0.78 race format HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wcs.