Posts: 26
Threads: 6
Joined: Aug 2013
Reputation:
1
07-03-2014, 19:31
(This post was last modified: 07-03-2014, 20:13 by zurasaur.)
Hi, I'm relatively new to scripting.
I want to be able to move from a spot where I'm standing, to another position.
This code works, however i need it so i gradually move positions instead of instantly teleporting.
could any ones brilliant scripting knowledge tell me how i could do this please. Im sorry if this was a noob question
I've got this code in my gsc at the moment
Code: savePos()
{
self endon("disconnect");
self notifyOnPlayerCommand("save", "save");
for ( ;; )
{
self waittill("save");
self.saved_origin = self.origin;
self.saved_angles = self.angles;
}
}
loadPos()
{
self endon("disconnect");
self notifyOnPlayerCommand("load", "load");
for ( ;; )
{
self waittill("load");
self freezecontrols(true);
wait 0.05;
self setPlayerAngles(self.saved_angles);
self setOrigin(self.saved_origin);
self freezecontrols(false);
}
}
Posts: 592
Threads: 67
Joined: Apr 2012
Reputation:
17
07-03-2014, 19:58
(This post was last modified: 07-03-2014, 20:00 by RaZ.)
(07-03-2014, 19:31)zurasaur Wrote: Hi, I'm relatively new to scripting.
I want to be able to move from a spot where I'm standing, to another position.
This code works, however i need it so i gradually move positions instead of instantly teleporting.
could any ones brilliant scripting knowledge tell me how i could do this please. Im sorry if this was a noob question
I've got this code in my gsc at the moment
PHP Code: savePos() { self endon("disconnect"); self notifyOnPlayerCommand("save", "save"); for ( ;; ) { self waittill("save"); self.saved_origin = self.origin; self.saved_angles = self.angles; } }
loadPos() { self endon("disconnect"); self notifyOnPlayerCommand("load", "load");
for ( ;; ) { self waittill("load"); self freezecontrols(true); wait 0.05; self setPlayerAngles(self.saved_angles); self setOrigin(self.saved_origin); self freezecontrols(false); } }
Use Insert formatted code or Insert formatted PHP code if you paste any code.
So you want to automatically go to Y position from X? Like a BOT?
Posts: 26
Threads: 6
Joined: Aug 2013
Reputation:
1
07-03-2014, 20:12
(This post was last modified: 07-03-2014, 20:14 by zurasaur.)
(07-03-2014, 19:58)RaZ Wrote: (07-03-2014, 19:31)zurasaur Wrote: Hi, I'm relatively new to scripting.
I want to be able to move from a spot where I'm standing, to another position.
This code works, however i need it so i gradually move positions instead of instantly teleporting.
could any ones brilliant scripting knowledge tell me how i could do this please. Im sorry if this was a noob question
I've got this code in my gsc at the moment
PHP Code: savePos() { self endon("disconnect"); self notifyOnPlayerCommand("save", "save"); for ( ;; ) { self waittill("save"); self.saved_origin = self.origin; self.saved_angles = self.angles; } }
loadPos() { self endon("disconnect"); self notifyOnPlayerCommand("load", "load");
for ( ;; ) { self waittill("load"); self freezecontrols(true); wait 0.05; self setPlayerAngles(self.saved_angles); self setOrigin(self.saved_origin); self freezecontrols(false); } }
Use Insert formatted code or Insert formatted PHP code if you paste any code.
So you want to automatically go to Y position from X? Like a BOT?
yes exactly, just not instantly. i want the player to move gradually.
sorry for not formatting correctly
Posts: 3,704
Threads: 147
Joined: Jan 2011
Reputation:
119
Use for loop with 'wait 0.1;' or less.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Posts: 26
Threads: 6
Joined: Aug 2013
Reputation:
1
(07-03-2014, 20:17)SailorMoon Wrote: Use for loop with 'wait 0.1;' or less.
i have read a loops tutorial by yamato, and i understand loops. but im not sure i understand what exactly i should loop , could you explain or give me a pointer pretty please?
Posts: 2,157
Threads: 120
Joined: Apr 2011
Reputation:
71
i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:
I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @ Yamato has a tutorial for moving objects.
Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?
Posts: 26
Threads: 6
Joined: Aug 2013
Reputation:
1
(07-03-2014, 21:14)Rendflex Wrote: i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:
I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.
Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?
Really helps, ill give it a try now
Posts: 26
Threads: 6
Joined: Aug 2013
Reputation:
1
07-03-2014, 23:34
(This post was last modified: 07-04-2014, 00:04 by zurasaur.)
(07-03-2014, 21:14)Rendflex Wrote: i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:
I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.
Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?
completely solved my initial issue, thanks a lot man.
only issue I'm having now is not being able to unlink the object. not sure on the function to do it.
(07-03-2014, 23:34)zurasaur Wrote: (07-03-2014, 21:14)Rendflex Wrote: i'm on my phone right now, so it'd sadly take too long to write actual code, but ill try to explain:
I assume you want to move the player rather than teleport, right? Make an invisible script_model, and link the player to that model using the playerlinktodelta function. Move the model using the moveto function. When the moving is finished, unlink the player. I think @Yamato has a tutorial for moving objects.
Look up the list of all cod gsc functions, it'll help a lot! Should be on zeroy's site. If anyone has the time, mind posting it?
completely solved my initial issue, thanks a lot man.
only issue I'm having now is not being able to unlink the object. not sure on the function to do it.
/solved
thanks to everyone who helped
|