[SOLVED] /drag
#1

I know it's kind of stupid to ask about it beacuse its many topics but. The scipts at topic doesnt works, or the pastebin at topics are not active anymore.

Thats why i want a /drag and /stopdrag command that teleports player to you every 2 secounds.

Thanks if somone have a link to topic that realy works, or can paste this code
Reply
#2

I know its possible to make, but I cant get mine to work Anyone?
Reply
#3

Damn good idea!

Id like to know it too, how it happens :P
Reply
#4

Would be a kinda neat feature for admins. But really its quite simple enough to just /summonuser ID. And just have him teleport to you.
Reply
#5

Its easy! I have it in my script. All you need is a really fast timer and use Float: X,Y,Z and teleport the player just a little bit away from the player that is dragging him.
Reply
#6

Its really cool i hope someone makes a script for it ..
Reply
#7

I found some script, trying to get it work:

Top:
Код:
new Dragged[MAX_PLAYERS];
new IsDragged[MAX_PLAYERS];

//Longer down at the public's
public Dragging(playerid,giveplayerid)
{
	new Float:X1, Float:Y1, Float:Z1, Float:A1;
	GetPlayerFacingAngle(playerid,A1);
	GetPlayerPos(playerid,X1,Y1,Z1);
	SetPlayerInterior(giveplayerid,GetPlayerInterior(playerid));
	SetPlayerFacingAngle(giveplayerid,A1+180);
	SetPlayerPos(giveplayerid,X1,Y1+2,Z1);
	TogglePlayerControllable(giveplayerid,0);
	return 1;
}
Command:
Код:
if (!strcmp(cmd, "/drag", true))
	{
		if(gTeam[playerid] == 2 || IsACop(playerid))
		{
    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, 0xFF0000AA, "/drag [playerid]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
  		if(!IsNumeric(tmp))
			{
   			SendClientMessage(playerid,COLOR_RED, "/drag [playerid] Playerid must be a number!");
   			return 1;
   		}

			if(IsPlayerConnected(giveplayerid))
			{
				if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3)
 				{
 					SendClientMessage(playerid, 0xFF0000AA, "You are too far away from that player.");
  				return 1;
  			}

				if(giveplayerid == playerid)
				{
					SendClientMessage(playerid, COLOR_RED, "You cannot drag yourself!");
					return 1;
				}
				
				if(Dragged[giveplayerid] == 0)
				{
				  GetPlayerName(giveplayerid, sendername, sizeof(sendername));
				  GetPlayerName(playerid, playername, sizeof(playername));
				  
					format(string, sizeof(string), "Officer %s started dragging %s", playername, sendername);
					ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					TogglePlayerControllable(giveplayerid,0);
					Dragged[giveplayerid] = 1;
					IsDragged[playerid] = SetTimerEx("Dragging", 1000, true, "i", giveplayerid);
				}
				else
				{
					SendClientMessage(playerid, 0xFF0000AA, "This player is already being dragged");
				}
			}
			else
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid,0xFF0000AA, string);
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "  You are not a Cop / FBI / Marine !");
		}
		return 1;
	}
This code kind of works, but when i try to drag, nothing happens. I and the player I wanted to drag get freezed. And if I unfreeze the other player I wanted to drag with admin command, he starts to drag me

Help!
Reply
#8

Put this at the top of your script:

Код:
new DragTimer[MAX_PLAYERS];

forward Drag(draggerid, playerid);
Put this in OnPlayerCommandText:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
     new cmd[30];
     new tmp[30];
     new idx;
     cmd = strtok(cmdtext, idx);

     if(strcmp(cmd, "/drag", false)==0)
     {
         if(DragTimer[playerid] < 0)
         {
              tmp = strtok(cmdtext, idx);
              new draggedid = strval(tmp);
              if(IsPlayerConnected(draggedid) == 1)
             {       
                  DragTimer[playerid] = SetTimerEx("Drag", 2000, 1, "ii", draggedid, playerid);
                  return 1;
             }
        }
     }
     if(strcmp(cmd, "/undrag", false) == 0)
     {
         if(DragTimer[playerid] >= 0)
         {
         KillTimer(DragTimer[playerid]);
         DragTimer[playerid] = 0;
         return 1;
         }
     }
     return 0
}
Put this anywhere in your script:

