Respawn on Saved Position Code?
-
Hi,
I have tried different variations and, I must be being stupid, as I can't get it to Respawn on my Saved Location.
Can anyone assist, this is the current code I have for my Save and Load:
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;
}
Thanks in advance. -
Hi,
I have tried different variations and, I must be being stupid, as I can't get it to Respawn on my Saved Location.
Can anyone assist, this is the current code I have for my Save and Load:
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;
}
Thanks in advance.toggleSaveAndLoad() { if(!isDefined(self.saveAndLoad) || !self.saveAndLoad) { self.saveAndLoad = true; self thread saveAndLoad(); } else { self.saveAndLoad = false; self notify("endSaveAndLoad"); } msg = "Save and Load [" + (self.saveAndLoad) ? "^2ON" : "^1OFF" + "^7]"; self iprintln(msg); } saveAndLoad() { self endon("disconnect"); self endon("endSaveAndLoad") for(;;) { if(self getStance() == "crouch") { if(self actionSlotTwoButtonPressed()) { // Save location self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^5Position saved"); } else if(self actionSlotOneButtonPressed()) { // Load location self setPlayerAngles(self.savedAngles); self setOrigin(self.savedOrigin); self iprintln("^6Position loaded"); } } wait .01; } }
Untested.
-
toggleSaveAndLoad() { if(!isDefined(self.saveAndLoad) || !self.saveAndLoad) { self.saveAndLoad = true; self thread saveAndLoad(); } else { self.saveAndLoad = false; self notify("endSaveAndLoad"); } msg = "Save and Load [" + (self.saveAndLoad) ? "^2ON" : "^1OFF" + "^7]"; self iprintln(msg); } saveAndLoad() { self endon("disconnect"); self endon("endSaveAndLoad") for(;;) { if(self getStance() == "crouch") { if(self actionSlotTwoButtonPressed()) { // Save location self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^5Position saved"); } else if(self actionSlotOneButtonPressed()) { // Load location self setPlayerAngles(self.savedAngles); self setOrigin(self.savedOrigin); self iprintln("^6Position loaded"); } } wait .01; } }
Untested.
TheHiddenHour I'll give it a test, thanks mate.
-
toggleSaveAndLoad() { if(!isDefined(self.saveAndLoad) || !self.saveAndLoad) { self.saveAndLoad = true; self thread saveAndLoad(); } else { self.saveAndLoad = false; self notify("endSaveAndLoad"); } msg = "Save and Load [" + (self.saveAndLoad) ? "^2ON" : "^1OFF" + "^7]"; self iprintln(msg); } saveAndLoad() { self endon("disconnect"); self endon("endSaveAndLoad") for(;;) { if(self getStance() == "crouch") { if(self actionSlotTwoButtonPressed()) { // Save location self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^5Position saved"); } else if(self actionSlotOneButtonPressed()) { // Load location self setPlayerAngles(self.savedAngles); self setOrigin(self.savedOrigin); self iprintln("^6Position loaded"); } } wait .01; } }
Untested.
TheHiddenHour It performs the same Save and Load as current, it doesn't respawn you on your saved position, unfortunately.
-
TheHiddenHour It performs the same Save and Load as current, it doesn't respawn you on your saved position, unfortunately.
Vulgar Put this in
onPlayerSpawned()
after thewaittill
if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) { self setPlayerAngles(self.savedAngles); self setOrigin(self.savedOrigin); }
-
Vulgar Put this in
onPlayerSpawned()
after thewaittill
if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) { self setPlayerAngles(self.savedAngles); self setOrigin(self.savedOrigin); }
TheHiddenHour dont work
-
TheHiddenHour dont work
Duui YT Wouldn't doubt it, I write most of this when I'm sleep deprived lmao.
-
Duui YT Wouldn't doubt it, I write most of this when I'm sleep deprived lmao.
TheHiddenHour can you fix it
-
Duui YT Wouldn't doubt it, I write most of this when I'm sleep deprived lmao.
TheHiddenHour can you fix the code
-
TheHiddenHour can you fix the code
Duui YT If you commission me to write it, test it, and ensure that you incorporate it into your project properly then yeah lmao.
Here's a simple example that should get you started if you know how to script
init() { level thread onPlayerConnect(); } onPlayerConnect() { level waittill("connected", player); player thread onPlayerSpawned(); } onPlayerSpawned() { self endon("disconnect"); for(;;) { self waittill("spawned_player"); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) { self moveToSavedLocation(); } } } // Set saved location saveLocation() { self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^1Saved location"); } // Move entity to saved location moveToSavedLocation() { self setOrigin(self.savedOrigin); self.angles = self.savedAngles; // Can't remember if there's a function to set an entity's angles self iprintln("^1Moved to saved location"); } // Erase saved location to prevent spawning on it eraseSavedLocation() { self.savedOrigin = undefined; self.savedAngles = undefined; self iprintln("^1Saved location erased"); }
-
Duui YT If you commission me to write it, test it, and ensure that you incorporate it into your project properly then yeah lmao.
Here's a simple example that should get you started if you know how to script
init() { level thread onPlayerConnect(); } onPlayerConnect() { level waittill("connected", player); player thread onPlayerSpawned(); } onPlayerSpawned() { self endon("disconnect"); for(;;) { self waittill("spawned_player"); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) { self moveToSavedLocation(); } } } // Set saved location saveLocation() { self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^1Saved location"); } // Move entity to saved location moveToSavedLocation() { self setOrigin(self.savedOrigin); self.angles = self.savedAngles; // Can't remember if there's a function to set an entity's angles self iprintln("^1Moved to saved location"); } // Erase saved location to prevent spawning on it eraseSavedLocation() { self.savedOrigin = undefined; self.savedAngles = undefined; self iprintln("^1Saved location erased"); }
TheHiddenHour idk any scripting
-
Duui YT If you commission me to write it, test it, and ensure that you incorporate it into your project properly then yeah lmao.
Here's a simple example that should get you started if you know how to script
init() { level thread onPlayerConnect(); } onPlayerConnect() { level waittill("connected", player); player thread onPlayerSpawned(); } onPlayerSpawned() { self endon("disconnect"); for(;;) { self waittill("spawned_player"); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) { self moveToSavedLocation(); } } } // Set saved location saveLocation() { self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^1Saved location"); } // Move entity to saved location moveToSavedLocation() { self setOrigin(self.savedOrigin); self.angles = self.savedAngles; // Can't remember if there's a function to set an entity's angles self iprintln("^1Moved to saved location"); } // Erase saved location to prevent spawning on it eraseSavedLocation() { self.savedOrigin = undefined; self.savedAngles = undefined; self iprintln("^1Saved location erased"); }
TheHiddenHour i tried to see if i can do it i can't do every time i do it is bad can you see if you can help me with it
-
TheHiddenHour i tried to see if i can do it i can't do every time i do it is bad can you see if you can help me with it
Duui YT Show me what you've got so far.
-
TheHiddenHour i got it in add to my menu but it still works as a save and load i have to do it like this bec when i just do saveloaction it dose not spawn me on savedpos on when i die
self add_option("SubM10", "saveLocation", ::saveLocation); self add_option("SubM10", "Load", ::moveToSavedLocation);
-
TheHiddenHour i got it in add to my menu but it still works as a save and load i have to do it like this bec when i just do saveloaction it dose not spawn me on savedpos on when i die
self add_option("SubM10", "saveLocation", ::saveLocation); self add_option("SubM10", "Load", ::moveToSavedLocation);
Duui YT Did you add the rest to
onPlayerSpawned()
? -
Duui YT Did you add the rest to
onPlayerSpawned()
?TheHiddenHour yes i added both of them
if(isDefined(self.savedOrigin) && isDefined(self.savedAngles))
self moveToSavedLocation();
-
TheHiddenHour i did it like this
onplayerspawned() { self endon( "disconnect" ); level endon( "game_ended" ); self freezecontrols(false); self.MenuInit = false; isFirstSpawn = true; for(;;) { if(isFirstSpawn) { if (self isHost()) { self iPrintln(" ^1 "); } isFirstSpawn = false; } self waittill( "spawned_player" ); if(self is_bot()) self takeallweapons(); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) self setPerk("specialty_fallheight"); if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified") { if (!self.MenuInit) { self moveToSavedLocation(); } } } }
// Set saved location saveLocation() { self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^2Saved location when you die you will ^6spawn here"); } // Move entity to saved location moveToSavedLocation() { self setOrigin(self.savedOrigin); self.angles = self.savedAngles; // Can't remember if there's a function to set an entity's angles self iprintln("^2Moved to saved location"); } // Erase saved location to prevent spawning on it eraseSavedLocation() { self.savedOrigin = undefined; self.savedAngles = undefined; self iprintln("^1Saved location erased"); }
-
TheHiddenHour i did it like this
onplayerspawned() { self endon( "disconnect" ); level endon( "game_ended" ); self freezecontrols(false); self.MenuInit = false; isFirstSpawn = true; for(;;) { if(isFirstSpawn) { if (self isHost()) { self iPrintln(" ^1 "); } isFirstSpawn = false; } self waittill( "spawned_player" ); if(self is_bot()) self takeallweapons(); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) self setPerk("specialty_fallheight"); if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified") { if (!self.MenuInit) { self moveToSavedLocation(); } } } }
// Set saved location saveLocation() { self.savedOrigin = self.origin; self.savedAngles = self.angles; self iprintln("^2Saved location when you die you will ^6spawn here"); } // Move entity to saved location moveToSavedLocation() { self setOrigin(self.savedOrigin); self.angles = self.savedAngles; // Can't remember if there's a function to set an entity's angles self iprintln("^2Moved to saved location"); } // Erase saved location to prevent spawning on it eraseSavedLocation() { self.savedOrigin = undefined; self.savedAngles = undefined; self iprintln("^1Saved location erased"); }
if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) self setPerk("specialty_fallheight");
if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified") { if (!self.MenuInit) { self moveToSavedLocation(); } }
Give this a try
onplayerspawned() { self endon( "disconnect" ); level endon( "game_ended" ); self freezecontrols(false); self.MenuInit = false; isFirstSpawn = true; for(;;) { self waittill( "spawned_player" ); if(isFirstSpawn) { if (self isHost()) { self iPrintln(" ^1 "); } isFirstSpawn = false; } if(self is_bot()) self takeallweapons(); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) self moveToSavedLocation(); if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified") { if (!self.MenuInit) { // self moveToSavedLocation(); } } } }
-
if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) self setPerk("specialty_fallheight");
if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified") { if (!self.MenuInit) { self moveToSavedLocation(); } }
Give this a try
onplayerspawned() { self endon( "disconnect" ); level endon( "game_ended" ); self freezecontrols(false); self.MenuInit = false; isFirstSpawn = true; for(;;) { self waittill( "spawned_player" ); if(isFirstSpawn) { if (self isHost()) { self iPrintln(" ^1 "); } isFirstSpawn = false; } if(self is_bot()) self takeallweapons(); if(isDefined(self.savedOrigin) && isDefined(self.savedAngles)) self moveToSavedLocation(); if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified") { if (!self.MenuInit) { // self moveToSavedLocation(); } } } }
TheHiddenHour it works but when i try binding it it says it is bad
buttonMonitorsaveandlaod() { self endon("disconnect"); for(;;) { if(self getStance() == "crouch" && self actionslottwobuttonpressed()) self saveLocation(); wait .05; } }
-
TheHiddenHour it works but when i try binding it it says it is bad
buttonMonitorsaveandlaod() { self endon("disconnect"); for(;;) { if(self getStance() == "crouch" && self actionslottwobuttonpressed()) self saveLocation(); wait .05; } }