/drag for Cops RP
#1

Hey guys any of you gave the /drag CMD Duy /drag Vid and where i go he follow ?

I am using this code but as faulty

Код:
if(strcmp(cmd, "/drag", true) == 0)
  {
    if(IsPlayerConnected(playerid))
    {
     if(PlayerInfo[playerid][pAdmin] == 10 || IsACop(playerid))
     {
       tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: /drag [Player ID]");
        return 1;
      }
      giveplayerid = ReturnUser(tmp);
       if(IsPlayerConnected(giveplayerid))
      {
        if(giveplayerid != INVALID_PLAYER_ID)
        {
          if(gTeam[giveplayerid] == 2 || IsACop(giveplayerid))
          {
            SendClientMessage(playerid, COLOR_GREY, "  You can't drag Cops !");
            return 1;
          }
          if(DragOff[giveplayerid] > 0)
          {
            SendClientMessage(playerid, COLOR_GREY, "  You Are already being Dragged!");
            return 1;
          }
         if (ProxDetectorS(3.0, playerid, giveplayerid))
         {
               if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "You Cannot Drag Yourself!"); return 1; }
             GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
             format(string, sizeof(string), "* You are being dragged by %s,", sendername);
            SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
            format(string, sizeof(string), "* You begin to drag %s,", giveplayer);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            format(string, sizeof(string), "* %s has started to drag %s.", sendername ,giveplayer);
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            TogglePlayerControllable(giveplayerid, 0);
            DragOff[giveplayerid] = playerid;

         }
         else
         {
           SendClientMessage(playerid, COLOR_GREY, "  That Player is not near you !");
           return 1;
         }
        }
      }
      else
      {
        SendClientMessage(playerid, COLOR_GREY, "  That player is Offline !");
        return 1;
      }
     }
     else
     {
      SendClientMessage(playerid, COLOR_GREY, "  You are not a Cop / FBI / Navy / National Guard!");
     }
   }
   return 1;
  }
  if(strcmp(cmd, "/stopdrag", true) == 0)
  {
    if(IsPlayerConnected(playerid))
    {
     if(PlayerInfo[playerid][pAdmin] == 10 || IsACop(playerid))
     {
       tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: /stopdrag [Player ID]");
        return 1;
      }
      giveplayerid = ReturnUser(tmp);
      if(IsPlayerConnected(giveplayerid))
      {
        if(giveplayerid != INVALID_PLAYER_ID)
        {
          if (ProxDetectorS(3.0, playerid, giveplayerid))
         {
           if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "You cannot stop dragging yourself!"); return 1; }
           if(DragOff[giveplayerid] > 0)
           {
             GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
             format(string, sizeof(string), "* %s stopped dragging you.", sendername);
            SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
            format(string, sizeof(string), "* You stopped dragging %s.", giveplayer);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            TogglePlayerControllable(giveplayerid, 1);
            DragOff[giveplayerid] = 0;
           }
           else
           {
             SendClientMessage(playerid, COLOR_GREY, "  That player isn't being dragged !");
             return 1;
           }
         }
         else
         {
           SendClientMessage(playerid, COLOR_GREY, "  That player is not near you !");
           return 1;
         }
        }
      }
      else
      {
        SendClientMessage(playerid, COLOR_GREY, "  That player is Offline !");
        return 1;
      }
     }
     else
     {
      SendClientMessage(playerid, COLOR_GREY, "  You are not a Cop / FBI / Navy / National Guard !");
     }
   }//not connected
   return 1;
  }
Reply
#2

You need to keep spawning the dragged player to the player who is dragging them (this would be the simple way). You can probably do this under OnPlayerUpdate, or by using a timer. It would be more accurate under OnPlayerUpdate, but could also cause some server lag.
Reply
#3

I've Tried / stopdrag pen not happen !!!! Help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)