/sendto help?
#1

Hello.
I trying to develop a command.
/sendto [player1] [player2]

Player 1 = The player that is being teleported
Player 2 = The destination of Player 1

Anyone?
Reply
#2

Код:
CMD:sendto(playerid, params[])
{
    new id, id2;
    if(sscanf(params, "uu", id, id2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "USAGE: /sendto [player1] [player2]");
        SendClientMessage(playerid, 0xFF0000FF, "You are going to move [player2] to [player1] position."); 
        return 1;
    }
    else if(!IsPlayerConnected(id) || !IsPlayerConnected(id2) || id == playerid || id2 == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
    else
    {
        new Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
        GetPlayerName(id, name, sizeof(name));
        GetPlayerPos(id, x, y, z);
        SetPlayerPos(id2, x+1, y+1, z);
        format(string, sizeof(string), "You have been moved to %s position.", name);
        SendClientMessage(playerid, 0xFF0000FF, string);
    }
    return 1;
}
Reply
#3

Uzing ZCMD + Sscanf here is an example:

PHP код:
CMD:sendto(playeridparams[])
{
    new 
targetidtargetid1aname[MAX_PLAYER_NAME], string[278], Float:XFloat:Y,Float:Ztname[MAX_PLAYER_NAME], tname1[MAX_PLAYER_NAME];
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playeridRed"You must be an admin to use this command!");
    if(
sscanf(params"uu"targetidtargetid1)) return SendClientMessage(playeridGreen"Correct Usage: /tpto [PlayerID1] [PlayerID2]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridYellow"This player is not connected to the server ID 1");
    if(!
IsPlayerConnected(targetid1)) return SendClientMessage(playeridYellow"This player is not connected to the server ID 2");
    
GetPlayerPos(targetidFloat:XFloat:YFloat:Z);
    
GetPlayerName(targetidtnameMAX_PLAYER_NAME);
    
GetPlayerName(targetid1tname1MAX_PLAYER_NAME);
    
GetPlayerName(playeridanameMAX_PLAYER_NAME);
    
format(stringsizeof(string), "Admin %s has teleported %s to %s"anametnametname1);
    
SetPlayerPos(targetid1Float:X+1,Float:Y+1,Float:Z);
    
SendClientMessageToAll(Yellowstring);
    return 
1;

Made it along time ago so there might be mistakes
Reply
#4

Код:
CMD:sendto(playerid, params[])
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFF0000AA, "You need to be RCON for use this command");
new player1;
new player2;
new str[128];
new p1[MAX_PLAYER_NAME];
new p2[MAX_PLAYER_NAME];
new pd[MAX_PLAYER_NAME];
if(sscanf(params, "uu", player1, player2))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /sendto [p1][p2]");
if(player1 == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF0000AA, "Error: player not connected");
if(player2 == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF0000AA, "Error: player not connected");
GetPlayerName(playerid, pd, MAX_PLAYER_NAME);
GetPlayerName(player1, p1, MAX_PLAYER_NAME);
GetPlayerName(player2, p2, MAX_PLAYER_NAME);
new Float:x;
new Float:y;
new Float:z;
GetPlayerPos(player1, x, y, z);
SetPlayerPos(player2, x+1, y+1, z);
format(str, sizeof(str),"Admin %s has teleported you to %s", pd, p2);
SendClientMessage(player1, 0x00FF00AA, str);
format(str, sizeof(str),"Admin %s teleported %s to you", pd, p1);
SendClientMessage(player2, 0x00FF00AA, str);
format(str, sizeof(str), "You teleported %s to %s", p1, p2);
SendClientMessage(playerid, 0x00FF00AA, str);
return 1;
}
Obviously you need to have sscanf in plugin and sscanf2 in includes, and zcmd
Reply
#5

How can I get this to strcmp?
Reply
#6

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
     if(strcmp(cmdtext, "/sendto", true))
     {
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFF0000AA, "You need to be RCON for use this command");
new player1;
new player2;
new str[128];
new p1[MAX_PLAYER_NAME];
new p2[MAX_PLAYER_NAME];
new pd[MAX_PLAYER_NAME];
if(sscanf(params, "uu", player1, player2))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /sendto [p1][p2]");
if(player1 == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF0000AA, "Error: player not connected");
if(player2 == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF0000AA, "Error: player not connected");
GetPlayerName(playerid, pd, MAX_PLAYER_NAME);
GetPlayerName(player1, p1, MAX_PLAYER_NAME);
GetPlayerName(player2, p2, MAX_PLAYER_NAME);
new Float:x;
new Float:y;
new Float:z;
GetPlayerPos(player1, x, y, z);
SetPlayerPos(player2, x+1, y+1, z);
format(str, sizeof(str),"Admin %s has teleported you to %s", pd, p2);
SendClientMessage(player1, 0x00FF00AA, str);
format(str, sizeof(str),"Admin %s teleported %s to you", pd, p1);
SendClientMessage(player2, 0x00FF00AA, str);
format(str, sizeof(str), "You teleported %s to %s", p1, p2);
SendClientMessage(playerid, 0x00FF00AA, str);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)