[Support] Save and load disabled

Topic created · 9 Posts · 103 Views
  • i just added save and load on my server and its all good untill you join the server and it says save and load disabled. anybody know how to fix

  • Maybe show code?
    Not quite sure what sort of answers you expect with the current state of your question.

  • @Ox_ saveandload()

    {

    if (self.snl == 0)
    
    {
    
        self iprintln("^5Save and Load Enabled");
    
        self iprintln("Crouch and Press [{+actionslot 2}] To Save");
    
        self iprintln("Crouch and Press [{+actionslot 1}] To Load");
    
        self thread dosaveandload();
    
        self.snl = 1;
    
    }
    
    else
    
    {
    
        self iprintln("^1Save and Load Disabled");
    
        self.snl = 0;
    
        self notify("SaveandLoad");
    
    }
    

    }
    dosaveandload()

    {

    self endon("disconnect");
    
    self endon("SaveandLoad");
    
    load = 0;
    
    for(;;)
    
    {
    
    if (self actionslottwobuttonpressed() && self GetStance() == "crouch" && self.snl == 1)
    
    {
    
        self.o = self.origin;
    
        self.a = self.angles;
    
        load = 1;
    
        self iprintln("^5Position Saved");
    
        wait 2;
    
    }
    
    if (self actionslotonebuttonpressed() && self GetStance() == "crouch" && load == 1 && self.snl == 1)
    
    {
    
        self setplayerangles(self.a);
    
        self setorigin(self.o);
    
    }
    
    wait 0.05;
    

    }

    }

    And self thread saveandload(); in onPlayerSpawned() {

  • @lula said in Save and load disabled:

    @Ox_ saveandload()

    {

    if (self.snl == 0)
    
    {
    
        self iprintln("^5Save and Load Enabled");
    
        self iprintln("Crouch and Press [{+actionslot 2}] To Save");
    
        self iprintln("Crouch and Press [{+actionslot 1}] To Load");
    
        self thread dosaveandload();
    
        self.snl = 1;
    
    }
    
    else
    
    {
    
        self iprintln("^1Save and Load Disabled");
    
        self.snl = 0;
    
        self notify("SaveandLoad");
    
    }
    

    }
    dosaveandload()

    {

    self endon("disconnect");
    
    self endon("SaveandLoad");
    
    load = 0;
    
    for(;;)
    
    {
    
    if (self actionslottwobuttonpressed() && self GetStance() == "crouch" && self.snl == 1)
    
    {
    
        self.o = self.origin;
    
        self.a = self.angles;
    
        load = 1;
    
        self iprintln("^5Position Saved");
    
        wait 2;
    
    }
    
    if (self actionslotonebuttonpressed() && self GetStance() == "crouch" && load == 1 && self.snl == 1)
    
    {
    
        self setplayerangles(self.a);
    
        self setorigin(self.o);
    
    }
    
    wait 0.05;
    

    }

    }

    And self thread saveandload(); in onPlayerSpawned() {

    I'd assume you probably never define self.snl? You should define it before using it.
    Also toggling it on/off every time the player spawns in doesn't sound very good to me.

  • @Ox_ what do i do to define it

  • @lula Just as a reminder, the scripts you can find in the forum are mostly samples that are here to help people having a working script, so you can build your own mod around that. Copy pasting stuff and praying for the best doesn't always work.

    Not to mention that the script itself is pretty shitty tbh, since that saveandload() function does nothing but swap the values of self.snl between 1 and 0, so you should DEFINETLY NOT call that in your onPlayerSpawned() if you want this to work correctly.


    What I would do is completely get rid of the saveandload() function, and instead call dosaveandload() in your onPlayerSpawned(). Maybe save the "Crouch and Press" iprintlns to paste them at the start of dosaveandload(), between self endon("SaveandLoad"); and load = 0;, so you still have the explaination text popping up.

    Then in your OnPlayerConnect(), put player.snl = 1; between the closest brackets, and every user who connects will be able to use the Save & Load thing. If you have some kind of VIP check or anything, you can use it in your OnPlayerConnect() function to either grant the SnL or not, like this for example :

    // This doesn't actually work unless the isVip function exists, this is only an example...
    if(player isVip())
        player.snl = 1;
    else
        player.snl = 0;
    
  • Thanks Thats nice to know

  • For me I just completely removed the toggle. So delete the part that makes it disabled and anything else to do with disabling it.

  • This post is deleted!
Log in to reply