Posts: 170
Threads: 11
Joined: Oct 2007
Reputation:
0
Hi,
Does someone have a idea how to make it that if a player die, he spawns i front of the nearest hospital from his position.
Posts: 415
Threads: 25
Joined: Apr 2008
Reputation:
0
Theory:
Get all the cords of the hospitals, and save them in separate global variables:
new H1X = 423.43, H1Y = 1353.56, H1Z = 3.23;
new H2X = 1353.43, H2Y = 133.56, H2Z = 8.32;
etc. Do that for all the hospitals.
When a player dies, get his location, and do:
X - H1X = Var1X; Y - H1Y = Var1Y; Z - H1Z = Var1Z;
X - H2X = Var2Z; Y - H2Y = Var2Z; Z - H2Z = Var2Z;
etc, etc, etc.
Then add up the remainders:
Var1X - Var1Y = Close1; Close1 - Var1Z = Close1;
Var2X - Var2Y = Close2; Close2 - Var2Z = Close2;
etc, etc, etc.
What ever number is smaller:
if(Close1 < Close2) return SetPlayerPos(playerid, H1X H1Y H1Z);
else if(Close1 > Close2) return SetPlayerPos(playerid, H2X H2Y H2Z);
etc, etc, etc.
Yes, I know I'm making a lot of "new"s, but I'm not looking for quality, I'm looking for functionality, you can always change it :P.
Posts: 266
Threads: 22
Joined: Jul 2009
Reputation:
0
One thing. Why just not put the
SetPlayerPos(etc) at OnPlayerDeath ? You just put the coordinates and that's it..Or no ?
Posts: 297
Threads: 47
Joined: Jun 2008
Reputation:
0
@ Don Correlli,
I have the same problems if I create the H1X as not just a variable but a float.... the errors like 'tag mismatch' and 'lvalue (non constant) remain?
Greetz Riz