Jump to content
  • Global

    Global

    Chatroom Rules

    • NO SE DA SOPORTE EN CHATBOX
    • NO SPAM
    • NO FLOOD

Recommended Posts

  • Usuario
Posted

He reparado el antiguo FS de Duelo y He Creado este Mucho Mejor

#include <a_samp>
/////////Pragma////////////////
#pragma tabsize 0
/////////Defines///////////////
#define FILTERSCRIPT
#define SendError(%1,%2) SendClientMessage(%1,Rojo,"ERROR: " %2)
#define SendUsage(%1,%2) SendClientMessage(%1,Blanco,"USAGE: " %2)
#define Naranjo    0xFF8040FF
#define Amarillo    0xFFFF00AA
#define Rojo      0xFF0000AA
#define Blanco     0xFFFFFFAA

/////////Stock/////////////////
stock
  InvitadoAlDuelo[MAX_PLAYERS],
  HasInvitadoAlDuelo[MAX_PLAYERS],
  JugadorEnElDuelo[MAX_PLAYERS],
  Conteo[MAX_PLAYERS],
  DueloTimer[MAX_PLAYERS],
  DueloEnProgreso,
  DueloID1,
  DueloID2;

/////////CallBacks/////////////
public OnFilterScriptInit()
{
  print("\t============================================");
  print("\tSistema De Duelo");
  print("\t-----------------");
  print("\t---------------------------------------------");
  print("\tCargando......!");
  print("\t============================================");
  return 1;
}

public OnFilterScriptExit()
{
  print("\t============================================");
  print("\tSistema De Duelo ");
  print("\t/////////////////");
  print("\t--------------------------------------------");
  print("\tFinalizando.....!");
  print("\t============================================");
  return 1;
}

public OnPlayerConnect(playerid)
{
  InvitadoAlDuelo[playerid] = 0;
  HasInvitadoAlDuelo[playerid] = 0;
  JugadorEnElDuelo[playerid]  = 0;
  return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  if(playerid == DueloID1 || playerid == DueloID2)
  {
      DueloEnProgreso = 0;
  }
  return 1;
}

strtok(const string[], &index)
{
   new length = strlen(string);
   while ((index < length) && (string[index] <= ' '))
   {
       index++;
   }

   new offset = index;
   new result[20];
   while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
   {
       result[index - offset] = string[index];
       index++;
   }
   result[index - offset] = EOS;
   return result;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
   new cmd[256], idx, tmp[256];
   cmd = strtok(cmdtext, idx);
   if(!strcmp(cmd, "/duelo", true))
   {
       tmp = strtok(cmdtext, idx);
       if(!strlen(tmp))
       {
           SendClientMessage(playerid, 0xBFC0C2FF, "Uso: /duelo [playerid]");
           return 1;
       }
       if(HasInvitadoAlDuelo[playerid] == 1) return SendError(playerid, "Ya Has Invitado a alguien a un duelo!");

       new DuelID = strvalEx(tmp), pName[MAX_PLAYER_NAME],zName[MAX_PLAYER_NAME],tString[128];

      GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
      GetPlayerName(DuelID, zName, MAX_PLAYER_NAME);

      if (!IsPlayerConnected(DuelID)) return SendError(playerid, "Jugador No Conectado.");
   if(   HasInvitadoAlDuelo[DuelID] == 1) return SendError(playerid, "Ese jugador es invitado a un duelo!");
   if(   DuelID  == playerid)  return SendError(playerid, "No puedes tener un duelo contigo mismo!");

  format(tString, sizeof(tString), "Invitaste a %s (ID:%d) a un duelo 1 vs 1, espera que %s acepte la invitacion.",zName, DuelID, zName);
  SendClientMessage(playerid, Amarillo, tString);

  format(tString, sizeof(tString), "Tu haz sido invitado a un duelo por %s (ID:%d) a un duelo 1 vs 1, tipea /aceduelo [iD Del Jugador] para aceptar y empezar el duelo.",pName, playerid);
  SendClientMessage(DuelID, Amarillo, tString);

  InvitadoAlDuelo[DuelID] = playerid;
  HasInvitadoAlDuelo[playerid] = 1;
  return 1;
}

  if(!strcmp(cmd, "/haceduelo", true))
   {
       tmp = strtok(cmdtext, idx);
       if(!strlen(tmp))
       {
           SendClientMessage(playerid, 0xBFC0C2FF, "Uso: /haceduelo [playerid]");
           return 1;
       }

       if(DueloEnProgreso == 1)return SendError(playerid, "Otro Duelo esta en progreso, espera a que ese duelo Termine!");

       new DuelID = strvalEx(tmp),pName[MAX_PLAYER_NAME],zName[MAX_PLAYER_NAME],tString[128];

       if(DuelID != InvitadoAlDuelo[playerid])return SendError(playerid, "Ese jugador no te invito a un Duelo!");

       GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
       GetPlayerName(DuelID, zName, MAX_PLAYER_NAME);

       format(tString, sizeof(tString), "Tu has aceptado el duelo con  %s (ID:%d),  El duelo comenzara en 10 segundos..",zName,DuelID);
       SendClientMessage(playerid, Amarillo, tString);

       format(tString, sizeof(tString), "%s (ID:%d), Acepto el duelo, El duelo comenzara en 10 segundos..",pName,playerid);
       SendClientMessage(DuelID, Amarillo, tString);

       format(tString, sizeof(tString), "***Informacion: Se inicia un duelo entre %s y %s comenzara en 10 segundos",pName,zName);
       SendClientMessageToAll(Naranjo, tString);

       InitializeDuel(playerid);
       InitializeDuelEx( DuelID);

       JugadorEnElDuelo[playerid] = 1;
       JugadorEnElDuelo[DuelID] = 1;

       DueloID1 = playerid;
       DueloID2 = DuelID;

          DueloEnProgreso = 1;
          return 1;
   }

   if (strcmp("/cduelo", cmdtext, true, 10) == 0)
      {
       if(HasInvitadoAlDuelo[playerid] == 0) return SendError(playerid, "Tu no has invitado a nadie a un Duelo!");

          SendClientMessage(playerid, Amarillo, "Cancelaste tu invitacion de duelo, Ahora puedes usar /duelo [iD Del Jugador] de nuevo.");
          HasInvitadoAlDuelo[playerid] = 0;
          return 1;
   }
   return 0;
}

