help dialog - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help dialog (
/showthread.php?tid=578395)
help dialog -
Edw - 19.06.2015
not show that dialog, you can tell me why?
PHP код:
case 0:
{
new
dstr[2000],
car = PlayerInfo[playerid][pPcarkey];
new nrm[66];
if(CarInfo[car][cLicense] == 0) format(nrm,sizeof(nrm),"{FFFFFF}Nu");
else format(nrm,sizeof(nrm),"{FFFFFF}%s", CarInfo[car][cLicense]);
new text[60];
if(CarInfo[car][cLock] == 0) format(text,sizeof(text),"{00FF00}Deschisa");
else format(text,sizeof(text),"{FF0000}Incuiata");
new id[40];
format(id, sizeof(id),"%s (ID: %d)",VehicleNames[GetVehicleModel(car)],car);
format(dstr, sizeof(dstr), "Model Vehicul: %s\nCuloarea 1: %d\nCuloarea 2: %d\nNumar de inmatriculare: %s\nKilometrii: %d\nUsa: %s",
VehicleNames[GetVehicleModel(car)], CarInfo[car][cColorOne], CarInfo[car][cColorTwo], nrm, CarInfo[car][cKM], text);
ShowPlayerDialog(playerid,178,DIALOG_STYLE_MSGBOX,id,dstr,"Iesire","");
}
Re: help dialog -
Konstantinos - 19.06.2015
Run time error 4:
pawn Код:
VehicleNames[GetVehicleModel(car)]
The size of VehicleNames array is 212 so 0-211 are the valid indexes. If you get the model ID and it's a valid vehicle, it will try to access the element with index of greater or equal to 400 which is out of bounds.
Store the modelid to a variable and if it's between the valid model IDs, use it in the array:
pawn Код:
new modelid = GetVehicleModel(car);
...
// in the format as argument:
..., modelid ? VehicleNames[modelid - 400] : ("N/A"), car);
do the same for the second format as well.