Код:
public Drag(draggerid, playerid)
{
     new Float:x, Float:y, Float:z;
     GetPlayerPos(draggerid, x, y, z);
     SetPlayerPos(playerid, x, y, z + 2);
     SetPlayerInterior(playerid, GetPlayerInterior(draggerid));
}
}
Not tested and I'm not 100% sure what will happen if more than one person drags. Also I've not added any messages so you might want to.
Reply
#9

Okey, now I used piece of script from lol2112. I did heavy modification because of many leaks and brackets shit. It kind of works now. But its same problem, the player I target drags me, instead of me dragging him! HELP!

Top:
Код:
forward Drag(giveplayerid, playerid);

new DragTimer[MAX_PLAYERS];
Public:
Код:
public Drag(giveplayerid, playerid)
{
     new Float:x, Float:y, Float:z;
     GetPlayerPos(giveplayerid, x, y, z);
     SetPlayerPos(playerid, x, y, z + 2);
     SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
}
Onplayercommandtext:
Код:
if (strcmp(cmd, "/drag", true) == 0)
	{
	  if(gTeam[playerid] == 2 || IsACop(playerid))
		{
		  tmp = strtok(cmdtext, idx);
			giveplayerid = strval(tmp);
		  if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /drag [playerid]");
				return 1;
			}
			if(!IsPlayerConnected(giveplayerid))
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid,COLOR_GREY, string);
				return 1;
			}
			if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3)
			{
 				SendClientMessage(playerid, 0xFF0000AA, "You are too far away from that player.");
  			return 1;
  			}
  			if(giveplayerid == playerid)
			{
				SendClientMessage(playerid, COLOR_RED, "You cannot drag yourself!");
				return 1;
			}
			if(DragTimer[playerid] <= 0)
			{
				if(IsPlayerConnected(giveplayerid) == 1)
				{
				  GetPlayerName(giveplayerid, sendername, sizeof(sendername));
			  	GetPlayerName(playerid, playername, sizeof(playername));
				  format(string, sizeof(string), "Officer %s started dragging %s", playername, sendername);
					ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					DragTimer[playerid] = SetTimerEx("Drag", 2000, 1, "ii", giveplayerid, playerid);
					return 1;
				}
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "  You are not a Cop / FBI / Marine !");
		}
		return 1;
 	}
 	
 	if (strcmp(cmd, "/stopdrag", true) == 0)
	{
	  if(gTeam[playerid] == 2 || IsACop(playerid))
		{
			if(DragTimer[playerid] >= 0)
			{
				KillTimer(DragTimer[playerid]);
				DragTimer[playerid] = 0;
				return 1;
			}
    }
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "  You are not a Cop / FBI / Marine !");
		}
		return 1;
	}
Reply
#10

Quote:
Originally Posted by Blt950
I did heavy modification because of many leaks and brackets shit.
Excuse me...exactly what modifications did you make except for change the variables for my public function heading (which wasn't necessary, i used draggerid to make it clear) and get rid of an extra } which was a typo...That's hardly even light modification. Don't forget you're the one who couldn't write this.

I don't get why you've already added all that stuff to the basic script. Start simple, make sure that the core of the code works before you add the extra stuff.

Change:

Код:
DragTimer[playerid] = SetTimerEx("Drag", 2000, 1, "ii", draggedid, playerid);
to:

Код:
DragTimer[playerid] = SetTimerEx("Drag", 2000, 1, "ii",playerid, draggedid);
That's in my code, and then do whatever you want for yours.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)