Sistema de hospital

Ir em baixo

Sistema de hospital

Mensagem por RodneyFrancalim em Seg Nov 05, 2012 11:02 am

Rodney Francalim

FilterScripts

••••••••••••••••••••••••••••••••••••••••••••••••••

1: Descrição
- Mais uma vez, título auto-explicativo. É um simples sistema de hospital onde, assim que o jogador morre, ele será teleportado para um interior de hospital (já com os objetos no FS), e lá o mesmo será recuperado gradativamente (pode-se notar a barra de HP quando ele está na maca) e após a recuperação o jogador será teleportado para a sala de espera no próprio hospital, onde este se localiza em Los Santos, Market (acho). E também tem um pronto-socorro em que o jogador pode usar o /curarme, e recuperar seu HP, mas o jogador precisa ter menos da metade + 1 do máximo de HP, ou seja, de 50 pra baixo, e o HP não será recuperado totalmente, será o valor atual do HP mais o valor atual do HP dividido por um número aleatório de 1 a 5. Exemplo: Se o jogador tem 30 de HP, quando ele digitar /curarme, será 30 + 30/x, em que, quanto menor o x, maior será a recuperação, em que x é diferente de 0. :p

- Lista de comandos:
• /entrar
• /sair
• /curarme

2: Do que precisaremos?
- ZCMD
- sscanf2

3: Imagens
- Quando o jogador morre

'-> NOTA:: Se você quer mais imagens do hospital, clique neste link

4: Código
http://pastebin.com/b6mgzg7m
Mas caso aconteça algo que impeça alguém de acessar o pastebin.com
Código:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

new bool:CuraRapida[MAX_PLAYERS] = true;
new bool:Morreu[MAX_PLAYERS] = false;

new TempoRecuperandoSe;

new TempoHospital[MAX_PLAYERS] = 0;

