/goto command -
Horatio - 16.05.2012
Hi all,
I need a pawn help...
Is possible script a pwn command that allows player teleport to another player with activated the goto-function only for the player wich use /goto?
Example:
- Player 2 type /goton Player1ID
- Player1 type /goto Player2
- Player1 teleported
- Player2 typed /gotoff Player1ID
- Player1 typed /goto Player2
- Player1 fail because he has the teleport function off
So, how can I activate goto for multiple IDs chosed by me?
Sorry for my bad english...
Re: /goto command -
MichaelProPlayer - 16.05.2012
Код:
if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
{
if(!strlen(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /goto [PlayerID]") &&
SendClientMessage(playerid, orange, "Function: Will Go to specified player");
new player1;
new string[128];
if(!IsNumeric(params))
player1 = ReturnPlayerID(params);
else player1 = strval(params);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid)
{
SendCommandToAdmins(playerid,"Goto");
new Float:x, Float:y, Float:z; GetPlayerPos(player1,x,y,z);
SetPlayerInterior(playerid,GetPlayerInterior(player1));
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(player1));
if(GetPlayerState(playerid) == 2)
{
SetVehiclePos(GetPlayerVehicleID(playerid),x+3,y,z);
LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(player1));
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(player1));
}
else SetPlayerPos(playerid,x+2,y,z);
format(string,sizeof(string),"|- You have Teleported to \"%s\" -|", pName(player1));
return SendClientMessage(playerid,BlueMsg,string);
}
Re: /goto command -
[KHK]Khalid - 16.05.2012
Here's a simple example (as far as I understood what you said):
Let's say you have your scripted /goto command which looks like:
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/goto", true) == 0)
{
new tragetplayer, tmp[128];
tmp = strtok(cmdtext, idx);
if(GetPVarInt(playerid, "NotAbleToGoto") == 1)
{
SendClientMessage(playerid, -1, "You are not allowed use this command!");
return 1;
}
else if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "Usage: /goto <id>");
return 1;
}
targetplayer = strval(tmp);
if(targetplayer == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, -1, "ERROR: Player is not connected!");
return 1;
}
else
{
new Float:x, Float:y, Float:z;
GetPlayerPos(targetplayer, x, y, z);
SetPlayerPos(playerid, x, y, z);
}
return 1;
}
Well, let's make a command which disable /goto for a certain player:
pawn Код:
if(strcmp(cmd, "/gotoff", true) == 0)
{
new targetplayer, tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, -1, "Usage: /gotoff <id>");
return 1;
}
targetplayer = strval(tmp);
if(targetplayer == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, -1, "ERROR: Player is not connected");
return 1;
}
else
{
SetPVarInt(playerid, "NotAbleToGoto", 1);
}
}
And if you'd like to make a command that enables /goto, you would simply do as I did with /gotoff. But change SetPVarInt(playerid, "NotAbleToGoto", 1); to SetPVarInt(playerid, "NotAbleToGoto", 0);