Problems with AttachTrailerToVehicle
#1

Hi

Iґve a big Problem with my /attach command. Sometimes i can Attach Cars, and sometimes not. I have tried everything, but i couldnt fix it.

Here my Command:

pawn Код:
if(strcmp(cmd, "/attach", true) == 0)
    {
        if(Meschaniker[playerid] == 1)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
                {
                    DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                    AttachTrailerToVehicle(GetNearestCar(playerid, 7), GetPlayerVehicleID(playerid));
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "Du musst in einen Schlepper!");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "Du musst zuerst in ein Auto!");
            }
            return 1;
        }
.
.
.
MFG, Robdeflop®

Sry for my bad English (Iґm German)
Reply
#2

Hi

Sometimes i can attach cars, and sometimes not, but i dont know why oO
I guess the code is correct. Often i can everytime attach Towtrucks, but no other cars.

MFG, Robdeflop®
Reply
#3

could be that GetNearestCar(playerid, 7) returns wrong vehicleid or vehicle is not streamed in
Reply
#4

HI

I guess not, because there never was a problem before.

pawn Код:
public GetNearestCar(playerid, Float:distance)
{
    new Float:pX, Float:pY, Float:pZ, Float:vX, Float:vZ, Float:vY;
    GetPlayerPos(playerid, pX, pY, pZ);
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        GetVehiclePos(i, vX, vY, vZ);
        if((floatabs(pX-vX)<distance)&&(floatabs(pY-vY)<distance)&&(floatabs(pZ-vZ)<distance)&&(i != GetPlayerVehicleID(i)))
        {
            if(i == 0)
            {
                return 9999;
            }
            return i;
        }
    }
    return 9999;
}
Thereґs nothing wrong or?

MFG, Robdeflop®
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)