SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/01/2015, 04:59 AM   #1
Arxalan
Banned
 
Join Date: Feb 2014
Location: In your heart
Posts: 366
Reputation: 38
Default [Help] Hospital System

Hello , i want to know how to make Hospital system so that when player die he spawn at front of nearest hospital ?
Arxalan is offline   Reply With Quote
Old 11/01/2015, 05:42 AM   #2
Michael B
High-roller
 
Michael B's Avatar
 
Join Date: Oct 2014
Location: Romania
Posts: 1,004
Reputation: 127
Default Re: [Help] Hospital System

You could use this filterscript, which is made by Rodney Francalim.

Link: On SA-MP Scripts, URL: /post/Hospital_system-Rodney_Francalim-filterscript_systems-10508/

P.S. SA-MP forums block the link, so you will have to introduce it manually.
__________________
Michael B is offline   Reply With Quote
Old 11/01/2015, 06:22 AM   #3
Arxalan
Banned
 
Join Date: Feb 2014
Location: In your heart
Posts: 366
Reputation: 38
Default Re: [Help] Hospital System

Give me the full link .
Arxalan is offline   Reply With Quote
Old 11/01/2015, 08:19 AM   #4
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,830
Reputation: 114
Default Re: [Help] Hospital System

It's easy making him spawn infront of the hospital.

Alright, first we need to create a variable so we can check if the player died before he spawned, by putting this at the top of our script(underneath the includes):
pawn Code:
new Hospital[MAX_PLAYERS];

Then we store "1" in the variable when a player dies.
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    Hospital[playerid] = 1;
    return 1;
}

Then when the player spawns, we check if the variable is set to "1".
And if it is, then we set the players position infront of the hospital, and we set the variable to "0" again.
pawn Code:
public OnPlayerSpawn(playerid)
{
    if(Hospital[playerid] == 1)
    {
        SetPlayerPos(playerid, 1172.8644, -1323.3914, 15.3996); // You can replace this with any coordinates you want, i placed it at the All Saints General Hospital
        Hospital[playerid] == 0;
    }
    return 1;
}
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 11/01/2015, 08:28 AM   #5
Arxalan
Banned
 
Join Date: Feb 2014
Location: In your heart
Posts: 366
Reputation: 38
Default Re: [Help] Hospital System

Setting it to single hospital is easy but i want it to multiple i mean player will spawn at nearest hospital e.g. San Fierro hospital if he is in sf or LV hospital etc if he is in lv.
Arxalan is offline   Reply With Quote
Old 11/01/2015, 08:56 AM   #6
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,830
Reputation: 114
Default Re: [Help] Hospital System

Oh sorry, i misread your post then.
Create a new variable again then:
pawn Code:
new ClosestHospital[MAX_PLAYERS];
Then create a switch to check what has been put in the variable, under OnPlayerSpawn:
pawn Code:
public OnPlayerSpawn(playerid)
{
    switch(ClosestHospital[playerid])
    {
        case 0: SetPlayerPos(playerid, /* Insert coordinates of hospital 0*/);
        case 1: SetPlayerPos(playerid, /* Insert coordinates of hospital 1*/);
        case 2: SetPlayerPos(playerid, /* Insert coordinates of hospital 2*/);
    }
    return 1;
}
Then we need to check which is the closest of these 3 hospitals, and then store 0, 1 or 2 in the variable.
We can do that with this stock:
pawn Code:
stock RespawnToHospital(playerid)
{
    new Float:Hospital[3]; // Creates 3 floats, which we then use underneath to check the distance the player has from those points
    Hospital[0] = GetPlayerDistanceFromPoint(playerid,/* Insert coordinates of hospital 0 here */);
    Hospital[1] = GetPlayerDistanceFromPoint(playerid, /* Insert coordinates of hospital 1 here */);
    Hospital[2] = GetPlayerDistanceFromPoint(playerid, /* Insert coordinates of hospital 2 here */);
    if(Hospital[0] <= Hospital[1] && Hospital[0] <= Hospital[3]) // We use this to detect if hospital 0 is closer than both other
    {
        ClosestHospital[playerid] = 0; // We store "0" in the variable if hospital 0 is closest
    }
    else if(Hospital[1] <= Hospital[0] && Hospital[1] <= Hospital[3]) // If hospital 0 isn't closest, we check hospital 1, if that's closer than both the other
    {
        ClosestHospital[playerid] = 1; // We store "1" in the variable if hospital 0 is closest
    }
    else if(Hospital[2] <= Hospital[0] && Hospital[2] <= Hospital[1]) // If none of those are closest, we check if hospital 2 is closest.
    {
        ClosestHospital[playerid] = 2; // We store "2" in the variable if hospital 0 is closest
    }
    return 1;
}
And then we call this stock by putting this under OnPlayerDeath:
pawn Code:
RespawnToHospital(playerid);
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 11/01/2015, 12:53 PM   #7
Arxalan
Banned
 
Join Date: Feb 2014
Location: In your heart
Posts: 366
Reputation: 38
Default Re: [Help] Hospital System

What to Add in GetPlayerDistanceFromPoint?
Arxalan is offline   Reply With Quote
Old 11/01/2015, 03:16 PM   #8
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,830
Reputation: 114
Default Re: [Help] Hospital System

The coordinates of the hospitals.
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Help] Hospital System Kaylen Scripting Help 0 24/08/2014 07:04 AM
How to fix the hospital system Kaylen Scripting Help 2 18/08/2014 12:01 PM
[FilterScript] Hospital system Rodney Francalim Filterscripts 8 31/05/2014 07:14 PM
Need some help with hospital system bug. Marcynka Scripting Help 2 20/10/2012 10:17 PM
[HOSPITAL SYSTEM] i need help with it please slymatt Help Archive 24 22/07/2011 10:42 PM


All times are GMT. The time now is 04:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.