Help with script PLZ

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
bigbabol
CJ Newbie
CJ Newbie
Posts: 50
Joined: January 9th, 2011, 11:13 am

Help with script PLZ

Post by bigbabol » January 10th, 2011, 5:55 pm

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 :mrgreen:

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Help with script PLZ

Post by IzNoGoD » January 10th, 2011, 6:23 pm

user maps\mp\gametypes\cj::loadpos(); or smthing might work too.
Not sure what is in the cj.gsc exactly though.
LMGTFY!

Its not a glitch... Its the future!

bigbabol
CJ Newbie
CJ Newbie
Posts: 50
Joined: January 9th, 2011, 11:13 am

Re: Help with script PLZ

Post by bigbabol » January 10th, 2011, 7:10 pm

:arrow: 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 :D

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Help with script PLZ

Post by Pedsdude » January 10th, 2011, 9:48 pm

Hmm, I don't know the exact code for that, but given that it's DanTheMan's map I'm sure he does :)
Image
Image

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Help with script PLZ

Post by megazor » January 11th, 2011, 4:00 am

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;
	}
}

bigbabol
CJ Newbie
CJ Newbie
Posts: 50
Joined: January 9th, 2011, 11:13 am

Re: Help with script PLZ

Post by bigbabol » January 11th, 2011, 2:53 pm

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 :(

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Re: Help with script PLZ

Post by Pedsdude » January 11th, 2011, 3:37 pm

Did you thread both of them, and did you create a trigger_multiple across the area you need, giving it a "yourmap_triga" targetname?
Image
Image

bigbabol
CJ Newbie
CJ Newbie
Posts: 50
Joined: January 9th, 2011, 11:13 am

Re: Help with script PLZ

Post by bigbabol » January 11th, 2011, 4:06 pm

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 :)

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Help with script PLZ

Post by megazor » January 12th, 2011, 5:51 am

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;
	}
}

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Help with script PLZ

Post by IzNoGoD » January 12th, 2011, 10:34 am

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 :P
LMGTFY!

Its not a glitch... Its the future!

bigbabol
CJ Newbie
CJ Newbie
Posts: 50
Joined: January 9th, 2011, 11:13 am

Re: Help with script PLZ

Post by bigbabol » January 12th, 2011, 1:55 pm

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!!! :mrgreen:
the iprintlns are funny xD

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Help with script PLZ

Post by megazor » January 12th, 2011, 4:10 pm

ye, wait .05 is more accurate but it also loads server more than .1 does.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests