Force a spawn

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
Grue
Private First Class
Private First Class
Posts: 25
Joined: Tue Apr 08, 2014 12:23 am

Force a spawn

Post by Grue »

Hey all,

I was wondering how I could force a player to spawn, if possible.

So if the player is dead, I would like the ability for a flag to make them spawn. I've seen this ability on a few other worlds, so I'm wondering how they might have done it. I tried playerRecord->spawned = true, but that didn't work.

Thanks,
Grue
User avatar
blast
General
General
Posts: 4886
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Force a spawn

Post by blast »

While the design of the game allows for the server to tell a player to spawn, I don't believe the bzfs API exposes a way to do that.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
etigah
Private First Class
Private First Class
Posts: 95
Joined: Tue May 22, 2012 4:08 pm

Re: Force a spawn

Post by etigah »

If you are ready to go off the beaten path..

Code: Select all

#include "../src/bzfs/bzfs.h"
..
..
playerAlive(playerID);
User avatar
blast
General
General
Posts: 4886
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Force a spawn

Post by blast »

Or just add an API function...
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Grue
Private First Class
Private First Class
Posts: 25
Joined: Tue Apr 08, 2014 12:23 am

Re: Force a spawn

Post by Grue »

That did the trick! Thanks so much!

Grue
Grue
Private First Class
Private First Class
Posts: 25
Joined: Tue Apr 08, 2014 12:23 am

Re: Force a spawn

Post by Grue »

Hmm alright another question on this matter...

I'm trying to give the player a flag immediately after they get killed and spawn back in. I kill the player using bz_killPlayer, then use the playerAlive function to spawn them back in. Right after they spawn back in, I'm trying to give them a flag in the bz_ePlayerSpawnEvent. Unfortunately, the flag won't give to the player. In the console, it just says "Grue grabbed <flag>", "Grue dropped <flag>"

Any idea why I can't give a flag to a player immediately after I spawn them in using the playerAlive function? When a player spawns in normally, the flag gives fine.

Thanks,
Grue
etigah
Private First Class
Private First Class
Posts: 95
Joined: Tue May 22, 2012 4:08 pm

Re: Force a spawn

Post by etigah »

Have you tried passing 1 as third parameter to bz_givePlayerFlag?

I do remember bringing players back alive immediately after being killed causing issues. Try delaying the playerAlive call by a short duration. One way is to add the player id to a list and call playerAlive on next tick event and empty the list.
Grue
Private First Class
Private First Class
Posts: 25
Joined: Tue Apr 08, 2014 12:23 am

Re: Force a spawn

Post by Grue »

Hey, thanks for the reply. I solved this by just setting a timer and giving the flag back after a fraction of a second.

Thanks again,
Grue
Post Reply