SA-MP Forums Archive
[Solved] multi varuble dcmd help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Solved] multi varuble dcmd help (/showthread.php?tid=130239)



[Solved] multi varuble dcmd help - rothhear - 25.02.2010

okay this is my idea i want a command [p2p <player1 id> <player2 id>

Код:
dcmd_p2p(playerid, params[])
{
}
i know how to check if the two targets are online and move them thats easy. its getting 2 or more varubles from params which is my problem. this command needs 2 inputs. but i have another command i am working on that meeds 4 like /blahh 123 123 123 123. what would be a good method to get them?


Re: multi varuble dcmd help - actiwe - 25.02.2010

If using sscanf then
Код:
new player2, player3;
if(sscanf(params, "uu", player2, player3)) return SendClientMessage(playerid, COLOR, "USAGE: /p2p [id] ((to)) [id]")
Or i misunderstanded you ?


Re: multi varuble dcmd help - Miguel - 25.02.2010

Use sscanf:
pawn Код:
dcmd_p2p(playerid, params[])
{
  new
    id1,
    id2;

  if(sscanf(params, "uu", id1, id2)) return SendClientMessage(playerid, COLOR, "USAGE: /p2p <player 1 id> <player 2 id>");
  else
  {
    // code, using id1 and id2 as variables for those players, example:
    if(id1 == id2)
    {
      for(new i = 0; i < MAX_PLAYERS; i ++) SendClientMessage(i, COLOR, "Noob!"), Ban(i);
    }
  }
  return 1;
}



Re: multi varuble dcmd help - rothhear - 25.02.2010

wow. i tried somthing similure to that. but i did new id1[250] and thats why it wasnt working. I have to say The SA-MP community seems to be far better then other coding comminitys out there like Runuo. i didnt get flamed and told to use the search button a hundred times. well here is my code works like a charm thanks.
Код:
dcmd_p2p(playerid, params[])
{
  new id1, id2;

  if(sscanf(params, "uu", id1, id2)) return SystemMsg(playerid, "USAGE: /p2p <player 1 id> <player 2 id>");
  else
  {
    if(id1 != id2)
    {
      if (IsPlayerConnected(id1))
			{
        if (IsPlayerConnected(id2))
				{
	      		new Float:pPos[ 3 ];
						GetPlayerPos(id1, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
						
						SetPlayerPos( id2, pPos[ 0 ], pPos[ 1 ], pPos[ 2 ] );
						SetPlayerInterior(id2, GetPlayerInterior(id1));
						SystemMsg(playerid, "You've teleported the player to you!");
				}
				else
	    	    {
					return SystemMsg(playerid, "ERROR: Coulnt find Player 2");
	    	    }
			}
			else
    	    {
				return SystemMsg(playerid, "ERROR: Coulnt find Player 1");
    	    }
    }
    else
    {
      return SystemMsg(playerid, "ERROR: Cannot move a person to themselfs");
    }
  }