SA-MP Forums Archive
spawn at hospital when die - 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)
+--- Thread: spawn at hospital when die (/showthread.php?tid=325265)



spawn at hospital when die - Gooday - 12.03.2012

Hello, how i can spawn at hospital someone when die?


Re: spawn at hospital when die - Infamous - 12.03.2012

Something like this:

pawn Code:
Under OnPlayerDeath

HasDied[playerid] = 1;

Under OnPlayerSpawn

if(HasDied[playerid] == 1)
{
    SetPlayerPos..etc
}



Re: spawn at hospital when die - Ronaldo_raul™ - 12.03.2012

Under OnPlayerDeath callback.
pawn Code:
SetPlayerPos(playerid, Float:x , Float:y, Float:z);
Replace your co-ordinates with the floats.

EDIT : Infamous was faster.


Re: spawn at hospital when die - Gooday - 12.03.2012

Quote:

C:\Users\Luca\Desktop\BaseScript\gamemodes\base.pw n(1369) : error 017: undefined symbol "HasDied"
C:\Users\Luca\Desktop\BaseScript\gamemodes\base.pw n(1369) : warning 215: expression has no effect
C:\Users\Luca\Desktop\BaseScript\gamemodes\base.pw n(1369) : error 001: expected token: ";", but found "]"
C:\Users\Luca\Desktop\BaseScript\gamemodes\base.pw n(1369) : error 029: invalid expression, assumed zero
C:\Users\Luca\Desktop\BaseScript\gamemodes\base.pw n(1369) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

pawn Code:
public OnPlayerSpawn(playerid)
{
    SetPlayerColor(playerid, COLOR_GREY);
    SetPlayerPos(playerid, -88.0029, 1222.8109, 19.7422);
    SetPlayerInterior(playerid, 0);
    TogglePlayerClock(playerid, 1);
    SetPlayerVirtualWorld(playerid, 0);
    if(HasDied[playerid] == 1)
{
    SetPlayerPos(id, -2208.3994140625, -2329.599609375, 30.200000762939);
}
    return 1;
}



Re: spawn at hospital when die - Infamous - 12.03.2012

Top of your script, under the includes etc:

new HasDied[MAX_PLAYERS];


Re: spawn at hospital when die - Gooday - 12.03.2012

Thanks


Re: spawn at hospital when die - Infamous - 12.03.2012

Might be an idea to set HasDied[playerid] = 0; under the SetPlayerPos bit in OnPlayerSpawn and under OnPlayerConnect HasDied[playerid] = 0; just to ensure nothing goes wrong.

pawn Code:
// Top of script

new HasDied[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    HasDied[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(HasDied[playerid] == 1)
    {
        SetPlayerPos(..
        SetPlayerFacingAngle(..
        HasDied[playerid] = 0;
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    HasDied[playerid] = 1;
    return 1;
}



Re: spawn at hospital when die - Gooday - 12.03.2012

UPDATE: Not working Sorry for double post but i dunno to edit :/


Re: spawn at hospital when die - Infamous - 12.03.2012

Make sure it's the same as my above post pal.


Re: spawn at hospital when die - Ronaldo_raul™ - 12.03.2012

Quote:
Originally Posted by Infamous
View Post
Might be an idea to set HasDied[playerid] = 0; under the SetPlayerPos bit in OnPlayerSpawn and under OnPlayerConnect HasDied[playerid] = 0; just to ensure nothing goes wrong.

pawn Code:
// Top of script

new HasDied[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    HasDied[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(HasDied[playerid] == 1)
    {
        SetPlayerPos(..
        SetPlayerFacingAngle(..
        HasDied[playerid] = 0;
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    HasDied[playerid] = 1;
    return 1;
}
I think there's no need for the variables.

Quote:
Originally Posted by Gooday
View Post
UPDATE: Not working Sorry for double post but i dunno to edit :/
What actually is the problem.Did you tried my code ?