Do you know how to script in SA-MP yet?
If you are new to scripting, here are some useful links:
https://sampwiki.blast.hk/wiki/SetPlayerPos <- To set a players position in a hospital.
https://sampwiki.blast.hk/wiki/SetPlayerInterior <- To set a players interior to the hospital interior.'
https://sampwiki.blast.hk/wiki/GivePlayerMoney <- To remove a players money ($200 / $500)
https://sampwiki.blast.hk/wiki/Random <- To create the random hospital system.
So for a more infromation, as this may not help you enough:
pawn Код:
new IsInAHospital[MAX_PLAYERS];// Add this to the top of your Gamemode with the other new's.
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
new rand = random(2)//This sets the random possibilities
switch(rand)//This detects what the random outcome was of the above function.
{
case 0: //Hospital spawn #1
{
SetPlayerInterior(playerid, #) //You will need to replace the # with the hospitals actual interior number.
SetPlayerPos(playerid, x_value_here, y_value_here, z_value_here)//Again, replace the xyz_value_here's with the correct ones.
IsInAHospital[playerid] = 1; //The script now knows they are in a hospital
GivePlayerMoney(playerid, -200);// This will take $200 from the player when they arrive at the hospital.
SendClientMessage(playerid, COLOR_GREEN, "You have been billed $200 for the medical fee's.");
SendClientMessage(playerid, COLOR_GREEN, "You may use the command /instaheal to pay $500 and exit now, or you may way 5 minutes to be healed.");// Message sent to the player's textbox.
}
case 1: //Hospital spawn #2
{
SetPlayerInterior(playerid, #) //You will need to replace the # with the hospitals actual interior number.
SetPlayerPos(playerid, x_value_here, y_value_here, z_value_here)//Again, replace the xyz_value_here's with the correct ones.
IsInAHospital[playerid] = 1; //The script now knows they are in a hospital
GivePlayerMoney(playerid, -200);// This will take $200 from the player when they arrive at the hospital.
SendClientMessage(playerid, COLOR_GREEN, "You have been billed $200 for the medical fee's.");
SendClientMessage(playerid, COLOR_GREEN, "You may use the command /instaheal to pay $500 and exit now, or you may way 5 minutes to be healed.");// Message sent to the player's text box.
}
}
return 1;// This means that it will stop the code, meaning it should be at the end.
}
//Now for the command /instaheal
public OnPlayerCommandText(playerid, cmdtext[])// Detects commands (you probably have this in your GM)
{
if (strcmp("/instaheal", cmdtext, true, 10) == 0)//The command to create
{
if(IsInAHospital[playerid] != 1)
{
IsInAHospital[playerid] = 0; //Ensure's they aren't in a hospital
SendClientMessage(playerid, COLOR_GREEN, "You aren't in a hospital to use this command!.");
return 1;
}
SendClientMessage(playerid, COLOR_GREEN, "You have made a full recovery.");
SendClientMessage(playerid, COLOR_GREEN, "You have been billed $500 for the extensive fast treatment."); //Message sent to the player's textbox.
SetPlayerInterior(playerid, 0)
SetPlayerPos(playerid, x_value_here, y_value_here, z_value_here)//Again, replace the xyz_value_here's with the correct ones.
GivePlayerMoney(playerid, -500);// This will take $500 from the player when they exit the hospital.
}
return 1;// This means that it will stop the code, meaning it should be at the end.
}
//Also add this to be safe
public OnPlayerDisconnect(playerid, reason)
{
IsInAHospital[playerid] = 0; //reset's the hospital value to 0. Just in case they were in one when they exited the server.
return 1;
}