Vehicle ID bugging/problem
#1

I have this code for my player vehicle system:
pawn Код:
GameTextForPlayer(playerid, "~g~VEHICLE SPAWNED!", 1500, 4);
                        if(VehicleInfo[playerid][iVehicle][pv_Plate][0]) { VehicleInfo[playerid][iVehicle][pv_vID] = SetVehicleNumberPlate(CreateVehicle(VehicleInfo[playerid][iVehicle][pv_ModelID], VehicleInfo[playerid][iVehicle][pv_Pos][0], VehicleInfo[playerid][iVehicle][pv_Pos][1], VehicleInfo[playerid][iVehicle][pv_Pos][2], VehicleInfo[playerid][iVehicle][pv_Pos][3], VehicleInfo[playerid][iVehicle][pv_Colours][0], VehicleInfo[playerid][iVehicle][pv_Colours][1], -1), VehicleInfo[playerid][iVehicle][pv_Plate]); }
                            if(!VehicleInfo[playerid][iVehicle][pv_Plate][0]) { VehicleInfo[playerid][iVehicle][pv_vID] = SetVehicleNumberPlate(CreateVehicle(VehicleInfo[playerid][iVehicle][pv_ModelID], VehicleInfo[playerid][iVehicle][pv_Pos][0], VehicleInfo[playerid][iVehicle][pv_Pos][1], VehicleInfo[playerid][iVehicle][pv_Pos][2], VehicleInfo[playerid][iVehicle][pv_Pos][3], VehicleInfo[playerid][iVehicle][pv_Colours][0], VehicleInfo[playerid][iVehicle][pv_Colours][1], -1), "SFRP"); }
                            SetVehicleHealth(VehicleInfo[playerid][iVehicle][pv_vID], VehicleInfo[playerid][iVehicle][pv_Health]);
                            VehicleInfo[playerid][iVehicle][pv_Spawned] = 1;
                            printf("Vehicle ID %d", VehicleInfo[playerid][iVehicle][pv_vID]);
As you can see, I made it print the vehicle ID thats assigned to a vehicle when they spawn one.

I spawn two of my vehicles and it prints "Vehicle ID 1" and will do it if I spawn all of my vehicles, I don't know?

(And it can't be a problem with the vehicle they select since it spawns the right vehicle model, etc)

Thanks
Reply
#2

It would be a lot easier to read if you actually used your enum properly for instance.... VehicleInfo[playerid][iVehicle][pv_Pos][2] why do that? Why not set pv_Pos to pv_PosX, pvPosY, pvPosZ it is much more readable. Anyways lets see your enum and variable.
Reply
#3

That doesn't have any effect on the vehicle ID though, it's not like the players can see the scripts enums etc.
Reply
#4

Anyone at all?
Reply
#5

Bump!
Reply
#6

ok I'll take pity on ya:

it's a pretty obvious problem but ur using the return from the setplate as the vehicle id which is just backwards and completely wrong.

here:
pawn Код:
GameTextForPlayer(playerid, "~g~VEHICLE SPAWNED!", 1500, 4);
    VehicleInfo[playerid][iVehicle][pv_vID] = CreateVehicle(VehicleInfo[playerid][iVehicle][pv_ModelID], VehicleInfo[playerid][iVehicle][pv_Pos][0], VehicleInfo[playerid][iVehicle][pv_Pos][1], VehicleInfo[playerid][iVehicle][pv_Pos][2], VehicleInfo[playerid][iVehicle][pv_Pos][3], VehicleInfo[playerid][iVehicle][pv_Colours][0], VehicleInfo[playerid][iVehicle][pv_Colours][1], -1);
    if(VehicleInfo[playerid][iVehicle][pv_Plate][0]) {
        SetVehicleNumberPlate(VehicleInfo[playerid][iVehicle][pv_vID], VehicleInfo[playerid][iVehicle][pv_Plate]);
    }
    if(!VehicleInfo[playerid][iVehicle][pv_Plate][0]) {
        SetVehicleNumberPlate(VehicleInfo[playerid][iVehicle][pv_vID], "SFRP");
    }
    SetVehicleHealth(VehicleInfo[playerid][iVehicle][pv_vID], VehicleInfo[playerid][iVehicle][pv_Health]);
    VehicleInfo[playerid][iVehicle][pv_Spawned] = 1;
    printf("Vehicle ID %d", VehicleInfo[playerid][iVehicle][pv_vID]);
ur just tryng to do too much in a single line and getting confused along the way. break it down and make it more visible and you'll find that you'll see these issues much clearer! The compiler doesn't care is you save lines or make extra ones so why compress everything into a mess lol?
Reply
#7

Ah thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)