PDA

View Full Version : Problems with scripts+suggestions



Heaveny
29-04-2016, 08:03 AM
Sometimes, after I close and start server again (due to a precache problem), I get this problem:




WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void PlayerManagement::_unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: Included script '../ChatCommandManager'
Angelscript: Beginning plugin 'EntityManager' compilation
Angelscript: Starting compilation: 2 scripts
WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void _unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: Beginning plugin 'Teleport' compilation
Angelscript: Starting compilation: 1 scripts
WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void _unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: Beginning plugin 'Vox' compilation
Angelscript: Starting compilation: 1 scripts
WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void _unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: Beginning plugin 'EntityCreator' compilation
Angelscript: Starting compilation: 1 scripts
WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void _unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: Beginning plugin 'Porkyman' compilation
Angelscript: Starting compilation: 1 scripts
WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void _unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: Beginning plugin 'SvenAdmin' compilation
Angelscript: Starting compilation: 1 scripts
WARNING: Angelscript: (0, 0) : Failed in call to function 'Prepare' with 'void _unnamed_function_()' (Code: -2)
WARNING: Angelscript: Plugin script compilation failed
Angelscript: 0 Plugins successfully compiled
Angelscript: 7 Plugins failed compilation

I don't know why that happens.
In addition, I have a problem with CBaseEntity@'s opCast(). I'm trying to make a group resurrect function, by taking all indexes from the map and verifying their distance to the player calling the function. Problem is, Revive() is only for CBasePlayer@ and CBaseMonster@, and whenever I try to use opCast() for CBaseEntity@, it seems it won't work for me.

Here's something small I tried with opcast() and opImplCast()


// currently only to get opCast()/opImplCast() working
void Resurrect(const CCommand@ args)
{
CBasePlayer@ Player = g_ConCommandSystem.GetCurrentPlayer();
CBaseEntity@ Test=Player.opImplCast();
}


Another question I have, is... how can I store data for each player on the current map? i'm thinking of one of those amxx /saveloc and /teleport plugins, but I didn't find any small plugin with only those 2 commands ,but giant ones with too many commands for me to figure it out myself.



:flmcraterm8:
In addition, I got some suggestions, unless they're already in and I'm not aware, or were already suggested:
-What about some float multipliers for monsters/players? damage/speed multiplier? attack speed multiplier? movement speed multiplier? animations speed multiplier? I'm thinking of a veterancy script, but I'd need such things, I don't know if it's currently possible...without model changing.

-A texture change function would be helpful. Doom I,II had the possibility to change map textures in real time by changing all textures of a certain type to another. Bonus if the new textures can be moving/animated, like func_conveyor's moving textures.

-Maybe an option to not start angelscript commands with "."?

-Ability to move a model's bones into another model. example of monster_gargantua with monster_gman in source engine: http://images.akamai.steamusercontent.com/ugc/550933323086555669/B065C08C3949B235143483550123ACE564E5FE7B/ I know there's trigger_setorigin with its flags to do some sort of "parenting", but nothing to control the bones.

-Probably asked before but, writing local text files? I know there's a read line command and some example for reading text files, but i'm still patiently waiting for the database support like MySQL, or just writing/saving files in the local angelscript directory, and not somewhere outside of it, for security reasons.

-Not something related to angelscript, but I think the media player needs something more than just some letters whose meaning must be discovered by continously trying songs and see what each letter does.

Solokiller
29-04-2016, 08:53 AM
If the server encounters an error while precaching, it will corrupt the Angelscript context (it also leaks memory). You have to restart the game to fix that. The cause of that problem won't be fixed, so don't expect that problem to go away. (some people think reloading dlls will fix it, but it will make the problem worse)

You're not supposed to call opCast and opImplCast. Those functions are used by Angelscript's built-in syntax. opImplCast is used to convert between types implicitly, so CBasePlayer@ converts to CBaseEntity@ on its own. opCast requires you to use cast<CBasePlayer@>( pEntity ).

I suggest you read the manual for more information on that: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_class_inheritance.html

Storing data for each player can be done by inserting each player into a dictionary, using their Steam ID as the key. The Teleport plugin shows how to do this and is pretty small.

Texture changes are not supported by the engine, but i don't recall anyone suggesting it before. You can use animated textures instead: http://twhl.info/forums.php?thread=7068
It's pretty limited, but it's something.

Commands start with '.' to prevent them from conflicting with existing and future commands, as well as map script commands.

Bone merging is not possible as far as i know of. That would require considerable changes in the engine to transmit such changes to clients.

Angelscript's file system is read only for security purposes, but if you need to be able to write files (and make them persist) i suggest starting a discussion on where these files should go. It hasn't been discussed before beyond the need to sandbox the file system to prevent abuse.
Database support isn't being worked on right now, but i might build a library to do that eventually. Can't say what the team is planning to do about that.

The media player is probably going to be updated when the new UI gets implemented. Can't tell you when that'll be.

w00tguy123
29-04-2016, 01:24 PM
Angelscript's file system is read only for security purposes, but if you need to be able to write files (and make them persist) i suggest starting a discussion on where these files should go. It hasn't been discussed before beyond the need to sandbox the file system to prevent abuse.

I think restricting file writes to the scripts directory is good enough, possibly in some sub-directory that scripts can't reside in (to prevent overwriting them). Anything beyond that is more trouble than it's worth.

There could be a unique folder for each script to prevent overwriting data for other scripts, but I think the script writers should just be responsible enough to not create a "data.txt" in a common directory.

Also, what about allowing file reads from outside the scripts directory? Being able to parse map resources could be pretty useful (http://forums.svencoop.com/showthread.php/43428-A-plugin-to-replace-res-files). I don't see how reading game content could be a security issue (apart from some special files like server.cfg).

Heaveny
29-04-2016, 01:35 PM
Ah, thanks, will read that manual.

Unfortunately I'm a shy guy when it comes to ask for features, as I expect people to disagree on them, such as the Damage/animation speed multipliers, or the file writing implementation, I hope someone else will post a thread for this. There is the g_Log.PrintF(...) which already writes log files somewhere.
I guess the root folder should be ..\scripts\plugins, and it would only write/overwrite files, not create files, otherwise certain plugins/map scripts could be malicious, or an annoyance spamming machine.
Anyways, I'll try to attempt to transform some entity from HL1 source code to a custom entity, while patiently waiting for someone to do a file writing suggestions, to finally get rid of that SCXPM and get something better.

edit: whoops, was too slow

Solokiller
29-04-2016, 01:35 PM
That's all possible. Adding support for reading files in particular directories is very easy. It's just that there was never any discussion on the matter.

Nero
30-04-2016, 04:45 PM
What's wrong with SCXPM? :o
I'm 1/3 done converting it to AS, but since AS can't write to file atm there is no way to save player's progress permanently (that I know of) :(