[Solved] multi varuble dcmd help
#1

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?
Reply
#2

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 ?
Reply
#3

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;
}
Reply
#4

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");
    }
  }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)