PDA

View Full Version : respawn at the place you died [HELP]


ClavoC
19/07/2012, 11:02 AM
So,

I'm a new scripter, not a professional but I surely know the basics already of a few things!
I'm currently using the LA:RP script 0.3e as we speak.

The thing what I'm trying to do is:

Whenever a player gets killed, he RESPAWNS at the location he got killed, frozen, and with a nice /fall animation.

He has the possibility to do /deathaccept and he would respawn at the ASGH.

Could someone tell me how to inplent this into my LA:RP script? Please if you do, explain me where and what to put into my script with the "//" function... Explaining where to define or place something!

Andregood
19/07/2012, 11:06 AM
GetPlayerPos.
SetPlayerPos
ApplyAnimation.
Toggleplayercontrollable.

ClavoC
19/07/2012, 11:07 AM
Well I wouldn't understand it like that, could you please code it for me, like explaining me what where and how, with full details?

Andregood
19/07/2012, 11:10 AM
Try doing it yourself, if you fail, give me the code and I'll assist you.

ClavoC
19/07/2012, 11:11 AM
That's kindful of you, well, the codes you've placed up here, where do I have to put them? OnPlayerDeath?

EV007
19/07/2012, 11:12 AM
Ontop of your gamemodeinit write this:


new Float:PosX[MAX_PLAYERS];
new Float:PosY[MAX_PLAYERS];
new Float:PosZ[MAX_PLAYERS];
new csaved[MAX_PLAYERS];


Onplayerdeath callback type this:

GetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
csaved[playerid] = 1;


Onplayerspawn:

if(csaved[playerid] == 1)
{
csaved[playerid] == 0;
SetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
}


EDIT: I might be doing this wrong, let me know after you test it.

ClavoC
19/07/2012, 11:18 AM
Eh, I inplented into my LARP script and I recieved this warning:


"gamemodes\larp.pwn(4669) : warning 215: expression has no effect"

Therefor, I'm not spawning at the place I died, at all.....

EV007
19/07/2012, 11:20 AM
Where does the error point to?

Try this:

onplayerdeath:


new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PosX[playerid]=x;
PosY[playerid]=y;
PosZ[playerid]=z;

ClavoC
19/07/2012, 11:24 AM
The error points to:

csaved[playerid] == 0;

Do I have to remove the old functions under OnPlayerDeath which you posted be fore? or just inplend these new ones, I inplented these new ones you just posted with your reply and still doesn't work, I keep respawning at my spawn point, or faction spawn

EV007
19/07/2012, 11:29 AM
replace the csaved[playerid] == 0; with:

csaved[playerid] = 0;

you have to replace the code with my new one, but you can try both ways. I believe second way is much better

ClavoC
19/07/2012, 11:34 AM
Tried both ways, none of them is working,.

EV007
19/07/2012, 11:38 AM
You die and nothing happens?

write this on the FIRST LINE of onplayerspawn:

printf("%.2f,%.2f,%.2f,%d",PosX[playerid],PosY[playerid],PosZ[playerid],csaved[playerid]);

after you die and respawn, check your servers console and see what are the numbers, if they are 0, It means my code was placed in the wrong place on your playerdeath

Minion
19/07/2012, 11:46 AM
Can you show us your OnPlayerDeath and On PlayerSpawn? with the above code added

ClavoC
19/07/2012, 11:49 AM
[death] Clavo_Cruzo died 54
1652.15,-2295.73,-0.81,1.

That's what I would see on the dos/console screen.

ClavoC
19/07/2012, 11:51 AM
public OnPlayerSpawn(playerid)
{
printf("%.2f,%.2f,%.2f,%d",PosX[playerid],PosY[playerid],PosZ[playerid],csaved[playerid]);
if(csaved[playerid] == 1)
{
csaved[playerid] = 0;
SetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
}
InitLockDoors(playerid);
STDPlayer[playerid] = 0;
gTeam[playerid] = PlayerInfo[playerid][pTeam]; //Set the Team
if (gTeam[playerid] == 4) //medic / criminal reset team
{
gTeam[playerid] = 3;
}
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "** This server requires a Login BEFORE spawn (Kicked) **");
KickPlayer[playerid] = 1;
}

That's OnPlayerSpawn.


OnPlayer death:

public OnPlayerDeath(playerid, killerid, reason)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
PosX[playerid]=x;
PosY[playerid]=y;
PosZ[playerid]=z;
GetPlayerPos(playerid,PosX[playerid],PosY[playerid],PosZ[playerid]);
csaved[playerid] = 1;
new name[MAX_PLAYER_NAME];
new string[256];
//new dmessage[128];
//new deathreason[20];
new playercash;
new victimteam;
new Float:px,Float:py,Float:pz;
new killerteam;

EV007
19/07/2012, 11:51 AM
Remove the code printf i gave you and put

print("executed");
under my onplayerspawn code (under if(csaved[playerid] == 1)

after you respawn from death check the console IT SHOULDN'T print anything, if it doesn't you need to move the whole code if its not above everything, to the top.

EDIT: Don't do the second thing I wrote, you posted first hehe. Let me know what the console says, I have no idea what could be wrong atm.

Minion
19/07/2012, 11:57 AM
Alright. Remove everything(Comment it with // if you need it) from your OnPlayerSpawn and OnPlayerSpawn.

Put this on top of script:

new temp[MAX_PLAYERS]=0;
new Float:pX[MAX_PLAYERS],Float:pY[MAX_PLAYERS],Float:pZ[MAX_PLAYERS];

Put this under OnPlayerDeath:
GetPlayerPos(playerid,pX[playerid],pY[playerid],pZ[playerid]);
temp[playerid]=1;

Put this Under OnPlayerSpawn:
if(temp[playerid]==1)
{
SetPlayerPos(playerid,pX[playerid],pY[playerid],pZ[playerid]);
temp[playerid]=0;

}


i've tried this and its working

EV007
19/07/2012, 11:59 AM
Thats actually the same, I know the problem now .

The onplayerspawn code you posted is not FULL. Meaning there could be SetPlayerPos functions and we can't see them, you respawn where you died, but the code below gets executed AFTER, that's why you are experiencing this, put the if csaved code below everything and it SHOULD work 99%.

Minion
19/07/2012, 12:03 PM
Thats why i told him to delete or comment everything in both callbacks. Just delete EVERYTHING, i mean, EVERYTHING from both call backs and put the code that i gave you.

ClavoC
19/07/2012, 12:16 PM
Still not working, I did EXACTLY what you said, removed EVERYTHING from the old system and it still doesn't work.

remember: I'm using Los Angeles RP script!

Minion
19/07/2012, 12:20 PM
Well, Can you send me the script? I'll solve it for ya

ClavoC
19/07/2012, 12:26 PM
I sent you the script on PM, please send me it on PM back when you fixed it! thanks alot for your help

Devilxz97
19/07/2012, 01:22 PM
u want when u death u spawn the death place

ClavoC
19/07/2012, 01:32 PM
Yes. At the place you died.

ClavoC
19/07/2012, 05:56 PM
Is there anyone else who could help me please? I'm using LA:RP Script, so make sure to make explain it on the way I could inplend it into the LA-RP Script!