Could someone correct this small plugin?
Howdy,
I wrote this small plugin tonight (or maybe I should say modified it from a much larger one) as an intro for myself to Pawn. Unfortunately I seemed to have made at least one mistake (probably more). It compiles with no errors, and shows up on my plugin list, but it doesn't seem to actually load up the cvars from my database (though it did correctly create the table). I added the command so that I could test it while I was in the server, and whenever I run it it also fails to get my cvars from the database. In addition, it seems to freeze up the server for about 10 seconds, where I get a "Warning, connection problem" in the upper right hand corner... then it unfreezes and continues to work. Here it is: Code:
/* Plugin generated by AMXX-Studio */Thanks! |
Re: Could someone correct this small plugin?
You don't need to connect to DB everytime when you type amx_check_cvars.
|
Re: Could someone correct this small plugin?
Ah, so I would leave the connection up and just end it with plugin_end?
|
Re: Could someone correct this small plugin?
I'll be honest, I've been messing with it and it just seems to get worse. I'm guessing that I'm not going the right direction with this.
Does anyone know of perhaps an example script that already exists that I might use to learn from? |
Re: Could someone correct this small plugin?
Example of connection:
PHP Code:
|
Re: Could someone correct this small plugin?
Thanks for that example, I appreciate that! How would you apply a query?
In the examples I found, they had set the connection to a variable and used that variable later for queries. Is that just an optional parameter in case of multiple connections perhaps? |
Re: Could someone correct this small plugin?
Quote:
PHP Code:
|
Re: Could someone correct this small plugin?
Thanks a ton!
I'll work with it tonight and see if I can correct my mistakes with a modified version of your code and post the result. Thanks for your help! |
Re: Could someone correct this small plugin?
Alright, I spent a lot of time working on it, and it's doing pretty well now. I'd like to add some more features, but then I'll post it for anyone who wants to use it, and I'll credit you for your great help.
The main problem was actually totally unrelated to my script (my sql connection was terrible, I found a new host and it's working great now), but I still much prefer the idea of connecting just once rather than every time I do an update. Right now my script properly reads from the mysql table, and sets the cvars correctly. If you update a value in the table, you can use a command to have the server check the table and update the values accordingly. If anyone is interested, I can post my current progress. I am having a little trouble working this out though: The plugin (thankfully) properly yields to map settings at the start, but if you use the amx_get_cvars command (which grabs the values off the table and updates the server), it of course overwrites them. My thoughts are that perhaps I should just leave it the way it is, and people should be aware not to do that.. but I'd like a more ellegant solution if anyone has any ideas. Thanks! |
Re: Could someone correct this small plugin?
If you will have serious problems just post them here, there are many peoples that can help you here.
|
| All times are GMT -4. The time now is 02:18. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.