AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Mattie's Plugins (https://forums.alliedmods.net/forumdisplay.php?f=71)
-   -   HOWTO: exec'ing files from within a script pack (https://forums.alliedmods.net/showthread.php?t=38233)

Ace Rimmer 06-05-2005 10:42

HOWTO: exec'ing files from within a script pack
 
A few more questions about Script Packs:

If I type "eventscripts_register" in the console, I recieve "unknown command" as response, even if I type rcon first. Anybody an ideas?

About writing a script pack...

I have had great trouble with this and I think I have missed someting really obvious so I woudl like to give you a small example:

Let us say I have a script pack called "pull_the _babes"

the script contains three files:

player_say.cfg

and

pull_the_babes.cfg
hump_on_3.cfg

now I'm pretty sure I have to put all 3 files in a folder called "pull_the_babes" which goes into the "events" folder?

I then have to register the script by putting:
eventscripts_register pull_the_babes in my autoexec or server.cfg?

The BIG trouble is when writing the actual code:
If player_say has a command that says - "es if server_var(babe = "wants_a_shag") then exec hump_on_3.cfg" how will I write this line to reference the hump_on_3.cfg file? (obviously this is not real code).

I did try this with my acematch script but it woudln't work at all so I had to resort to making the install a copy and paste job.

Can you explain please how to refernce config files within a script?

Thanks and best regards.

Mattie 06-05-2005 11:44

Quote:

Originally Posted by Ace Rimmer
If I type "eventscripts_register" in the console, I recieve "unknown command" as response, even if I type rcon first. Anybody an ideas?

Well, the command doesn't work great through rcon if you're trying to list active script packs. (It's like plugin_print in that regard.) You really can only rely on it listing things if you do it from the server console.

That being said, I use "ma_rcon eventscripts_register firebug" all the time. (Be careful when using "rcon" because rcon likes to put quotes around everything and that will confuse eventscripts_register.)

Quote:

I have had great trouble with this and I think I have missed someting really obvious so I woudl like to give you a small example
Let's start with the Script Pack documentation in the EventScripts doc:
Quote:

Script Packs
EventScripts v0.7.5 introduced the concept of 'script packs' that can be enabled and disabled at will. Basically a script pack developer can specify the following things when he provides a group of related event scripts:
  • 1. A command that activates the script pack for you to place in autoexec.cfg (or to type in when you want). This is typically of the form of eventscripts_register scriptpackname. For example, "eventscripts_register firebug".
    2. A command that de-activates the script pack. This is typically of the form of eventscripts_unregister scriptpackname. For example, "eventscripts_unregister firebug".
    3. The subdirectory under eventscripts_subdirectory where you must place these. This must be the name of the script pack you use when you call eventscripts_register.
For example, I could create a group of scripts that provide "FireBug" functionality. I'd provide a zipfile of the scripts and any users who wanted to use it would extract those into their (e.g.) cfg/events/firebug directory. In order to turn on the scripts, they'd just issue "eventscripts_register firebug" from the console. To disable them for the next map, they'd issue "eventscripts_unregister firebug".

In addition to typical event cfg files (e.g. round_start.cfg), script pack developers might include extra functionality in traditional .cfg files. Whenever a script pack is registered, a server variable is created that provides the directory to the script pack to use with the 'exec' command. It's of the form "scriptpackname_dir".

Script pack developers can also provide their own 'server.cfg' file that exists in the script pack subdirectory. This will be executed whenever a new map is loaded since there aren't a lot of good events for this sort of thing.
Take a look at the second to last paragraph. Does it answer the question?

Here's how my FireBug example does it:
Quote:

es_setinfo buildbugfirst.cfg 0
es_setinfo buildbug.cfg 0
es_format buildbugfirst.cfg "%1%2" server_var(firebug_dir) buildbugfirst.cfg
es_format buildbug.cfg "%1%2" server_var(firebug_dir) buildbug.cfg
// ...
es exec server_var(buildbug.cfg)
There are also examples of how to use this in Ajax's script packs. He included a workaround in his more recent ones to help resolve the issue with some Linux machines being particular about the slash direction (i.e. / vs. \).

-Mattie

Ace Rimmer 06-05-2005 12:49

Thanks Mattie. You'll have to trust me that I had read as much as I could of all the documentation. I must have missed the paragraph you directed me to. That has given me something to try now, thanks...

btw I don't have command line acees to my server it is rented so I have rcon only. So again, your explanation makes sense there too.

Thanks again.

:D :D :D

Ace Rimmer 06-05-2005 13:04

Nope I still don't get it, sorry.

Please can you just show me the script:

my scriptpack is called "acematch" I have all the config files in folder events/acematch/

what do i need to change in order to exec acematchgo.cfg for example?

instead of "exec acematchgo.cfg"

I would put "es exec server_var(acematch_dir) acematchgo.cfg"

Is that correct?

Sorry to be a pain on this, it is beating me...

Mattie 06-05-2005 13:13

Quote:

Originally Posted by Ace Rimmer
Nope I still don't get it, sorry.

Please can you just show me the script:

my scriptpack is called "acematch" I have all the config files in folder events/acematch/

what do i need to change in order to exec acematchgo.cfg for example?

instead of "exec acematchgo.cfg"

I would put "es exec server_var(acematch_dir) acematchgo.cfg"

Is that correct?

Sorry to be a pain on this, it is beating me...

Code:

es_setinfo acematchgoCFG 0
es_format acematchgoCFG "%1%2" server_var(acematch_dir) acematchgo.cfg
// ...
es exec server_var(acematchgoCFG)


ajax 06-05-2005 13:18

Mattie, perhaps we could break this into a thread of its own so that people trying to INSTALL a script pack don't get confused by these questions about how to CREATE a script pack.

Quote:

Originally Posted by Ace Rimmer
what do i need to change in order to exec acematchgo.cfg for example?

instead of "exec acematchgo.cfg"

I would put "es exec server_var(acematch_dir) acematchgo.cfg"

Is that correct?

not really but you are getting closer. you would need to set up the var in your acematch\server.cfg
Code:

// acematch\server.cfg
es_setinfo acematchgo.cfg 0
es_format acematchgo.cfg "%1%2" server_var(acematch_dir) acematchgo.cfg

then in the location from which you want to execute it...
Code:

es exec server_var(acematchgo.cfg)
like i said in the es_format thread, this is fairly confusing. see that thread for a more in-depth explanation.

maybe this would be a little less confusing...
Code:

// acematch\server.cfg
es_setinfo acematchgo_path_and_file 0
es_format acematchgo_path_and_file "%1%2" server_var(acematch_dir) acematchgo.cfg

Code:

es exec server_var(acematchgo_path_and_file)

Ace Rimmer 06-05-2005 14:27

Thanks guys, I may well have to ask some moe embarrassing questions once i have had chance to try this. :)

Ace Rimmer 06-10-2005 10:33

Mattie? Is it worth editing some of the crap out of here and making this sticky, before it gets knocked off the front page?

Mattie 06-10-2005 10:38

Quote:

Originally Posted by Ace Rimmer
Mattie? Is it worth editing some of the crap out of here and making this sticky, before it gets knocked off the front page?

* sigh *

I might need to finalize my own phpbb so I can have multiple sections/forums. Before long the whole front is going to be covered in stickies. Hmmmmmm....

ichthys 06-10-2005 15:48

Quote:

Originally Posted by Mattie
Quote:

Originally Posted by Ace Rimmer
Mattie? Is it worth editing some of the crap out of here and making this sticky, before it gets knocked off the front page?

* sigh *

I might need to finalize my own phpbb so I can have multiple sections/forums. Before long the whole front is going to be covered in stickies. Hmmmmmm....

good idea


All times are GMT -4. The time now is 14:08.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.