Hospital system, How would it work?
#1

How does hospital systems work? in roleplay servers, I.e

When the person dies they are sent to the hospital (Fort Carson General) and there is a timer delay before they respawn and the camera looks at the building until they respawn.

Could someone send me an idea or part of code to show me how this would work? Do I need loops etc?

Grant.
Reply
#2

Only part of the code?
pawn Код:
new bool:IsDead[MAX_PLAYERS];

//OnPlayerDeath
IsDead[playerid]++;


//OnPlayerSpawn
if(IsDead[playerid])
{
    //SpawnInHospital with timer
    //Set the camera thinghy
    TogglePlayerControllable(playerid,0);
    IsDead[plaeyrid]--;
}
Reply
#3

A quick script I wrote, it compiled, untested though:
pawn Код:
// Hospital filterscript by Mean.
// When you die, you get teleported to hospital and stay in there for the specified amount of time.
// Use wisely.

#include < a_samp >

static died[ MAX_PLAYERS ];

#define PUB:%1(%2) forward %1(%2); \
                   public %1(%2)
#define HOSPITAL_TIME      60 // In seconds. Default = 60.
#define MSG_ENTER_HOSPITAL "You almost died due to a heavy medical problem. The doctors saved your life."
#define MSG_EXIT_HOSPITAL  "You have recovered from your injuries. You have been released from the hospital."

public OnPlayerConnect( playerid )
    return died[ playerid ] = 0, true;

public OnPlayerDeath( playerid, killerid, reason )
    return died[ playerid ] = 1, true;

public OnPlayerSpawn( playerid ) {
    if( died[ playerid ] == 1 ) {
        // Set interior and position to the hospital.
        SendClientMessage( playerid, -1, MSG_ENTER_HOSPITAL );
        SetTimerEx( "hospitalrelease", HOSPITAL_TIME * 1000, 0, "i", playerid );
        died[ playerid ] = 0;
    }
    return true;
}

PUB:hospitalrelease( playerid ) {
    SendClientMessage( playerid, -1, MSG_EXIT_HOSPITAL );
    return SpawnPlayer( playerid ), true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)