SetVehiclePosition +1 of player location
#1

pawn Код:
#define COLOR_RED 0xF04747FF
CMD:getvehicle(playerid, params[])
{

    // Check if the player's admin-level is at least 1
    if (APlayerData[playerid][PlayerLevel] >= 1)
    {
        new vehicleid;
        if(sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /getvehicle [vehicleid]");
        if(GetVehicleModel(vehicleid) == 0 || vehicleid >= MAX_VEHICLES) return SendClientMessage(playerid, COLOR_RED, "That  vehicle does not exist.");       
        new Float:playerPos[3];
        GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
        GetXYInFrontOfPlayer(playerid, playerPos[0], playerPos[1], 5.0);
        SetVehiclePos(vehicleid, playerPos[0], playerPos[1], playerPos[2]);
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}

GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if(GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
I was lazy to create my own, so I found this out, but I can't configure where to add the +1, so the car spawns 1 feet up the ground or the same place with me. Can someone help me on this?

Thanks.
Reply
#2

SetVehiclePos(vehicleid, playerPos[0]+1, playerPos[1]+1, playerPos[2]);
Reply
#3

pawn Код:
SetVehiclePos(vehicleid, playerPos[0], playerPos[1], playerPos[2]+1);
//playerid, x, y, z  => z = height, we make z+1 => one feet higher from the ground
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)