new Float:MacaAposMorrer[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          Sistema de hispital");
    print("                    Por: Rodney Francalim\n\n\n");

    // 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);                                                  // ENTRAR NO HOSPITAL

    Create3DTextLabel("Hospital de Los Santos\n/entrar", 0x008080FF, 1172.5526, -1323.2614, 15.4028, 20.0, 0, 0);  // ENTRAR NO HOSPITAL
    Create3DTextLabel("Los Santos\n/sair", 0x008080FF, 1177.3695, -1340.4095, 9280.5693, 20.0, 0, 0);              // SAIR DO HOSPITAL
    Create3DTextLabel("Cura rápida\n/curarme", 0x008080FF, 1163.2344, -1340.1019, 9280.5693, 20.0, 0, 0);          // CURA RÁPIDA
   return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, 0x008080FF, "Este servidor usa o sistema de hospital, por: Rodney Francalim");
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SendClientMessage(playerid, 0x008080FF, "Este servidor usa o sistema de hospital, por: Rodney Francalim");
    if(Morreu[playerid])
    {
        SetPlayerHealth(playerid, 5.0);
        new randmaca = random(sizeof(MacaAposMorrer));
        SetPlayerPos(playerid, MacaAposMorrer[randmaca][0], MacaAposMorrer[randmaca][1], MacaAposMorrer[randmaca][2]);
        SetPlayerFacingAngle(playerid, MacaAposMorrer[randmaca][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~Voce sera recuperado em alguns segundos~n~Aguarde", 60000, 4);
        TempoRecuperandoSe = SetTimer("RecuperouSe", 1000, true);
        return 1;
    }
    return 1;
}

CMD:entrar(playerid)
{
    if(PlayerToPoint(1.0, playerid, 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}(ERRO){A9C4E4}: Você não está em nenhuma porta.");
    return 1;
}

CMD:sair(playerid)
{
    if(PlayerToPoint(1.0, playerid, 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}(ERRO){A9C4E4}: Você não está em nenhuma porta.");
    return 1;
}

CMD:curarme(playerid)
{
    new Float:vida;
    GetPlayerHealth(playerid, vida);
    if(!PlayerToPoint(2.0, playerid, 1163.2344, -1340.1019, 9280.5693)) return SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERRO){A9C4E4}: Você precisa estar no pronto-socorro para curar-se.");
    if(!CuraRapida[playerid]) return SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERRO){A9C4E4}: Você já se curou há menos de 5 minutos. Volte mais tarde.");
    if(vida > 50) return SendClientMessage(playerid, 0xA9C4E4AA, "{FF0000}(ERRO){A9C4E4}: Você não está ferido o suficiente para curar-se.");
    else
    {
        new denominador = random(4);
        SetPlayerHealth(playerid, vida + vida/denominador+1);
        SetTimer("BlockCurarMe", 300000, false);
        CuraRapida[playerid] = false;
    }
    return 1;
}

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

forward BlockCurarMe(playerid);
public BlockCurarMe(playerid) return CuraRapida[playerid] = true, 1;

forward RecuperouSe(playerid);
public RecuperouSe(playerid)
{
    TempoHospital[playerid]++;
    new Float:vida;
    GetPlayerHealth(playerid, vida);
    ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    switch(TempoHospital[playerid])
    {
        case 1 .. 59:
        {
            SetPlayerHealth(playerid, vida+1);
        }
        case 60:
        {
            Morreu[playerid] = false;
            SendClientMessage(playerid, 0xA9C4E4AA, "");
            SendClientMessage(playerid, 0xA9C4E4AA, "{DD2222}Médico{FFFFFF} diz: Você foi recuperado. Seja mais cuidado a partir de agora.");
            ClearAnimations(playerid);
            SetPlayerPos(playerid, 1175.0963, -1318.3589, 9280.5693);
            SetCameraBehindPlayer(playerid);
            SetPlayerFacingAngle(playerid, 177.8791);
            SetPlayerInterior(playerid, 1);
            KillTimer(TempoRecuperandoSe);
            TempoHospital[playerid] = 0;
        }
    }
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

// ========================================================================== //
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
   {
      new Float:oldposx, Float:oldposy, Float:oldposz;
      new Float:tempposx, Float:tempposy, Float:tempposz;
      GetPlayerPos(playerid, oldposx, oldposy, oldposz);
      tempposx = (oldposx -x);
      tempposy = (oldposy -y);
      tempposz = (oldposz -z);
      if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
      {
         return 1;
      }
   }
    if(IsPlayerConnected(playerid))
   {
      new Float:oldposx, Float:oldposy, Float:oldposz;
      new Float:tempposx, Float:tempposy, Float:tempposz;
      GetPlayerPos(playerid, oldposx, oldposy, oldposz);
      tempposx = (oldposx -x);
      tempposy = (oldposy -y);
      tempposz = (oldposz -z);
      if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
      {
         return 1;
      }
   }
   return 0;
}

5: Considerações finais
- Este é o primeiro FilterScript que posto aqui, espero que seja útil. :p
- Pode ter alguns bugs, como 2 jogadores estarem em uma mesma maca, ou não executar a animação corretamente. :mrgreen:

6: Agradecimento e créditos
- Quero agradecer ao Y_Less pela criação do sscanf2 ter criado o tutorial de como usá-lo.
- Também ao Zeex pela criação do ZCMD
- E ao alexcordeiro por ter dado a ideia. :mrgreen:

••••••••••••••••••••••••••••••••••••••••••••••••••
avatar
RodneyFrancalim
MEMBRO FusioN
MEMBRO FusioN

Mensagens 43
Reputação : 0
Brasil Google Chrome

Voltar ao Topo Ir em baixo

Re: Sistema de hospital

Mensagem por Anthrax_FusioN em Ter Jun 18, 2013 12:44 pm

Cara, posso estar errado, mas pra resolver o bug de 2 players irem parar na mesma maca não seria possivel fazer uma checagem de distância tipo colocar as coordenadas da primeira maca e checar se tem algum player naquela posição ai se fosse o caso mandava o outro player para a segunda maca e se tivesse livre mandar pra primeira maca mesmo, e assim faria com a segunda e a terceira e por ai vai?
avatar
Anthrax_FusioN

Mensagens 12
Reputação : 0
Brasil Mozilla Firefox

Voltar ao Topo Ir em baixo

Re: Sistema de hospital

Mensagem por Anderson_FusioN em Qui Jun 20, 2013 9:03 pm

O sistema é bastante interessante, já vi em outros servers....
Acho legal em servidores RP, agora tem que ver com o Chefão se ele curte...

Eu aprovo, pessoalmente acho que para com essa viagem de ficar morrendo e voltando pro combate...

Essa é minha opinião, é claro! kkkk
avatar
Anderson_FusioN

Mensagens 8
Reputação : 0
Brasil

Voltar ao Topo Ir em baixo

Re: Sistema de hospital

Mensagem por Conteúdo patrocinado


Conteúdo patrocinado


Voltar ao Topo Ir em baixo

Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum