SA-MP Forums Archive
When players die in a event, they get sent to the hospital? - 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: When players die in a event, they get sent to the hospital? (/showthread.php?tid=207704)



When players die in a event, they get sent to the hospital? - Mr. Despair - 06.01.2011

I'm having this issue with players joining the event and when they get killed by another player, they end up getting sent to the hospital instead of being sent back to where they were when they /join'ed the event. I want when they die, they go back to where they join'ed the event with their guns and whatever HP and Armor they had.

This is my OnPlayerDeath


Код:
public OnPlayerDeath(playerid, killerid, reason)
{
//   printf("OnPlayerDeath: playerid: %d, killerid: %d, reason: %s", playerid, killerid, reason); //debug
    ClearGuns(playerid);
    SetPlayerColor(playerid, TCOLOR_HOSPITAL);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[playerid][pOnDuty] = 0;
    PlayerInfo[playerid][pBombs] = 0;
    PlayerInfo[playerid][pScope] = 0;
    PlayerInfo[playerid][pLocal] = 999;
    PlayerInfo[playerid][pVirtualWorld] = 0;
    PlayerInfo[killerid][pKills] += 1;
    CapturingTimer[playerid] = 0;
    STDPlayer[playerid] = 0;
    IsAtEvent[playerid] = 0;
	new name[MAX_PLAYER_NAME];
	new killa[MAX_PLAYER_NAME];
	new string[128];
	new caller = Mobile[playerid];
	GetPlayerName(playerid, name, sizeof(name));
	GetPlayerName(killerid, killa, sizeof(killa));
Any other information that is needed, let me know.


Re: When players die in a event, they get sent to the hospital? - selten98 - 06.01.2011

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
//   printf("OnPlayerDeath: playerid: %d, killerid: %d, reason: %s", playerid, killerid, reason); //debug
    ClearGuns(playerid);
    SetPlayerColor(playerid, TCOLOR_HOSPITAL);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[playerid][pOnDuty] = 0;
    PlayerInfo[playerid][pBombs] = 0;
    PlayerInfo[playerid][pScope] = 0;
    PlayerInfo[playerid][pLocal] = 999;
    PlayerInfo[playerid][pVirtualWorld] = 0;
    PlayerInfo[killerid][pKills] += 1;
    CapturingTimer[playerid] = 0;
    STDPlayer[playerid] = 0;
    IsAtEvent[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    new killa[MAX_PLAYER_NAME];
    new string[128];
    new caller = Mobile[playerid];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(killerid, killa, sizeof(killa));
this should work
pawn Код:
OnPlayerDeath(etc)
{
if(IsAtEvent[playerid] == 1)
{
SetPlayerPos(playerid,crappos)
}
}



Re: When players die in a event, they get sent to the hospital? - Mr. Despair - 06.01.2011

It didn't work, I still go to the hospital


Re: When players die in a event, they get sent to the hospital? - selten98 - 06.01.2011

when u add someone to the event u do
IsAtEvent[playerid] = 1; ??


Re: When players die in a event, they get sent to the hospital? - Mr. Despair - 06.01.2011

I currently tried putting this under OnPlayerDeath, however failed to work.

Код:
if(IsAtEvent[playerid] == 1)
	{
    	SetPlayerInterior(playerid,0);
		SetPlayerVirtualWorld(playerid, 0);
		SetPlayerPos(playerid,982.1890,-1624.2583,14.9526);
		SetPlayerFacingAngle(playerid, 90);
		SetCameraBehindPlayer(playerid);
	}



Re: When players die in a event, they get sent to the hospital? - PotH3Ad - 06.01.2011

Make sure you add that code before you reset the variable "IsAtEvent".

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
//   printf("OnPlayerDeath: playerid: %d, killerid: %d, reason: %s", playerid, killerid, reason); //debug
    ClearGuns(playerid);
    SetPlayerColor(playerid, TCOLOR_HOSPITAL);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[playerid][pOnDuty] = 0;
    PlayerInfo[playerid][pBombs] = 0;
    PlayerInfo[playerid][pScope] = 0;
    PlayerInfo[playerid][pLocal] = 999;
    PlayerInfo[playerid][pVirtualWorld] = 0;
    PlayerInfo[killerid][pKills] += 1;
    CapturingTimer[playerid] = 0;
    STDPlayer[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    new killa[MAX_PLAYER_NAME];
    new string[128];
    new caller = Mobile[playerid];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(killerid, killa, sizeof(killa));
   
    if(IsAtEvent[playerid])
    {
        IsAtEvent[playerid] = 0;
        SetPlayerInterior(playerid,0);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerPos(playerid,982.1890,-1624.2583,14.9526);
        SetPlayerFacingAngle(playerid, 90);
        SetCameraBehindPlayer(playerid);
    }



Re: When players die in a event, they get sent to the hospital? - selten98 - 06.01.2011

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsAtEvent[playerid] == 0)
//   printf("OnPlayerDeath: playerid: %d, killerid: %d, reason: %s", playerid, killerid, reason); //debug
    ClearGuns(playerid);
    SetPlayerColor(playerid, TCOLOR_HOSPITAL);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[playerid][pOnDuty] = 0;
    PlayerInfo[playerid][pBombs] = 0;
    PlayerInfo[playerid][pScope] = 0;
    PlayerInfo[playerid][pLocal] = 999;
    PlayerInfo[playerid][pVirtualWorld] = 0;
    PlayerInfo[killerid][pKills] += 1;
    CapturingTimer[playerid] = 0;
    STDPlayer[playerid] = 0;
    IsAtEvent[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    new killa[MAX_PLAYER_NAME];
    new string[128];
    new caller = Mobile[playerid];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(killerid, killa, sizeof(killa));
} else if(IsAtEvent[playerid] == 1) {
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid,982.1890,-1624.2583,14.9526);
SetPlayerFacingAngle(playerid, 90);
SetCameraBehindPlayer(playerid);
}



Re: When players die in a event, they get sent to the hospital? - PotH3Ad - 06.01.2011

Quote:
Originally Posted by selten98
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsAtEvent[playerid] == 0)
//   printf("OnPlayerDeath: playerid: %d, killerid: %d, reason: %s", playerid, killerid, reason); //debug
    ClearGuns(playerid);
    SetPlayerColor(playerid, TCOLOR_HOSPITAL);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[playerid][pOnDuty] = 0;
    PlayerInfo[playerid][pBombs] = 0;
    PlayerInfo[playerid][pScope] = 0;
    PlayerInfo[playerid][pLocal] = 999;
    PlayerInfo[playerid][pVirtualWorld] = 0;
    PlayerInfo[killerid][pKills] += 1;
    CapturingTimer[playerid] = 0;
    STDPlayer[playerid] = 0;
    IsAtEvent[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    new killa[MAX_PLAYER_NAME];
    new string[128];
    new caller = Mobile[playerid];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(killerid, killa, sizeof(killa));
} else if(IsAtEvent[playerid] == 1) {
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid,982.1890,-1624.2583,14.9526);
SetPlayerFacingAngle(playerid, 90);
SetCameraBehindPlayer(playerid);
}
That wouldn't work because if a player was in an event the code above wouldn't be called.


Re: When players die in a event, they get sent to the hospital? - selten98 - 06.01.2011

than do it other way round?


Re: When players die in a event, they get sent to the hospital? - Mr. Despair - 06.01.2011

I've tried two ways, OnPlayerDeath and SetPlayerInHospital, neither way works. And I just tried Potheads way and it still failed to work.