PDA

View Full Version : Player can't move for secounds



Loveboy
15th June 2013, 09:46
Hi Guys, i have a question: how i can make that a player can't move for (example) 20 seconds?
after the 20 seconds he can move?

If you ask what i want to make:
The Map is starting, 20 seconds and the game begins :)

RobsoN
15th June 2013, 10:32
link player to script origin:

To lock:

org = spawn("script_origin",self.origin);
self linkTo(org);

To unlock:
self unlink();

Loveboy
15th June 2013, 10:36
So you mean: [code]

org = spawn("script_origin",self.origin);
self linkTo(org);

wait(20);

self unlink();

kung foo man
15th June 2013, 10:37
But don't forget to delete the helper-model then. On the other hand you don't need a model for each player, one model for all works also.



// ONLY ONCE:
level.helper = spawn("script_origin", (0,0,0))

// for each player:
player linkTo(level.helper);
wait 20;
player unlink();

Loveboy
15th June 2013, 10:53
Hi, this i get it if i have test it:


******* script compile error *******
bad syntax: (file 'maps/mp/gametypes/_begin.gsc', line 9)
self linkTo(level.waiter);
*
************************************


script:


init()
{
thread waiting();
}

waiting()
{
level.waiter = spawn("script_origin", (0,0,0))
self linkTo(level.waiter);
wait 20;
self unlink();
}

kung foo man
15th June 2013, 11:11
I said with bold text: ONLY ONCE

If you can't understand that, use:



init()
{
thread waiting();
}

waiting()
{
if ( ! isDefined(level.waiter))
level.waiter = spawn("script_origin", (0,0,0)); // you forget the ; here
self linkTo(level.waiter);
wait 20;
self unlink();
}

Loveboy
15th June 2013, 11:19
hmm it didnt work, i have try to make script_model but it doesnt work too.
my error:

******* script runtime error *******
struct is not an entity: (file 'maps/mp/gametypes/_begin.gsc', line 10)
self linkTo(level.waiter);
*

kung foo man
15th June 2013, 11:21
You need to call the functions on a player, now the functions work with "level".

Loveboy
15th June 2013, 11:26
hmmm idk what you mean ;(

IzNoGoD
15th June 2013, 11:51
Try freezecontrols() instead.

Loveboy
15th June 2013, 12:05
What? I have nothing understand. Sorry, can you please add this here what do you mean?


init()
{
thread waiting();
}

waiting()
{
if ( ! isDefined(level.waiter))
level.waiter = spawn("script_origin", (0,0,0)); // you forget the ; here
self linkTo(level.waiter);
wait 20;
self unlink();
}

kung foo man
15th June 2013, 12:09
Dude, you need something like: player waiting();

Try to understand what "self" means by reading more code in tdm.gsc e.g.

ATM you are doing: level waiting(); which is bullshit of course

Loveboy
15th June 2013, 12:26
Hmm i tried that but the error says Unknown Function: players[i] freezeplayer();


init()
{
thread waiting();
}

waiting()
{
players = getentarray("player", "classname");
for (i = 0; i<players.size; i++)
{
players[i] freezeplayer();
wait 20;
players[i] unfreeze();
}
}

EvoloZz
15th June 2013, 12:42
freezecontrols(true) not freezeplayer()

Tally
15th June 2013, 12:48
Hi Guys, i have a question: how i can make that a player can't move for (example) 20 seconds?
after the 20 seconds he can move?

If you ask what i want to make:
The Map is starting, 20 seconds and the game begins :)

This works:


main()
{
level thread onPlayerConnect();
}

onPlayerConnect()
{
for( ;; )
{
level waittill( "connected", player );

player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon( "disconnect" );

for( ;; )
{
self waittill( "spawned_player" );

self thread Freeze();
}
}


Freeze()
{
self iprintlnbold( "frozen" );
self freezeControls( true );

wait( 10 );

self iprintlnbold( "unfrozen" );
self freezeControls( false );
}

Loveboy
15th June 2013, 12:50
THANK YOU EVOLLLUZZZ & TALLLY YOU ARE RIGHT!!!!!!!!!!

Loveboy
15th June 2013, 18:43
Ok Guys, that not work, idk really why, i have set it in my mp_sad.gsc, i have run the map and it doesn't work.



main()
{
// Map name: mp_sad (test map)
maps\mp\_load::main();
maps\mp\_kiste1::main(); // Zufallskiste Nr.1

thread begin(); // Here if map starts then you have to wait 20 secounds
}

begin()
{
wait(1);
players = getentarray("player", "classname");
for (i = 0; i<players.size; i++)
{
players[i] freezecontrols(true);
wait 20;
players[i] freezecontrols(false);
}
}

If map started, then waiting 1 secound, then freeze, that doesnt work.

And i think because: If you are not in the map, in the exact second 29:59, then it should start but i come too late, and i will be not stuck.

Somebody know how else i can make it?

Loveboy
15th June 2013, 18:51
I must create in Callback_startgametype a timer or in my map.gsc, so that if you connect and it looking for the timer, which secound i am? How long it left now?

I think this is not easy and i asked my friends, they can't maybe some of killtubers, but would be very nice if somebody is here and can help

Tally
15th June 2013, 20:25
There are 3 problems with that code:

1. You must check that the entarray for players exists. If not, then wait for it to be defined;

2. You aren't waiting for the players to spawn. They cannot move until they are spawned;

3. You are waiting 20 seconds in the for() loop to search for all players. This will mean the loop will wait 20 seconds before it moves on to the next player. In that time, the player will be able to run around.

So, try this:


main()
{
// Map name: mp_sad (test map)
maps\mp\_load::main();
maps\mp\_kiste1::main(); // Zufallskiste Nr.1

thread begin(); // Here if map starts then you have to wait 20 secounds
}

begin()
{
wait(1);

players = getentarray("player", "classname");

while( !isDefined( players ) )
wait( 0.05 );

for( i = 0; i < players.size; i++ )
players[i] thread FreezePlayer();
}

FreezePlayer()
{
self endon( "disconnect" );

self waittill( "spawned_player" );

self freezecontrols(true);
wait( 20 );
self freezecontrols(false);
}


EDIT - the code I just wrote also has a problem - it will only wait until the first player connects, and then run. You really need to detect every connecting player, and run the thread on them. Hence, my original code I posted is much much better because it does exactly that - it detects each and every player and runs the freeze thread on them as they spawn. You need to put that original code in there instead.