/sendto help? -
Shannkz - 15.10.2012
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?
Re: /sendto help? -
RedJohn - 15.10.2012
Код:
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;
}
Re: /sendto help? -
gtakillerIV - 15.10.2012
Uzing ZCMD + Sscanf here is an example:
PHP код:
CMD:sendto(playerid, params[])
{
new targetid, targetid1, aname[MAX_PLAYER_NAME], string[278], Float:X, Float:Y,Float:Z, tname[MAX_PLAYER_NAME], tname1[MAX_PLAYER_NAME];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, Red, "You must be an admin to use this command!");
if(sscanf(params, "uu", targetid, targetid1)) return SendClientMessage(playerid, Green, "Correct Usage: /tpto [PlayerID1] [PlayerID2]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, Yellow, "This player is not connected to the server ID 1");
if(!IsPlayerConnected(targetid1)) return SendClientMessage(playerid, Yellow, "This player is not connected to the server ID 2");
GetPlayerPos(targetid, Float:X, Float:Y, Float:Z);
GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
GetPlayerName(targetid1, tname1, MAX_PLAYER_NAME);
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(string, sizeof(string), "Admin %s has teleported %s to %s", aname, tname, tname1);
SetPlayerPos(targetid1, Float:X+1,Float:Y+1,Float:Z);
SendClientMessageToAll(Yellow, string);
return 1;
}
Made it along time ago so there might be mistakes
Re: /sendto help? -
lorizz - 15.10.2012
Код:
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
Re: /sendto help? -
Shannkz - 15.10.2012
How can I get this to strcmp?
Re: /sendto help? -
lorizz - 15.10.2012
Код:
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;
}