Page 1 of 1
Help with script PLZ
Posted: January 10th, 2011, 5:55 pm
by bigbabol
i made a trigger multiple and i want that when a player touches it, he returns to the position before the jump
for example mp_sonic water or the spikes in mp_cheops
pls help me
p.s:
peds i know u can help me

Re: Help with script PLZ
Posted: January 10th, 2011, 6:23 pm
by IzNoGoD
user maps\mp\gametypes\cj::loadpos(); or smthing might work too.
Not sure what is in the cj.gsc exactly though.
Re: Help with script PLZ
Posted: January 10th, 2011, 7:10 pm
by bigbabol

Killersam
I'm sorry but I did not mean that ....
the script works fine but the script teleports in the same spot no matter where jumps
I want that when a player touches the trigger back to exactly where he jumped as water mp_sonic
I do not know you understand what I mean
sorry for my english i used a translator
thanks anyway

Re: Help with script PLZ
Posted: January 10th, 2011, 9:48 pm
by Pedsdude
Hmm, I don't know the exact code for that, but given that it's DanTheMan's map I'm sure he does

Re: Help with script PLZ
Posted: January 11th, 2011, 4:00 am
by megazor
Code: Select all
teleport_onTouch()
{
yourmap_triga = getent("yourmap_triga","targetname");
while(1)
{
yourmap_triga waittill ("trigger",user);
wait .1;
if (isDefined(user.lastPosOnGround) && isPlayer(user)) //might have disconnected within .1 second :-)
user setOrigin(user.lastPosOnGround);
}
}
saveGroundPos()
{
while (1)
{
players = getEntArray("player", "classname");
for (i = 0; i < players.size; i++)
if (players[i].sessionstate == "playing" && players[i] isOnGround())
players[i].lastPosOnGround = players[i].origin;
wait .1;
}
}
Re: Help with script PLZ
Posted: January 11th, 2011, 2:53 pm
by bigbabol
megazor wrote:Code: Select all
teleport_onTouch()
{
yourmap_triga = getent("yourmap_triga","targetname");
while(1)
{
yourmap_triga waittill ("trigger",user);
wait .1;
if (isDefined(user.lastPosOnGround) && isPlayer(user)) //might have disconnected within .1 second :-)
user setOrigin(user.lastPosOnGround);
}
}
saveGroundPos()
{
while (1)
{
players = getEntArray("player", "classname");
for (i = 0; i < players.size; i++)
if (players[i].sessionstate == "playing" && players[i] isOnGround())
players[i].lastPosOnGround = players[i].origin;
wait .1;
}
}
thanks but doesn't work

Re: Help with script PLZ
Posted: January 11th, 2011, 3:37 pm
by Pedsdude
Did you thread both of them, and did you create a trigger_multiple across the area you need, giving it a "yourmap_triga" targetname?
Re: Help with script PLZ
Posted: January 11th, 2011, 4:06 pm
by bigbabol
Pedsdude wrote:Did you thread both of them, and did you create a trigger_multiple across the area you need, giving it a "yourmap_triga" targetname?
Yes i did

Re: Help with script PLZ
Posted: January 12th, 2011, 5:51 am
by megazor
so you have the following:
Code: Select all
main()
{
thread saveGroundPos();
thread teleport_onTouch();
}
ok, then let's do some debugging...
Code: Select all
teleport_onTouch()
{
trig = getent("yourmap_triga","targetname");
while(1)
{
trig waittill("trigger", user);
//wait .1;
if (!isDefined(user.lastPosOnGround))
user iPrintLn("no saved positions");
else
user setOrigin(user.lastPosOnGround);
}
}
saveGroundPos()
{
while (1)
{
players = getEntArray("player", "classname");
for (i = 0; i < players.size; i++)
{
if (isDefined(players[i].sessionstate) && players[i].sesionstate == "playing")
players[i] iPrintLn("I am playing, lolz");
if (players[i] isOnGround())
players[i] iPrintLn("I am on the ground, rofl");
if (players[i].sessionstate == "playing" && players[i] isOnGround())
players[i].lastPosOnGround = players[i].origin;
}
wait .1;
}
}
Re: Help with script PLZ
Posted: January 12th, 2011, 10:34 am
by IzNoGoD
Two things:
Check defined of self.sessionstate too, before saving, and use wait 0.05 for best results.
Btw, you might wanna delete the iprinlns xD 10 per second aint funny

Re: Help with script PLZ
Posted: January 12th, 2011, 1:55 pm
by bigbabol
megazor wrote:so you have the following:
Code: Select all
main()
{
thread saveGroundPos();
thread teleport_onTouch();
}
ok, then let's do some debugging...
Code: Select all
teleport_onTouch()
{
trig = getent("yourmap_triga","targetname");
while(1)
{
trig waittill("trigger", user);
//wait .1;
if (!isDefined(user.lastPosOnGround))
user iPrintLn("no saved positions");
else
user setOrigin(user.lastPosOnGround);
}
}
saveGroundPos()
{
while (1)
{
players = getEntArray("player", "classname");
for (i = 0; i < players.size; i++)
{
if (isDefined(players[i].sessionstate) && players[i].sesionstate == "playing")
players[i] iPrintLn("I am playing, lolz");
if (players[i] isOnGround())
players[i] iPrintLn("I am on the ground, rofl");
if (players[i].sessionstate == "playing" && players[i] isOnGround())
players[i].lastPosOnGround = players[i].origin;
}
wait .1;
}
}
THANKS!!! FINALLY WORKS!!!
the iprintlns are funny xD
Re: Help with script PLZ
Posted: January 12th, 2011, 4:10 pm
by megazor
ye, wait .05 is more accurate but it also loads server more than .1 does.