SA-MP Forums Archive
does someone have a idea how to make it..... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: does someone have a idea how to make it..... (/showthread.php?tid=59476)



does someone have a idea how to make it..... - kevin433 - 27.12.2008

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.


Re: does someone have a idea how to make it..... - Zezombia - 27.12.2008

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.


Re: does someone have a idea how to make it..... - kevin433 - 29.12.2008

Quote:

Then add up the remainders:
Var1X - Var1Y = Close1; Close1 - Var1Z = Close1;
Var2X - Var2Y = Close2; Close2 - Var2Z = Close2;
etc, etc, etc.

+ or - ? Because you wrote "add up"




Re: does someone have a idea how to make it..... - Rizard - 25.07.2009

Quote:
Originally Posted by Zezombia
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.
I get a fiew errors regarding this:

new H1X = 423.43, H1Y = 1353.56, H1Z = 3.23; => (Tag mismatch)
new H2X = 1353.43, H2Y = 133.56, H2Z = 8.32; => (Tag mismatch)

And also this:

X - H1X = Var1X; Y - H1Y = Var1Y; Z - H1Z = Var1Z; => (error 022: must be lvalue (non-constant))

Greetz Riz


Re: does someone have a idea how to make it..... - Correlli - 25.07.2009

Quote:
Originally Posted by Zezombia
new H1X = 423.43, H1Y = 1353.56, H1Z = 3.23;
new H2X = 1353.43, H2Y = 133.56, H2Z = 8.32;
Zezombia, these should be floats:
Quote:
Originally Posted by Zezombia
new Float:H1X = 423.43, Float:H1Y = 1353.56, Float:H1Z = 3.23;
new Float:H2X = 1353.43, Float:H2Y = 133.56, Float:H2Z = 8.32;



Re: does someone have a idea how to make it..... - XtremeChio - 25.07.2009

One thing. Why just not put the

SetPlayerPos(etc) at OnPlayerDeath ? You just put the coordinates and that's it..Or no ?


Re: does someone have a idea how to make it..... - Correlli - 26.07.2009

Quote:
Originally Posted by XtremeChio
One thing. Why just not put the

SetPlayerPos(etc) at OnPlayerDeath ? You just put the coordinates and that's it..Or no ?
OnPlayerDeath callback is called when player dies, so why would you set his position when he dies and then he will spawn at other position when OnPlayerSpawn is called?


Re: does someone have a idea how to make it..... - Rizard - 26.07.2009

@ 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


Re: does someone have a idea how to make it..... - Correlli - 26.07.2009

Quote:
Originally Posted by Rizard
@ 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
Can you paste your code here?


Re: does someone have a idea how to make it..... - Rizard - 08.08.2009

Sorry that it took so long hollidayz

I'm trying to remember what I did back then (verry nice I commented a bit of that code)

here we go:
on top:
pawn Код:
new H1X = 1614.6682, H1Y = 1818.1664, H1Z = 10.8203; //line 1761
new H2X = 1176.6060, H2Y = -1323.7875, H2Z = 14.0296; //line 1762
new Var1X, Var1Y, Var1Z, Var2X, Var2Y, Var2Z; //line 1763
new Close1, Close2; //line 1764
OnPlayerSpawn:
pawn Код:
Xhosp - H1X = Var1X; Yhosp - H1Y = Var1Y; Zhosp - H1Z = Var1Z; //1774
Xhosp - H2X = Var2X; Yhosp - H2Y = Var2Y; Zhosp - H2Z = Var2Z; //1775
Var1X - Var1Y = Close1; Close1 - Var1Z = Close1; //1776
Var2X - Var2Y = Close2; Close2 - Var2Z = Close2; //1777
OnPlayerDeath:
pawn Код:
GetPlayerPos(playerid,Xhosp,Yhosp,Zhosp); //1976
Didn't start the if loop (close1 < close2) etc... caus I get to many errors already

Errors
Код:
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1761) : warning 213: tag mismatch
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1761) : warning 213: tag mismatch
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1761) : warning 213: tag mismatch
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1762) : warning 213: tag mismatch
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1762) : warning 213: tag mismatch
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1762) : warning 213: tag mismatch
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1774) : error 022: must be lvalue (non-constant)
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1774) : warning 215: expression has no effect
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1774) : error 022: must be lvalue (non-constant)
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1774) : warning 215: expression has no effect
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1774) : error 022: must be lvalue (non-constant)
C:\Users\Rien\Documents\Samp server 2\gamemodes\ronserver.pwn(1774) : fatal error 107: too many error messages on one line
Need any more things? did I forgot anything, pls say so... it has been a while

Greetz Riz