[MySQL] Numberplate Not appearing in Dialog
#1

I fixed the problem of Loading vehicles, but now another appeared. The Numberplate is 'LOADED', it even sets to the Correct vehicle. But doesn't appear in a Dialog. Here's the related code.

The Command /mycars. (I showed the code for only the first vehicle.)
pawn Код:
if(OwnedVehicle[playerid][0][loaded])
{
format(string, sizeof(string), "%s (ID: %d) Plate: %s\n", GetVehicleName(OwnedVehicle[playerid][0][ID]), OwnedVehicle[playerid][0][vID], VehicleInfo[OwnedVehicle[playerid][0][ID]][vPlate]);
}
Here is the Loading.
pawn Код:
cache_get_field_content(i, "vPlate", temp), format(VehicleInfo[playerid][vPlate], 12, "%s", temp);
It loads the vehicle numberplates, sets them, respawns the vehicles. It works fine. But in this command, they aren't appearing in the Dialog.
Here is the Result:


You can see, for all the vehicles, the Plate is empty. It set them, so they load fine. Something wrong with the Command, probably. Any Help?
Reply
#2

You're using "playerid" here
pawn Код:
cache_get_field_content(i, "vPlate", temp), format(VehicleInfo[playerid][vPlate], 12, "%s", temp);
and when calling it you are using the (mysql?) id of the vehicle
pawn Код:
format(string, sizeof(string), "%s (ID: %d) Plate: %s\n", GetVehicleName(OwnedVehicle[playerid][0][ID]), OwnedVehicle[playerid][0][vID], VehicleInfo[OwnedVehicle[playerid][0][ID]][vPlate]);
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
You're using "playerid" here
pawn Код:
cache_get_field_content(i, "vPlate", temp), format(VehicleInfo[playerid][vPlate], 12, "%s", temp);
and when calling it you are using the (mysql?) id of the vehicle
pawn Код:
format(string, sizeof(string), "%s (ID: %d) Plate: %s\n", GetVehicleName(OwnedVehicle[playerid][0][ID]), OwnedVehicle[playerid][0][vID], VehicleInfo[OwnedVehicle[playerid][0][ID]][vPlate]);
I'm confused about the First Objection. All the other Variables load fine. The Color, the Position, the Model. Why not the Plate then?

And the Second objection, Well No, I'm not using the MySQL ID. Look at it again, orderwise.
%s = Vehicle Name Of Ownedvehicle[playerid][0][ID] (ID = The variable used to create vehicle. NOT MYSQL ID)
%d = Actual MySQL ID of the vehicle.
%s = The Number Plate of Ownedvehicle[playerid][0][ID] Same as above.
Reply
#4

UPDATE: There's a problem in Loading 'STRINGS'. I tried debugging it, using the Plate and Owner Name. It returned Blank. i.e 'This vehicle is owned by ." (Something is supposed to be before the full stop)
Reply
#5

a question, why doing this:
pawn Код:
cache_get_field_content(i, "vPlate", temp), format(VehicleInfo[playerid][vPlate], 12, "%s", temp);
while you can simply do this:
pawn Код:
cache_get_field_content(i, "vPlate", VehicleInfo[playerid[vPlate], mysql, 12);
and yea, Sascha noticed a something, you used in loading vehicle, for vehicleinfo enum "playerid", while you are using in the formatting line, a vehicle id.
Reply
#6

Well, I Fixed the error. Thanks Sascha, that worked.
But erm, another appeared. The vehicle numberplates roll back by one.
Let me explain
1st vehicle is supposed to have = MG 01
2nd vehicle -------------------- = UV 46
3rd Vehicle -------------------- = DE 3933

1st Vehicle has the plate of 2nd, 2nd has the plate of 3rd, 3rd has empty. So, do I need to do some sort of -1 here? Since MySQL starts with 0, eh?

pawn Код:
for(new i = 0; i < rows; i++)
        {
     cache_get_field_content(i, "vPlate", VehicleInfo[i][vPlate], handle, 12);
So, where do I -1, erm?
Reply
#7

try
pawn Код:
for(new i; i<rows;)
Reply
#8

@ Sawalha
That;
pawn Код:
for(new i; i<rows;)
Crashes the server. When I change it to this;

pawn Код:
for(new i; i < rows; i++)
It's fine. But then, the Plates Conflict with each other?
Reply
#9

This:
pawn Код:
for(new i; i < rows; i++)
Should be:
pawn Код:
for(new i = 0; i < rows; i++) The reason being in your array 0 is the first vehicle by default I believe I would be 1.
Reply
#10

Quote:
Originally Posted by Smally
Посмотреть сообщение
This:
pawn Код:
for(new i; i < rows; i++)
Should be:
pawn Код:
for(new i = 0; i < rows; i++) The reason being in your array 0 is the first vehicle by default I believe I would be 1.
So then. The plates roll back by one. i.e The first vehicle has the second vehicle's plate, second has third's, third has blank.
EDIT: Please refer to this thread, it's the same.
https://sampforum.blast.hk/showthread.php?tid=554867
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)