06.10.2010, 16:18
how can I create a command that teleports a player to me ? I can't start it.
if(strcmp(cmd, "/gethere", true) == 0) {
if(PlayerInfo[playerid][Level] >= 3) {
new player1, tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, red, "USAGE: /gethere [playerid]");
return 1; }
player1 = strval(tmp);
if(IsPlayerConnected(player1)) {
CMDMessageToAdmins(playerid,"GETHERE");
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z); SetPlayerInterior(player1,GetPlayerInterior(playerid));
SetPlayerVirtualWorld(player1,GetPlayerVirtualWorld(playerid));
if(GetPlayerState(player1) == 2) {
new VehicleID = GetPlayerVehicleID(player1);
SetVehiclePos(VehicleID,x+3,y,z); LinkVehicleToInterior(VehicleID,GetPlayerInterior(playerid));
SetVehicleVirtualWorld(GetPlayerVehicleID(player1),GetPlayerVirtualWorld(playerid));
} else {
SetPlayerPos(player1,x+2,y,z); }
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,256,"You have been teleported to Administrator %s's location",adminname); SendClientMessage(player1,blue,string);
format(string,256,"You have teleported %s to your location", playername); SendClientMessage(playerid,blue,string);
return 1;
} else {
SendClientMessage(playerid, red, "Player is not connected");
return 1; }
} else {
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command"); }
return 1; }
if(strcmp(cmd, "/gethere", true) == 0)
{
new player1, tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, red, "USAGE: /gethere [playerid]");
return 1;
}
player1 = strval(tmp);
if(IsPlayerConnected(player1))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerInterior(player1,GetPlayerInterior(playerid));
SetPlayerVirtualWorld(player1,GetPlayerVirtualWorld(playerid));
if(GetPlayerState(player1) == 2)
{
new VehicleID = GetPlayerVehicleID(player1);
SetVehiclePos(VehicleID,x+3,y,z); LinkVehicleToInterior(VehicleID,GetPlayerInterior(playerid));
SetVehicleVirtualWorld(GetPlayerVehicleID(player1),GetPlayerVirtualWorld(playerid));
}
else
{
SetPlayerPos(player1,x+2,y,z);
}
return 1;
}
else
{
SendClientMessage(playerid, red, "Player is not connected");
return 1;
}
return 1;
}
Try that out, if it works it will work in every player, just add the admins checker line yourself if u want
DON'T BE LAZY! pawn Код:
|
if(!strcmp(cmdtext, "/get", true))
{
if(strlen(cmdtext[4]))
return SendClientMessage(playerid, 0xFFFFFFF, ">> /get <id>");
if(!IsPlayerConnected(strval(cmdtext[4]))
return SendClientMessage(playerid, 0xFFFFFFF, "The playerid is non-existant.");
new
Float:PlayerPos[3]
;
GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
SetPlayerPos(strval(cmdtext[4]), PlayerPos[0], PlayerPos[1], PlayerPos[2]+3);
SetPlayerInterior(strval(cmdtext[4]), GetPlayerInterior(playerid));
SetPlayerVirtualWorld(strval(cmdtext[4]), GetPlayerVirtualWorld(playerid));
}
if( !strcmp( cmdtext, "/get", true ))
{
new iPlayer;
if( cmdtext[ 4 ] == '\0' || ( cmdtext[ 4 ] == '\1' && cmdtext[ 5 ] == '\0' ))
return SendClientMessage(playerid, 0xFFFFFFF, ">> /get <id>");
iPlayer = strval( cmdtext[ 5 ] );
if( !IsPlayerConnected( iPlayer ))
return SendClientMessage(playerid, 0xFFFFFFF, "The playerid is non-existant.");
new
Float:fX,
Float:fY,
Float:fZ;
new
iInt = GetPlayerInterior( playerid ),
iVehicle = GetPlayerVehicleID( iPlayer );
GetPlayerPos( playerid, fX, fY, fZ );
if( iVehicle )
{
SetVehiclePos( iVehicle, fX + 1.0, fY, fZ + 0.5 );
LinkVehicleToInterior( iVehicle, iInt );
}
else
{
SetPlayerPos( iPlayer, fX, fY, fZ + 0.5 );
SetPlayerInterior( iPlayer, iInt );
}
SetPlayerVirtualWorld( iPlayer, GetPlayerVirtualWorld( playerid ));
return true;
}
Try that out, if it works it will work in every player, just add the admins checker line yourself if u want
DON'T BE LAZY! pawn Код:
|
local variable "tmp" shadows a variable at a preceding level