WHY IT NOT TP?
#1

pawn Код:
CMD:event1(playerid, params[]) // SPEED-RACER (rules who got first place win!!!)
{
    if(IsPlayerAdmin(playerid))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            SetVehiclePos(GetPlayerVehicleID(playerid), -1397.782470, -203.723114, 1051.346801);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), 93.569358);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid), 7);

            SetPlayerPos(playerid, -1397.782470, -203.723114, 1051.346801);
            SetPlayerFacingAngle(playerid, 93.569358);

            SetPlayerInterior(playerid, 7);
            SendClientMessage(playerid, COLOR_RED, "!!Teleported!!");
        }
    }
    else SendClientMessage(playerid,-1,"Only Rcon admins");
    return 1;
}
I MAKE IT FOR ADMIN ONLY BUT WHEN I USE IT NOT TP ME TO -1397.782470, -203.723114, 1051.346801

Question Why
Reply
#2

if it doesn't show you anything, then probably you're not in any vehicle. (as a driver or passenger)
Reply
#3

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
so i have to delete this? or add

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
if any one know can show me in pawn?
Reply
#4

no you don't, probably you were trying to use this command on foot before.

It tells the server that you must be in any vehicle in order to use this command.

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
This will check if the player is not only in a vehicle, but if he is the driver as well.
Reply
#5

Look at your code. Read what it is doing.
pawn Код:
CMD:event1(playerid, params[]) //When a player types "/event1"
{
    if(IsPlayerAdmin(playerid))
    {
        //Everything in here will only be executed if the player is an RCON admin
        if(IsPlayerInAnyVehicle(playerid))
        {
            //Everything in here will only be executed if the player is in a vehicle.
            SetVehiclePos(GetPlayerVehicleID(playerid), -1397.782470, -203.723114, 1051.346801);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), 93.569358);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid), 7);

            SetPlayerPos(playerid, -1397.782470, -203.723114, 1051.346801);
            SetPlayerFacingAngle(playerid, 93.569358);

            SetPlayerInterior(playerid, 7);
            SendClientMessage(playerid, COLOR_RED, "!!Teleported!!");
        }
        //If the player is not in a vehicle, everything here will be executed
        //There is nothing here though? Nothing will be called...
    }
    else SendClientMessage(playerid,-1,"Only Rcon admins");
    return 1;
}
The correct code:
pawn Код:
CMD:event1(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only RCON admins can use this command.");
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //Player is a driver
    {
        new vid = GetPlayerVehicleID(playerid);
        SetVehiclePos(vid, -1397.782470, -203.723114, 1051.346801);
        SetVehicleZAngle(vid, 93.569358);
        LinkVehicleToInterior(vid, 7);
    }
    else //Player is not a driver
    {
        SetPlayerPos(playerid, -1397.782470, -203.723114, 1051.346801);
        SetPlayerFacingAngle(playerid, 93.569358);
    }
    SetPlayerInterior(playerid, 7);
    SendClientMessage(playerid, COLOR_RED, "!!Teleported!!");
    return 1;
}
Reply
#6

thank you
Reply
#7

@Threshold
Your code will send only the vehicle to that position if he is a driver....

Below the LinkVehicleToInterior line add these two lines
pawn Код:
SetPlayerInterior(playerid,7);
PutPlayerInVehicle(playerid,vid);
Reply
#8

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
@Threshold
Your code will send only the vehicle to that position if he is a driver....

Below the LinkVehicleToInterior line add these two lines
pawn Код:
SetPlayerInterior(playerid,7);
PutPlayerInVehicle(playerid,vid);
Oh you're right about one thing, I didn't set the player's interior to 7 when he's in a vehicle. Although when you set a vehicle's position, it automatically takes the driver and its passengers with it, so there is no need to add PutPlayerInVehicle.

I made it that way so that passengers cannot teleport the driver with them if they decide to use /event1. I updated my original post so that the player's interior is set to 7 when they teleport.
Reply
#9

pawn Код:
CMD:event1(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only RCON admins can use this command.");
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //Player is a driver
    {
        new vid = GetPlayerVehicleID(playerid);
        SetVehiclePos(vid, -1397.782470, -203.723114, 1051.346801);
        SetVehicleZAngle(vid, 93.569358);
        LinkVehicleToInterior(vid, 7);
    }
    else //Player is not a driver
    {
        SetPlayerPos(playerid, -1397.782470, -203.723114, 1051.346801);
        SetPlayerFacingAngle(playerid, 93.569358);
    }
    SetPlayerInterior(playerid, 7);
    SendClientMessage(playerid, COLOR_RED, "!!Teleported!!");
    return 1;
}
i test code it work but when i tp normal accout to me his say his didnt see any map on it his say only his stand on the air.


Question: why normal player that tp to Interior by admin but normal user cant see any thing?
Reply
#10

I assume you're using some sort of /get command?
You are probably not setting the other player's interior.

pawn Код:
SetPlayerInterior(targetid, GetPlayerInterior(playerid));
'targetid' is the player you are teleporting, 'playerid' is the admin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)