[Help] Teleporting issues.
#1

I need this command:

Код:
CMD:tp(playerid, params[])
{
    new targetid;
    new target[MAX_PLAYER_NAME];
    new Float:x, Float:y, Float:z;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /tp [id]");
    GetPlayerName(targetid, target, sizeof(target));
    GetPlayerPos(targetid, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
    new getvehicle = GetPlayerVehicleID(playerid);
    SetVehiclePos(getvehicle, x, y + 5, z);
    }
    else
    {
    SetPlayerPos(playerid, x, y, z);
    }
    SendClientMessage(targetid, COLOR_WHITE, "An admin teleported to you.");
    return 1;
}
to get the targets interior, and set the players interior.

So say someone is in burger shot.

I teleport to them using /tp. I should be put in that interior. How do I do this?
Reply
#2

Use the function SetPlayerInterior to change a player's interior. If you want the targetid to have the same interior as the person using the command, add the following to the command.

pawn Код:
SetPlayerInterior(targetid, GetPlayerInterior(playerid));
Reply
#3

Try it

pawn Код:
CMD:tp(const playerid, const params[])
{
    new targetid, target[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /tp [id]");
    if(u == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "your message here");
    GetPlayerName(targetid, target, sizeof(target)), GetPlayerPos(targetid, x, y, z);
    if(IsPlayerInAnyVehicle(playerid))
    {
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(targetid));
        SetPlayerInterior(playerid, GetPlayerInterior(targetid));
        new veh = GetPlayerVehicleID(playerid);
        LinkVehicleToInterior(veh, GetPlayerInterior(targetid));
        SetVehicleVirtualWorld(veh, GetPlayerVirtualWorld(targetid));
        SetVehiclePos(veh, x, y + 5, z + 1);
    }
    else SetPlayerPos(playerid, x, y, z + 1), SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(targetid)), SetPlayerInterior(playerid, GetPlayerInterior(targetid));
    SendClientMessage(targetid, COLOR_WHITE, "An admin teleported to you.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)