ReloadScripts(); on a base system

Started by Mötley, Sep 01, 2016, 11:04 PM

Previous topic - Next topic

Mötley

Is there proper methods of using ReloadScripts(); on a base system?

I have encountered errors where the system does not reload the entire scripts causing what needs to be reloaded to have glitches "I really need to reload certain scripts over a period of time, Regarding a loop method'".

Any help is highly appreciated..

KAKAN

just do dofile again, I think it will work :)
oh no

EK.IceFlake

What does it not reload more specifically?
If you're talking about the cars and objects, they are implemented in the VCMP API, not squirrel. The reloadscripts function is on the squirrel plugin.
All it does is simply close the script and open it again. The cars and objects are already created, as they are by the vcmp api not the squirrel plugin. The squirrel plugin just calls the object and vehicle functions in the vcmp api.

Mötley

Well when I put the entire server into one file and use reloadscripts() The loop method isn't bugged anymore, neither is re logging into your account, no clue what is the true cause to this. Maybe I am the only one that has experienced this, or noticed this.

The loop method isn't a shity method/shity script, It just needs reloading over a course of time as it eventually becomes bugged in certain aspects,.

KAKAN were are you suggesting to use dofile again?

also am I supposed to write a string inside of reloadscripts() possibly?

Maybe:
Reloadscripts("Scripts/Mbs/Mbs.nut");
Reloadscripts("Scripts/Mbs/Mbs-Account-System.nut");
Reloadscripts("Scripts/Mbs/Mbs-Death-System.nut");
Reloadscripts("Scripts/Mbs/Mbs-Vehicle-System.nut");

EK.IceFlake

I dont get what you are saying, but let me make a guess
The wise option is to set a value to 1 on ini when reloading, if the value is 1 when onscriptload, dont call some car, etc functions, and make a loop that calls onPlayerJoin (the reason onplayerjoin otherwise not working is onplayerjoin is a vcmp api event, not squirrel, the plugin just echoes it to squirrel) for every player and a loop onplayerpart right before reloadscripts

Xmair

ReloadScripts calls the onScriptUnload and onScriptLoad events.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

EK.IceFlake

Yes...
but onscriptload might have some functiosn to create vehicles... they are now recreated
it also doesnt call onplayerpart and onplayerjoin

KAKAN

No motley, you can't pass a string into the reloadscripts function. But for sure, you can manually call the functions.
oh no

Mötley

#8
I already preformed a manual call for onScriptUnload(), I would like to believe that ReloadScripts() is a bugged when refering to base systems

When I have time I will play with http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Functions/Script::LoadScript

And see if this fixes my issue

KAKAN

Quote from: Mötley on Sep 02, 2016, 01:36 PMI already preformed a manual call for onScriptUnload(), I would like to believe that ReloadScripts() is a bugged when refering to base systems
No, reloadscript does it work. it's your system which isn't configured for it.
oh no

Mötley

Then how would this be configured? Never had an issue with it until using a base

KAKAN

Quote from: Mötley on Sep 02, 2016, 01:39 PMThen how would this be configured? Never had an issue with it until using a base
Take this as an example:-
function onScriptLoad(){
/*Normally, you do like this: LoadLotofVehicles();
But since, we need to check whether it's a reload or a startup, we will use something like this:-
*/
if( GetVehicleCount() < 1 ) LoadLotOfVehicles();
else local restart = true;
if( restart ) DoSomething();
}
/* now, we will manually call the functions. */
function DoSomething(){
for( local plr, id = 0; id<100; id++ ){
plr = FindPlayer(id);
if( plr ) onPlayerJoin( plr ); //Manually call the function. That's why we exist.
else if( plr.IsSpawned ) onPlayerSpawn( plr ); //That's how you do it.
}
}
Hope you got me :)
oh no

Mötley

Quote from: KAKAN on Sep 02, 2016, 05:40 PM
Quote from: Mötley on Sep 02, 2016, 01:39 PMThen how would this be configured? Never had an issue with it until using a base
Take this as an example:-
function onScriptLoad(){
/*Normally, you do like this: LoadLotofVehicles();
But since, we need to check whether it's a reload or a startup, we will use something like this:-
*/
if( GetVehicleCount() < 1 ) LoadLotOfVehicles();
else local restart = true;
if( restart ) DoSomething();
}
/* now, we will manually call the functions. */
function DoSomething(){
for( local plr, id = 0; id<100; id++ ){
plr = FindPlayer(id);
if( plr ) onPlayerJoin( plr ); //Manually call the function. That's why we exist.
else if( plr.IsSpawned ) onPlayerSpawn( plr ); //That's how you do it.
}
}
Hope you got me :)
I got you and I fully understand.

My loop method is on a timer of course. and the scripts are in first order of course.
When the scripts are reloaded it acts as if they are not and are only partially removed from memory, yet never loaded. causing many functions to not exist.

I just did a retest and other than the server acting strange when doing a call for dofile on scriptunload() the loop method works just fine, So I am taking it that onScriptload is not being called for some strange reason, As I did a manual call onScriptload and it works better but I know thats not correct either, My only real fix would be to put everything into one Main.nut..,,


Thijn

I think the question you should be asking is why your script needs a reload for it to not bug out...