forward InitializeDuel(playerid);
public InitializeDuel(playerid)
{
   DueloTimer[playerid]  = SetTimerEx("DuelCountDown", 1000, 1, "i", playerid);

  SetPlayerHealth(playerid, 100);
  SetPlayerArmour(playerid, 100);

   SetPlayerPos(playerid, 1332.3190,2140.1152,11.0156); // da1
  //SetPlayerFacingAngle(playerid, A);
   SetCameraBehindPlayer(playerid);
   TogglePlayerControllable(playerid, 0);
   Conteo[playerid] = 11;

  return 1;
}

forward InitializeDuelEx(playerid);
public InitializeDuelEx(playerid)
{
   DueloTimer[playerid]  = SetTimerEx("DuelCountDown", 1000, 1, "i", playerid);

  SetPlayerHealth(playerid, 100);
  SetPlayerArmour(playerid, 100);

   SetPlayerPos(playerid, 1371.2172,2170.0876,11.0234);
   //SetPlayerFacingAngle(playerid, A);
   SetCameraBehindPlayer(playerid);
   TogglePlayerControllable(playerid, 0);
   Conteo[playerid] = 11;

  return 1;
}

forward DuelCountDown(playerid);
public DuelCountDown(playerid)
{
  new
     tString[128] ;

  Conteo[playerid] --;

  PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);

  format(tString, sizeof(tString), "~w~%d", Conteo[playerid]);
  GameTextForPlayer(playerid, tString, 900, 3);

   if(Conteo[playerid] == 0)
   {
       KillTimer(DueloTimer[playerid]);
       TogglePlayerControllable(playerid, 1);
       GameTextForPlayer(playerid,"~g~YA", 900, 3);
       return 1;
   }

  return 1;
}

strvalEx(xxx[])
{
  if(strlen(xxx) > 9)
  return 0;
  return strval(xxx);
}

/*IsNumeric(const string[])
{
  for (new i = 0, j = strlen(string); i < j; i++)
  {
     if (string[i] > '9' || string[i] < '0') return false;
  }
  return true;
}*/

public OnPlayerDeath(playerid, killerid, reason)
{
  new
      sString[128],
        pName[MAX_PLAYER_NAME],
        zName[MAX_PLAYER_NAME],
        Float:Health,
        Float:Armor;

  if(JugadorEnElDuelo[playerid] == 1 && JugadorEnElDuelo[killerid] == 1)
  {
     GetPlayerHealth(killerid, Health);
       GetPlayerArmour(killerid, Armor);

     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
       GetPlayerName(killerid, zName, MAX_PLAYER_NAME);

     if(Health > 90.0 && Armor > 90.0)
       {
         format(sString, sizeof(sString),"***Informacion: %s Ha\"Ganado\" a %s en el duelo quedo con %.2f de vida y %.2f de blindaje!", zName,pName,Health,Armor);
           SendClientMessageToAll(Naranjo, sString);

        InvitadoAlDuelo[playerid] = 0;HasInvitadoAlDuelo[playerid] = 0;JugadorEnElDuelo[playerid]  = 0;
           InvitadoAlDuelo[killerid] = 0;HasInvitadoAlDuelo[killerid] = 0;JugadorEnElDuelo[killerid]  = 0;
           DueloEnProgreso = 0;
        return 1;
        }
        else
        {
         format(sString, sizeof(sString),"***Informacion: %s a ganado el duelo contra %s con %.2f de vida y %.2f de blindaje!", zName,pName,Health,Armor);
            SendClientMessageToAll(Naranjo, sString);

        InvitadoAlDuelo[playerid] = 0;HasInvitadoAlDuelo[playerid] = 0;JugadorEnElDuelo[playerid]  = 0;
           InvitadoAlDuelo[killerid] = 0;HasInvitadoAlDuelo[killerid] = 0;JugadorEnElDuelo[killerid]  = 0;
        DueloEnProgreso = 0;
        return 1;
     }
  }
  return 1;
}

Funciona al 100%

 

Creditos

Charless - Lo Reparo y Co-Creo

[NB]Sneaky - Lo Creo

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...