Author Topic: Executing console commands with addon files  (Read 2918 times)

I basically want to execute whatever is in script.cs, using chat. This is my code ( just the part where i want to execute script.cs )
Code: [Select]
if(%msg $= "#bot exec script.cs"){
exec("Add-ons/client_bot/script.cs");
commandToServer('messageSent',"ChatBot: Executed script.cs");
}
That gives me the following error (part where it gives the ##)
Code: [Select]
exec("Add-ons/client_bot/script.cs");
commandToServer(##'##messageSent',"ChatBot: Executed script.cs");
If I remove the exec(""); client.cs loads normally.
So can somebody help with this?
I need something that executes console commands using client.cs, because I use exec("Add-ons/client_bot/client.cs"); myself when I want to test my addon

I'm going to take a guess and say that your executing this code from the console, while ingame. Honestly, I don't know why, but as far as I can tell, whenever you want to execute anything in a zip folder (or just do it anyway), do "setModPaths(getModPaths());" before executing. I have no idea what side effects (if any) this has. It does cause a 1-2 second lag when doing this. Works client sided and server sided. This does not allow new datablocks to be loaded.

The console ##error## system is an approximation of where the error is. Try commenting out that line and seeing if the error is still present, and if it is what line it has moved to.

post more lines before this error

The file with #bot etc is my client.cs file in the FOLDER client_chatbot. I want to execute code from script.cs that is inside client_chatbot using client.cs. As you can see I tried doing exec("Add-ons/client_chatbot/script.cs"); as I used to do this inside the game console, but that didn't work. I commented the whole exec(""); line out and the error was gone.


update: i had no ; after exec(") hahaha thanks for help anyway

Syntax is very important.

I suggest you read up on it.