Issue with parking tickets/dialog. -
Dokins - 21.04.2016
The issue with this command is that it works when I don't spawn an admin vehicle (create a new vehicle) but whenever I do, it prints these results:
pawn Код:
CMD:viewtickets(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new am, am2, string[128], totalamount;
if(!IsPlayerInRangeOfPoint(playerid, 3.0, 362.6061,172.3386,1008.3828))return SendClientMessage(playerid, COLOUR_GREY, "You must be at city hall to pay parking tickets.");
for(new x = 1; x < GetVehiclePoolSize()+1; x++)
{
if(VehOwner[x] == PlayerSQLID[playerid])
{
am++;
}
}
if(am == 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not own any vehicles.");
if(am > 0)
{
for(new y = 1; y < MAX_TICKETS; y++)
{
for(new v = 1; v < GetVehiclePoolSize()+1; v++)
{
if(VehicleSQLID[v] > 0)
{
if(PTVehSQLID[y] == VehicleSQLID[v])
{
am2++;
totalamount += PTAmount[y];
}
}
}
}
}
printf("am %d", am);
printf("Am2 %d", am2);
if(am2 == 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not have any outstanding parking tickets.");
format(string, sizeof(string), "Pay All Tickets: "COL_RED"$%s\n"COL_WHITE"Pay Individual Ticket", AddCommas(totalamount));
ShowPlayerDialog(playerid, DIALOG_PTICKETS, DIALOG_STYLE_LIST, "Parking Tickets", string, "Select","Exit");
return 1;
}
I think it's to do with getting the vehicle pool size, I do + 1 because it doesn't seem to display vehicles correctly or by the correct ID or anything
Re: Issue with parking tickets/dialog. -
Abagail - 21.04.2016
Show the rest of your code.
Re: Issue with parking tickets/dialog. -
Dokins - 21.04.2016
Which part?
Re: Issue with parking tickets/dialog. -
Abagail - 21.04.2016
Where you format the dialog.
Re: Issue with parking tickets/dialog. -
Dokins - 21.04.2016
It becomes 0 with the pay all parking tickets although it should return no outstanding tickets.
pawn Код:
if(dialogid == DIALOG_PTICKETS)
{
if(response == 0)
{
return 1;
}
else
{
new am, am2, name, string[600], ticket[128], totalamount;
switch(listitem)
{
case 0:
{
for(new x = 1; x < GetVehiclePoolSize()+1; x++)
{
if(VehOwner[x] == PlayerSQLID[playerid])
{
am++;
}
if(am > 0)
{
for(new y = 1; y < MAX_TICKETS; y++)
{
if(PTVehSQLID[y] == VehicleSQLID[x])
{
am2++;
name = GetVehicleModel(x) - 400;
format(ticket, sizeof(ticket), "Vehicle: %s | Plate: %s | Fine: $%s | Reason: %s\n", VehicleNames[name], VehPlate[x], AddCommas(PTAmount[y]), PTReason[y]);
strcat(string, ticket);
totalamount += PTAmount[y];
}
}
}
}
RepairCost[playerid] = totalamount;
format(ticket, sizeof(ticket), ""COL_WHITE"Total Amount Of Parking Tickets: "COL_RED"%s\n", AddCommas(am2));
strcat(string, ticket);
format(ticket, sizeof(ticket), ""COL_WHITE"Total Parking Ticket Amount: "COL_RED"$%s", AddCommas(totalamount));
strcat(string, ticket);
ShowPlayerDialog(playerid, DIALOG_ALLTICKET,DIALOG_STYLE_MSGBOX,"Parking Tickets", string,"Pay All","Cancel");
}
case 1:
{
for(new x = 1; x < GetVehiclePoolSize()+1; x++)
{
if(VehOwner[x] == PlayerSQLID[playerid])
{
am++;
}
if(am > 0)
{
for(new y = 1; y < MAX_TICKETS; y++)
{
if(PTVehSQLID[y] == VehicleSQLID[x])
{
am2++;
name = GetVehicleModel(x) - 400;
VehTicketList[playerid] = am2 - 1;
format(string, sizeof(string), "%sVehicle: %s | Plate: %s | Fine: $%s | Reason: %s\n", string, VehicleNames[name], VehPlate[x], AddCommas(PTAmount[y]), PTReason[y]);
}
}
}
}
ShowPlayerDialog(playerid, DIALOG_ONETICKET,DIALOG_STYLE_LIST,"Parking Tickets", string,"Info","Cancel");
}
}
}
}
Re: Issue with parking tickets/dialog. -
Abagail - 21.04.2016
Before looking too in depth, the code seems to be rather unorganized and loop heavy. If I was in your position, I'd consider rewriting the way the system works. If you'd rather not rewrite it let me know and I'll take another look at it.
Re: Issue with parking tickets/dialog. -
Dokins - 21.04.2016
There's nothing really wrong with nested loops. The issue doesn't arise here it
arises before it.
Also the forum messed up the indentation/format it's extremely annoying I hate messy code.