Advertisement
Guest User

PNascondino by Phanto90

a guest
Feb 8th, 2011
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.70 KB | None | 0 0
  1. /*
  2. ================================================================================
  3.                                Phanto's Script
  4. ________________________________________________________________________________
  5. •Script: PNascondino         •Scripter: Phanto90
  6. •Tipo: FS                    •Dimesione: 15 Kb
  7. •Righe: 365                  •Versione: 1.0v
  8. ________________________________________________________________________________
  9.                               * Descrizione *
  10. Dato che ho visto che molti volevano un sistema tipo Hide&Seek (Nascondino), in
  11. un momento di ho deciso di costruire questo semplice mini-game.
  12.  
  13. La dinamica è la seguente:
  14. 1.L'evento viene avviato da un timer a caricamento FS avvenuto.
  15. 2.I giocatori interessati possono partecipare con il comando /partecipa.
  16. 3.Una volta raggiunto un numero cospicuo di partecipanti, si digita /pronto.
  17.   (L'evento non inizia se non ci sono almeno 2 partecipanti)
  18. 4.Quando tutti saranno pronti l'evento inizierà e non sarà più possibile
  19.   parteciparvi.
  20. 5.Verrà scelto a caso il "carcatore" cui verrà dato un Minigun.
  21. 6.Da questo momento gli altri giocatori hanno 1 minuto per nasconderci prima
  22.   che il cercatore venga liberato. (Non preoccupatevi, non può vedervi mentre vi
  23.   nascondente).
  24. 7.Passato il minuto verrà liberato il cercatore che dovrà stanare tutti i
  25.   giocatori nascosti.
  26. 8.Per rendere più equo il gioco, il cercatore avrà 1 minuto a disposizione per
  27.   ogni giocatore partecipante (escluso lui). Quindi: (numeropartecipanti-1)*1min
  28. 9.Se dovesse riuscire a trovare tutti i player nascosti allora vincerebbe,
  29.   altrimenti come potete dedurre, perderebbe.
  30.  
  31. P.S. I giocatori sono "rinchiusi" in un preciso virtual world con dei limiti
  32.      ben stabiliti. Non pensate dunque che si possa fuggire dal luogo designato.
  33. P.S.2 State attenti se avete comandi che permettono di teletrasportarsi/cambiare
  34.       virtual world. Comprometterebbe il mini gioco.
  35.  
  36.               Grazie per aver scelto un prodotto Pawnoscripter!
  37.                      http://pawnoscripter.forumfree.it
  38.      
  39.                                                                       Phanto90
  40. ________________________________________________________________________________
  41.  
  42. Nota: Non ho avuto tempo e voglia  di controllare perfettamente tutto lo script,
  43. quindi potrebbero esserci dei Bug che non mi si sono presentati durante il
  44. testing.Se ne trovate prego di informarmi subito sulla pagina dove avete trovato
  45. la release dello script.
  46.  
  47. Vi preghiamo di non rimuovere i crediti.
  48. ================================================================================
  49. */
  50. #include <a_samp>
  51. //===============COLORI
  52. #define ROSSO 0xFF3233FF
  53. #define BIANCO 0xFFFFFFFF
  54. #define VERDE 0x00FF00FF
  55. //=========================FORWARD
  56. forward AvviaEvento();
  57. forward TimerNascondino();
  58. forward LiberaCercatore();
  59. //==============VARIABILIGIOCATORE
  60. enum InfoGiocatore{InGioco,Pronto};
  61. new Giocatore[MAX_PLAYERS][InfoGiocatore];
  62. //=============VARIABILI
  63. new stringa[1000],nome[25];
  64. //=============EVENTONASCONDINO
  65. enum Stato{Aperto,Partecipanti,Pronti,IdCercatore,Avviato,Tempo};
  66. new Nascondino[Stato];
  67. //============TEXT
  68. new Text:TNascondino;
  69. //============TIMER
  70. new IdTimerNascondino;
  71.  
  72. new Float:Luogo[][3]={
  73. {-816.5020,1444.7694,13.7891},
  74. {-814.5127,1429.0792,13.7891},
  75. {-800.6746,1427.7249,13.7891},
  76. {-802.1630,1445.7024,13.7891},
  77. {-788.8439,1445.3196,13.7891},
  78. {-786.5835,1427.5447,13.7891},
  79. {-775.2170,1427.5573,13.7891},
  80. {-774.8434,1444.6289,13.7931},
  81. {-810.9301,1436.6632,13.7891},
  82. {-786.6681,1437.2847,13.7891},
  83. {-773.8650,1437.9960,13.7891}
  84.  };
  85.  
  86. new Verbi[][25]={  //Simpatiche frasi ad effetto per chi viene scoperto :D
  87.  "sterminato",
  88.  "eliminato",
  89.  "spappolato",
  90.  "disintegrato",
  91.  "polverizzato",
  92.  "ridotto a brandelli",
  93.  "ridotto a un colabrodo",
  94.  "crivellato di colpi",
  95.  "vaporizzato",
  96.  "maciullato"
  97.  };
  98. //===================================================================AVVIAEVENTO
  99. public AvviaEvento()
  100. {
  101.  if(Nascondino[Aperto]==1) return 1;
  102.  SendClientMessageToAll(BIANCO,"[EVENTO:] L'evento {C14124}Nascondino{FFFFFF} sta per iniziare. Digita {C14124}/Partecipa{FFFFFF} per partecipare.");
  103.  Nascondino[Aperto]=1;
  104.  return 1;
  105. }
  106. //===============================================================TIMERNASCONDINO
  107. public TimerNascondino()
  108. {
  109.   if(!Nascondino[Avviato]) return KillTimer(IdTimerNascondino);
  110.   Nascondino[Tempo]--;
  111.   new minuti,secondi;
  112.   minuti=floatround(Nascondino[Tempo]/60);
  113.   secondi=Nascondino[Tempo]-(minuti*60);
  114.   format(stringa,sizeof(stringa)," %02d:%02d",minuti,secondi);
  115.   TextDrawSetString(TNascondino,stringa);
  116.   if(Nascondino[Tempo]==0 && Nascondino[Partecipanti]>1)
  117.   {
  118.   format(stringa,sizeof(stringa),"[EVENTO:] {8CE46C}%s{FFFFFF} Non è riuscito a trovare tutti i giocatori! Ha perso il match!",nome);
  119.   SendClientMessageToAll(BIANCO,stringa);
  120.   ResetPlayerWeapons(Nascondino[IdCercatore]);
  121.   TextDrawHideForPlayer(Nascondino[IdCercatore],TNascondino);
  122.   Nascondino[Avviato]=0;
  123.   Nascondino[Aperto]=0;
  124.   Nascondino[Partecipanti]=0;
  125.   Nascondino[Pronti]=0;
  126.   KillTimer(IdTimerNascondino);
  127.   RiavviaEvento();
  128.   }
  129.   return 1;
  130. }
  131. //===============================================================LIBERACERCATORE
  132. public LiberaCercatore()
  133. {
  134.  if(!Nascondino[Avviato]) return 0;
  135.  TogglePlayerControllable(Nascondino[IdCercatore],1);
  136.  GetPlayerName(Nascondino[IdCercatore],nome,sizeof(nome));
  137.  format(stringa,sizeof(stringa),"[EVENTO:] {8CE46C}%s{FFFFFF} è stato liberato! Nasconditi prima che ti trovi!",nome);
  138.  MandaMessaggioPartecipanti(BIANCO,stringa);
  139.  return 1;
  140. }
  141. //====================================================MANDAMESSAGGIOPARTECIPANTI
  142. stock MandaMessaggioPartecipanti(colore,Messaggio[])
  143. {
  144.  for(new i=0;i<MAX_PLAYERS;i++)
  145.  {
  146.  if(IsPlayerConnected(i) && Giocatore[i][InGioco])
  147.  SendClientMessage(i,colore,Messaggio);
  148.  }
  149. }
  150. //================================================================CHECKFINEGIOCO
  151. stock CheckFineGioco()
  152. {
  153.  if(Nascondino[Partecipanti]>1) return 0;
  154.  GetPlayerName(Nascondino[IdCercatore],nome,sizeof(nome));
  155.  format(stringa,sizeof(stringa),"[EVENTO:] {8CE46C}%s{FFFFFF} ha trovato tutti i giocatori! Vince quindi il match! Congratulazioni!",nome);
  156.  SendClientMessageToAll(BIANCO,stringa);
  157.  TextDrawHideForPlayer(Nascondino[IdCercatore],TNascondino);
  158.  ResetPlayerWeapons(Nascondino[IdCercatore]);
  159.  SetPlayerWorldBounds(Nascondino[IdCercatore],6000,-6000,6000,-6000);
  160.  Nascondino[Avviato]=0;
  161.  Nascondino[Aperto]=0;
  162.  Nascondino[Partecipanti]=0;
  163.  Nascondino[Pronti]=0;
  164.  Nascondino[Tempo]=0;
  165.  RiavviaEvento();
  166.  return 1;
  167. }
  168. //=================================================================RIAVVIAEVENTO
  169. stock RiavviaEvento()
  170. {
  171.   Nascondino[IdCercatore]=-1;
  172.   KillTimer(IdTimerNascondino);
  173.   SetTimer("AvviaEvento",60000*2,false);
  174.   for(new i=0;i<MAX_PLAYERS;i++)
  175.      {
  176.      if(Giocatore[i][InGioco]==1)
  177.       {
  178.       Giocatore[i][InGioco]=0;
  179.       Giocatore[i][Pronto]=0;
  180.       SetPlayerVirtualWorld(i,0);
  181.       SpawnPlayer(i);
  182.       TextDrawHideForPlayer(i,TNascondino);
  183.       SetPlayerWorldBounds(i,6000,-6000,6000,-6000);
  184.       }
  185.      }
  186.   return 1;
  187. }
  188. //============================================================ONFILTERSCRIPTINIT
  189. public OnFilterScriptInit()
  190. {
  191.   print("_____________________________________________");
  192.   print("PNascondino by Phanto90 caricato con successo");
  193.   print("_____________________________________________");
  194.   SetTimer("AvviaEvento",60000*2,false);
  195.   TNascondino = TextDrawCreate(502.000000, 123.000000, " 00:00");
  196.   TextDrawBackgroundColor(TNascondino, 255);
  197.   TextDrawFont(TNascondino, 3);
  198.   TextDrawLetterSize(TNascondino, 1.040000, 3.299999);
  199.   TextDrawColor(TNascondino, -1);
  200.   TextDrawSetOutline(TNascondino, 1);
  201.   TextDrawSetProportional(TNascondino, 1);
  202.   TextDrawUseBox(TNascondino, 1);
  203.   TextDrawBoxColor(TNascondino, 505290340);
  204.   TextDrawTextSize(TNascondino, 615.000000, 1.000000);
  205.   Nascondino[IdCercatore]=-1;
  206.   return 1;
  207. }
  208. //===============================================================ONPLAYERCONNECT
  209. public OnPlayerConnect(playerid)
  210. {
  211.   if(Nascondino[Aperto]==1 && !Nascondino[Avviato])
  212.   SendClientMessage(playerid,BIANCO,"[EVENTO:] L'evento {C14124}Nascondino{FFFFFF} è stato avviato. Digita {C14124}/Partecipa{FFFFFF} per partecipare.");
  213.   return 1;
  214. }
  215. //============================================================ONPLAYERDISCONNECT
  216. public OnPlayerDisconnect(playerid, reason)
  217. {
  218.     TextDrawHideForPlayer(playerid,TNascondino);
  219.     if(Nascondino[IdCercatore]==playerid)
  220.     {
  221.     GetPlayerName(Nascondino[IdCercatore],nome,sizeof(nome));
  222.     format(stringa,sizeof(stringa),"[EVENTO:] {8CE46C}%s{FFFFFF}(cercatore) è uscito dal server. L'evento si è automaticamente chiuso!",nome);
  223.     SendClientMessageToAll(BIANCO,stringa);
  224.     ResetPlayerWeapons(Nascondino[IdCercatore]);
  225.     Giocatore[Nascondino[IdCercatore]][InGioco]=0;
  226.     Giocatore[Nascondino[IdCercatore]][Pronto]=0;
  227.     Nascondino[Avviato]=0;
  228.     Nascondino[Aperto]=0;
  229.     Nascondino[Partecipanti]=0;
  230.     Nascondino[Pronti]=0;
  231.     RiavviaEvento();
  232.     }
  233.     if(Giocatore[playerid][InGioco])
  234.     {
  235.     if(Giocatore[playerid][Pronto])
  236.     Nascondino[Pronti]--;
  237.     Nascondino[Partecipanti]--;
  238.     Giocatore[playerid][InGioco]=0;
  239.     Giocatore[playerid][Pronto]=0;
  240.     GameTextForPlayer(Nascondino[IdCercatore],"Uno in meno a cui pensare!",1,3000);
  241.     CheckFineGioco();
  242.     }
  243.     return 1;
  244. }
  245. //=================================================================ONPLAYERDEATH
  246. public OnPlayerDeath(playerid, killerid, reason)
  247. {
  248.     if(Nascondino[IdCercatore]==playerid)
  249.     {
  250.     GetPlayerName(Nascondino[IdCercatore],nome,sizeof(nome));
  251.     format(stringa,sizeof(stringa),"[EVENTO:] {8CE46C}%s{FFFFFF}(cercatore) è morto. L'evento si è automaticamente chiuso!",nome);
  252.     SendClientMessageToAll(BIANCO,stringa);
  253.     ResetPlayerWeapons(Nascondino[IdCercatore]);
  254.     Giocatore[Nascondino[IdCercatore]][InGioco]=0;
  255.     Giocatore[Nascondino[IdCercatore]][Pronto]=0;
  256.     Nascondino[Avviato]=0;
  257.     Nascondino[Aperto]=0;
  258.     Nascondino[Partecipanti]=0;
  259.     Nascondino[Pronti]=0;
  260.     RiavviaEvento();
  261.     }
  262.     else if(Nascondino[Avviato]==1 && killerid==Nascondino[IdCercatore] && Giocatore[playerid][InGioco])
  263.     {
  264.     GetPlayerName(playerid,nome,sizeof(nome));
  265.     new verbo=random(sizeof(Verbi));
  266.     format(stringa,sizeof(stringa),"[NASCONDINO:] {8CE46C}%s{FFFFFF} è appena stato %s",nome,Verbi[verbo]);
  267.     MandaMessaggioPartecipanti(BIANCO,stringa);
  268.     GameTextForPlayer(killerid,"Uno in meno a cui pensare!",1,3000);
  269.     Nascondino[Partecipanti]--;
  270.     Giocatore[playerid][InGioco]=0;
  271.     Giocatore[playerid][Pronto]=0;
  272.     TextDrawHideForPlayer(playerid,TNascondino);
  273.     SetPlayerWorldBounds(playerid,6000,-6000,6000,-6000);
  274.     SetPlayerVirtualWorld(playerid,0);
  275.     CheckFineGioco();
  276.     }
  277.     else if(Nascondino[Avviato]==1 && Giocatore[playerid][InGioco]==1)
  278.     {
  279.     GetPlayerName(playerid,nome,sizeof(nome));
  280.     format(stringa,sizeof(stringa),"[NASCONDINO:] {8CE46C}%s{FFFFFF} è morto per cause fortuite.",nome);
  281.     MandaMessaggioPartecipanti(BIANCO,stringa);
  282.     SetPlayerWorldBounds(playerid,6000,-6000,6000,-6000);
  283.     TextDrawHideForPlayer(playerid,TNascondino);
  284.     Nascondino[Partecipanti]--;
  285.     Giocatore[playerid][InGioco]=0;
  286.     Giocatore[playerid][Pronto]=0;
  287.     SetPlayerVirtualWorld(playerid,0);
  288.     CheckFineGioco();
  289.     }
  290.     return 1;
  291. }
  292. //===========================================================ONPLAYERCOMMANDTEXT
  293. public OnPlayerCommandText(playerid, cmdtext[])
  294. {
  295.     //====================================PARTECIPA
  296.     if(!strcmp("/partecipa",cmdtext,true))
  297.     {
  298.        if(Giocatore[playerid][InGioco]) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Stai già partecipando all'evento.");
  299.        if(!Nascondino[Aperto]) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}L'evento è chiuso per ora. Prova in un secondo momento.");
  300.        if(Nascondino[Avviato]) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}L'evento è già stato avviato. Attendi il prossimo.");
  301.        new RandomSpawn=random(sizeof(Luogo));
  302.        SetPlayerPos(playerid,Luogo[RandomSpawn][0],Luogo[RandomSpawn][1],Luogo[RandomSpawn][2]);
  303.        SetPlayerVirtualWorld(playerid,501);
  304.        SetPlayerInterior(playerid,0);
  305.        SendClientMessage(playerid,BIANCO,"[EVENTO:] Ora stai partecipanto all'evento. Digita {C14124}Pronto{FFFFFF} quando sei pronto. Devi aspettare fino a quando non saranno tutti pronti.");
  306.        Nascondino[Partecipanti]++;
  307.        Nascondino[Tempo]=(Nascondino[Partecipanti])*60;
  308.        Giocatore[playerid][InGioco]=1;
  309.        SetPlayerHealth(playerid,100);
  310.        SetPlayerWorldBounds(playerid,-739.0712,-916.6221,1629.5925,1416.5366);
  311.        new minuti,secondi;
  312.        minuti=floatround(Nascondino[Tempo]/60);
  313.        secondi=Nascondino[Tempo]-(minuti*60);
  314.        format(stringa,sizeof(stringa)," %02d:%02d",minuti,secondi);
  315.        TextDrawSetString(TNascondino,stringa);
  316.        TextDrawShowForPlayer(playerid,TNascondino);
  317.        SendClientMessage(playerid,BIANCO,"[EVENTO:] Ora stai partecipanto a {C14124}Nascondino{FFFFFF}. Digita {C14124}/Pronto{FFFFFF} quando vuoi iniziare.");
  318.        return 1;
  319.     }
  320.     //===================================PRONTO
  321.     if(!strcmp("/pronto",cmdtext,true))
  322.     {
  323.        if(!Giocatore[playerid][InGioco]) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Non stai partecipando all'evento.");
  324.        if(Giocatore[playerid][Pronto]) return SendClientMessage(playerid,ROSSO,"[ERRORE:] {FFFFFF}Sei già pronto.");
  325.        if(Nascondino[Pronti]!=Nascondino[Partecipanti])
  326.        SendClientMessage(playerid,BIANCO,"[STATO:] Ora sei pronto. Attendi che anche gli altri giocatori siano pronti.");
  327.        if(Nascondino[Partecipanti]==1)
  328.        SendClientMessage(playerid,BIANCO,"[STATO:] Ora sei pronto. Servono almeno 2 giocatori per iniziare l'evento.");
  329.        Giocatore[playerid][Pronto]=1;
  330.        Nascondino[Pronti]++;
  331.        if(Nascondino[Pronti]==Nascondino[Partecipanti] && Nascondino[Partecipanti]>1)
  332.        {
  333.        Nascondino[Avviato]=1;
  334.        new i=0;
  335.        while(i==0)
  336.         {
  337.         Nascondino[IdCercatore]=random(MAX_PLAYERS);
  338.         if(IsPlayerConnected(Nascondino[IdCercatore]) && Giocatore[Nascondino[IdCercatore]][InGioco])
  339.          {
  340.          GivePlayerWeapon(Nascondino[IdCercatore],38,10000);
  341.          TogglePlayerControllable(Nascondino[IdCercatore],0);
  342.          i=1;
  343.          }
  344.         }
  345.        for(i=0;i<MAX_PLAYERS;i++)
  346.        {
  347.        if(Giocatore[i][InGioco]==1 && i!=Nascondino[IdCercatore])
  348.         {
  349.         MandaMessaggioPartecipanti(BIANCO,"[EVENTO:] {C14124}Nascondino sta per iniziare! Svelto hai un minuto per nasconderti!");
  350.         ResetPlayerWeapons(i);
  351.         SetPlayerColor(playerid,GetPlayerColor(playerid) & 0xFFFFFF00);
  352.         }
  353.        }
  354.        GetPlayerName(Nascondino[IdCercatore],nome,sizeof(nome));
  355.        SetPlayerHealth(Nascondino[IdCercatore],100000.0);
  356.        format(stringa,sizeof(stringa),"[EVENTO:] {8CE46C}%s{FFFFFF} è stato selezionato per fare il cercatore.",nome);
  357.        MandaMessaggioPartecipanti(BIANCO,stringa);
  358.        IdTimerNascondino=SetTimer("TimerNascondino",1000,true);
  359.        SetTimer("LiberaCercatore",60000,false);
  360.        }
  361.        return 1;
  362.     }
  363.    
  364.     return 0;
  365. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement