Few errors. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Few errors. (
/showthread.php?tid=229500)
Few errors. -
Marricio - 21.02.2011
Yo, i got two errors.
pawn Код:
C:\Archivos de programa\Rockstar Games\GTA San Andreas\SA-MP 0.3c\Marricio Scripting\filterscripts\plate.pwn(111) : error 033: array must be indexed (variable "GetVehicleNumberPlate")
C:\Archivos de programa\Rockstar Games\GTA San Andreas\SA-MP 0.3c\Marricio Scripting\filterscripts\plate.pwn(133) : error 079: inconsistent return types (array & non-array)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
Code:
pawn Код:
stock GetVehicleNumberPlate(vehicleid) // By Jochemd
{
if(vehicleid != INVALID_VEHICLE_ID) return vPlate[vehicleid];
return 0; // error 2 here
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == D_TRACK)
{
for(new v; v<MAX_VEHICLES; v++)
{
if(GetVehicleNumberPlate(v) == strlen(inputtext)) // Error 1 here.
{
return 1;
}
}
}
return 1;
}
Re: Few errors. -
JaTochNietDan - 21.02.2011
You're comparing a string with the length of the inputtext variable, I'm not sure what you're trying to achieve there. Are you trying to compare the inputtext with number plate? If so you cannot compare strings directly in Pawn, you need to use strcmp, for example:
pawn Код:
if(strcmp(GetVehicleNumberPlate(v), inputtext, true) == 0) // They are the same
Also the second error means that you're using inconsistent return types, it means that at one point you are returning a string, and then you are returning an integer, you cannot do that, although I don't know why you even need that function, just do this:
pawn Код:
if(strcmp(vPlate[vehicleid], inputtext, true) == 0) // They are the same
It makes a lot more sense!
Re: Few errors. -
Marricio - 21.02.2011
Quote:
Originally Posted by JaTochNietDan
You're comparing a string with the length of the inputtext variable, I'm not sure what you're trying to achieve there. Are you trying to compare the inputtext with number plate? If so you cannot compare strings directly in Pawn, you need to use strcmp, for example:
pawn Код:
if(strcmp(GetVehicleNumberPlate(v), inputtext, true) == 0) // They are the same
Also the second error means that you're using inconsistent return types, it means that at one point you are returning a string, and then you are returning an integer, you cannot do that, although I don't know why you even need that function, just do this:
pawn Код:
if(strcmp(vPlate[vehicleid], inputtext, true) == 0) // They are the same
It makes a lot more sense!
|
Oh well.. I understand now. Thank you! You're the best!