05.11.2012, 16:09
(
Last edited by Rodney Francalim; 05/11/2012 at 05:03 PM.
)
Rodney Francalim
FilterScripts
••••••••••••••••••••••••••••••••••••••••••••••••••FilterScripts
1: Description
- Self-explanatory title. It's a simple hospital system where the player, when dies, will be teleported to an interior of hospital (with objects already in FS), and there he'will be recovered gradually (can note the HP when he's on the stretcher) and after, the player will be teleported to the waiting room at the hospital, where this is located in Los Santos, Market (I guess). Also there's a first aid station, where the player can use the /curarme (/healme) and restore him HP, but the player needs has less than half + 1 of the max HP, in other words, fifty down, and the HP won't be restore fully, it'll be the current value of HP plus the current value of HP divided by a random number of 1 to 5. Example: If the player has 30 of HP, when he types /curarme (/healme), serб 30 + 30/x, what, how less the x, more will be recover, what x is different of 0.
- Commands list:
• /entrar (/enter)
• /sair (/exit)
• /curarme (/healme)
2: What will we need?
- ZCMD
- sscanf2
3: Images
- When the player dies (It says: You'll be recovered at some seconds. Wait...)
'-> NOTE:: If you want more pictures of hospital, click this link
4: Code
pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
new bool:QuickCure[MAX_PLAYERS] = true;
new bool:Died[MAX_PLAYERS] = false;
new TimeOfRecovery;
new HospitalTime[MAX_PLAYERS] = 0;
new Float:StretcherAfterDeath[6][4] = {
{1159.7764, -1305.0938, 9281.3076, 95.8811},
{1161.3806, -1305.1771, 9281.3076, 88.9876},
{1163.3702, -1305.0962, 9281.3076, 91.7352},
{1165.2333, -1305.1454, 9281.3076, 91.2044},
{1166.9817, -1305.3794, 9281.3076, 90.8186},
{1168.7142, -1305.3842, 9281.3076, 90.1919}
};
public OnFilterScriptInit()
{
print("\n\n\n Hospital systema");
print(" by: Rodney Francalim\n\n\n");
TimeOfRecovery = SetTimer("Recovered", 1000, true);
// Hospital - Interior
CreateObject(14595,1175.05078125,-1328.92089844,9283.52246094,0.00000000,0.00000000,0.00000000); //object(paperchase02) (1)
CreateObject(5020,1178.11718750,-1340.39355469,9281.22070312,0.00000000,0.00000000,0.00000000); //object(mul_las) (1)
CreateObject(5020,1178.11621094,-1340.39746094,9282.38867188,0.00000000,0.00000000,0.00000000); //object(mul_las) (2)
CreateObject(14598,1175.03491211,-1328.92651367,9283.51562500,0.00000000,0.00000000,0.00000000); //object(paperchase_glass) (1)
CreateObject(1523,1174.26074219,-1315.62304688,9279.56933594,0.00000000,0.00000000,0.00000000); //object(gen_doorext10) (1)
CreateObject(1704,1170.88537598,-1333.26599121,9279.56933594,0.00000000,0.00000000,180.00000000); //object(kb_chair03) (1)
CreateObject(1704,1167.13879395,-1325.55065918,9279.56933594,0.00000000,0.00000000,59.99938965); //object(kb_chair03) (2)
CreateObject(1726,1169.29589844,-1324.67285156,9279.56933594,0.00000000,0.00000000,0.00000000); //object(mrk_seating2) (1)
CreateObject(2293,1170.42285156,-1331.69628906,9279.49316406,0.00000000,0.00000000,0.00000000); //object(swk_1_fstool) (1)
CreateObject(3383,1170.69042969,-1305.55371094,9279.56933594,0.00000000,0.00000000,270.00000000); //object(a51_labtable1_) (1)
CreateObject(1671,1180.88574219,-1332.81640625,9280.02929688,0.00000000,0.00000000,159.99938965); //object(swivelchair_a) (1)
CreateObject(1705,1182.30761719,-1329.62500000,9279.56933594,0.00000000,0.00000000,319.49890137); //object(kb_chair04) (1)
CreateObject(2008,1180.47851562,-1331.94335938,9279.56933594,0.00000000,0.00000000,0.00000000); //object(officedesk1) (1)
CreateObject(1705,1179.29589844,-1330.18066406,9279.56933594,0.00000000,0.00000000,50.74584961); //object(kb_chair04) (2)
CreateObject(1808,1183.95117188,-1324.01953125,9279.56933594,0.00000000,0.00000000,319.99877930); //object(cj_watercooler2) (1)
CreateObject(1808,1177.81542969,-1334.52636719,9279.54980469,0.00000000,0.00000000,265.99548340); //object(cj_watercooler2) (2)
CreateObject(630,1179.38964844,-1324.77050781,9280.59472656,0.00000000,0.00000000,0.00000000); //object(veg_palmkb8) (1)
CreateObject(632,1165.56054688,-1325.03710938,9280.01855469,0.00000000,0.00000000,0.00000000); //object(veg_palmkb7) (1)
CreateObject(2245,1169.67956543,-1326.65368652,9280.30957031,0.00000000,0.00000000,0.00000000); //object(plant_pot_11) (1)
CreateObject(2251,1167.75500488,-1331.84020996,9280.84375000,0.00000000,0.00000000,0.00000000); //object(plant_pot_20) (1)
CreateObject(8659,1158.04785156,-1329.11425781,9280.56933594,0.00000000,0.00000000,90.00000000); //object(shbbyhswall11_lvs) (1)
CreateObject(8659,1158.03710938,-1329.11816406,9282.56542969,0.00000000,0.00000000,90.00000000); //object(shbbyhswall11_lvs) (2)
CreateObject(1997,1159.63012695,-1304.87231445,9279.56933594,0.00000000,0.00000000,0.00000000); //object(hos_trolley) (1)
CreateObject(1997,1161.32995605,-1304.96093750,9279.56933594,0.00000000,0.00000000,0.00000000); //object(hos_trolley) (2)
CreateObject(1997,1163.31799316,-1304.97705078,9279.56933594,0.00000000,0.00000000,0.00000000); //object(hos_trolley) (3)
CreateObject(1997,1165.15136719,-1304.99511719,9279.56933594,0.00000000,0.00000000,0.00000000); //object(hos_trolley) (4)
CreateObject(1997,1166.90063477,-1305.08386230,9279.56933594,0.00000000,0.00000000,0.00000000); //object(hos_trolley) (5)
CreateObject(1997,1168.62402344,-1305.17089844,9279.56933594,0.00000000,0.00000000,0.00000000); //object(hos_trolley) (6)
CreateObject(1663,1161.26855469,-1340.80761719,9280.03613281,0.00000000,0.00000000,129.99572754); //object(swivelchair_b) (1)
CreateObject(2009,1161.20410156,-1339.68261719,9279.56933594,0.00000000,0.00000000,270.00000000); //object(officedesk2l) (1)
CreateObject(2182,1160.41992188,-1342.13964844,9279.76660156,0.00000000,0.00000000,90.00000000); //object(med_office5_desk_1) (1)
CreateObject(1727,1164.51782227,-1340.79711914,9279.57617188,0.00000000,0.00000000,239.99818420); //object(mrk_seating2b) (1)
CreateObject(1727,1163.76611328,-1338.29174805,9279.56933594,0.00000000,0.00000000,309.99572754); //object(mrk_seating2b) (2)
CreateObject(1808,1162.06445312,-1342.57324219,9279.54980469,0.00000000,0.00000000,185.99304199); //object(cj_watercooler2) (3)
CreateObject(2921,1177.98413086,-1345.60217285,9282.83789062,0.00000000,0.00000000,330.00000000); //object(kmb_cam) (1)
CreateObject(2921,1158.33374023,-1324.11962891,9282.86621094,0.00000000,0.00000000,189.99633789); //object(kmb_cam) (2)
CreateObject(2921,1158.86291504,-1342.73022461,9282.51660156,0.00000000,0.00000000,259.99206543); //object(kmb_cam) (3)
CreateObject(2921,1183.56713867,-1323.83264160,9282.76855469,0.00000000,0.00000000,89.99145508); //object(kmb_cam) (4)
CreateObject(2921,1171.99426270,-1316.56140137,9282.96093750,0.00000000,0.00000000,139.98901367); //object(kmb_cam) (5)
CreateObject(3391,1175.07373047,-1305.24548340,9279.56933594,0.00000000,0.00000000,0.00000000); //object(a51_sdsk_ncol2_) (1)
CreateObject(3390,1175.03552246,-1308.79077148,9279.56933594,0.00000000,0.00000000,0.00000000); //object(a51_sdsk_ncol1_) (1)
CreateObject(3395,1173.14868164,-1304.05212402,9279.56933594,0.00000000,0.00000000,90.00000000); //object(a51_sdsk_3_) (1)
CreateObject(1726,1165.95532227,-1333.03588867,9279.56933594,0.00000000,0.00000000,90.00000000); //object(mrk_seating2) (3)
CreateObject(2370,1167.54455566,-1332.17419434,9279.16308594,0.00000000,0.00000000,0.00000000); //object(shop_set_1_table) (1)
CreateObject(2370,1169.28820801,-1327.00036621,9279.18847656,0.00000000,0.00000000,0.00000000); //object(shop_set_1_table) (2)
CreateObject(2855,1168.29309082,-1331.32019043,9280.00976562,0.00000000,0.00000000,0.00000000); //object(gb_bedmags05) (1)
CreateObject(2852,1170.00463867,-1326.30114746,9280.03515625,0.00000000,0.00000000,0.00000000); //object(gb_bedmags02) (1)
CreateObject(1997,1160.23461914,-1335.54052734,9279.56933594,0.00000000,0.00000000,90.00000000); //object(hos_trolley) (6)
CreateObject(1240,1174.99108887,-1315.88146973,9282.52148438,0.00000000,0.00000000,0.00000000); //object(health) (1)
CreateObject(1241,1164.36645508,-1333.81457520,9282.55859375,0.00000000,0.00000000,0.00000000); //object(adrenaline) (1)
AddStaticPickup(1318, 1, 1172.5526, -1323.2614, 15.4028, -1); // ENTER HOSPITAL
Create3DTextLabel("Hospital - Los Santos\n/enter", 0x008080FF, 1172.5526, -1323.2614, 15.4028, 20.0, 0, 0); // ENTER HOSPITAL
Create3DTextLabel("Los Santos\n/exit", 0x008080FF, 1177.3695, -1340.4095, 9280.5693, 20.0, 0, 0); // EXIT HOSPITAL
Create3DTextLabel("Quick cure\n/healme", 0x008080FF, 1163.2344, -1340.1019, 9280.5693, 20.0, 0, 0); // QUICK CURE
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0x008080FF, "This server uses the hospital system, por: Rodney Francalim");
return 1;
}
public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, 0x008080FF, "This server uses the hospital system, por: Rodney Francalim");
if(Died[playerid])
{
SetPlayerHealth(playerid, 5.0);
new randstretcher = random(sizeof(StretcherAfterDeath));
SetPlayerPos(playerid, StretcherAfterDeath[randstretcher][0], StretcherAfterDeath[randstretcher][1], StretcherAfterDeath[randstretcher][2]);
SetPlayerFacingAngle(playerid, StretcherAfterDeath[randstretcher][3]);
SetPlayerInterior(playerid, 1);
ClearAnimations(playerid);
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
SetPlayerCameraPos(playerid, 1159.3287, -1314.6178, 9282.0693);
SetPlayerCameraLookAt(playerid, 1164.3419, -1305.1895, 9280.5693);
GameTextForPlayer(playerid, "~r~You will be recovered at some seconds~n~Wait...", 60000, 4);
return 1;
}
return 1;
}
CMD:enter(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1172.5526, -1323.2614, 15.4028))
{
SetPlayerInterior(playerid, 1);
SetPlayerPos(playerid, 1177.3695, -1340.4095, 9280.5693);
GameTextForPlayer(playerid, "~r~Hospital", 5000, 1);
SetPlayerFacingAngle(playerid, 90);
SetCameraBehindPlayer(playerid);
}
else SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERROR){A9C4E4}: You aren't at a door.");
return 1;
}
CMD:exit(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1177.3695, -1340.4095, 9280.5693))
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1172.5526, -1323.2614, 15.4028);
GameTextForPlayer(playerid, "~w~Los Santos", 5000, 1);
SetPlayerFacingAngle(playerid, 270);
SetCameraBehindPlayer(playerid);
}
else SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERROR){A9C4E4}: You aren't at a door.");
return 1;
}
CMD:healme(playerid)
{
new Float:life;
GetPlayerHealth(playerid, life);
if(!IsPlayerInRangeOfPoint(playerid, 2.0, 1163.2344, -1340.1019, 9280.5693)) return SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERROR){A9C4E4}: You need be at the first aid station, to heal yourself.");
if(!QuickCure[playerid]) return SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERROR){A9C4E4}: You can't use it now. Back here adter 5 minutes.");
if(life > 50) return SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERROR){A9C4E4}: You aren't hurt enough to a heal.");
else
{
new denominator = random(4);
SetPlayerHealth(playerid, life + life/denominator+1);
SetTimer("BlockHealMe", 300000, false);
QuickCure[playerid] = false;
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
Died[playerid] = true;
return 1;
}
forward BlockHealMe(playerid);
public BlockHealMe(playerid) return QuickCure[playerid] = true, 1;
forward Recovered();
public Recovered()
{
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(Died[playerid])
{
HospitalTime[p]++;
new Float:life;
GetPlayerHealth(p, life);
ApplyAnimation(p, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
switch(HospitalTime[p])
{
case 1 .. 59:
{
SetPlayerHealth(p, life+1);
}
case 60:
{
Died[p] = false;
SendClientMessage(p, 0xA9C4E4AA, "");
SendClientMessage(p, 0xA9C4E4AA, "{DD2222}Doctor{FFFFFF} says: You are restore. Be careful.");
ClearAnimations(p);
SetPlayerPos(p, 1175.0963, -1318.3589, 9280.5693);
SetCameraBehindPlayer(p);
SetPlayerFacingAngle(p, 177.8791);
SetPlayerInterior(p, 1);
HospitalTime[p] = 0;
}
}
}
}
return 1;
}
public OnFilterScriptExit()
{
KillTimer(TimeOfRecovery);
return 1;
}
- It's my first FilterScript that I post here, I hope it is useful.
- It may have some bugs, as 2 players are in the same stretcher, or doesn't play the animation correctly.
6: Thank and credits
- I wanna to thank the Y_Less for the sscanf2 and the tutorial of how to use it.
- Also the Zeex for the ZCMD
- And alexcordeiro for the idea.
••••••••••••••••••••••••••••••••••••••••••••••••••