array must be indexed problem - 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: array must be indexed problem (
/showthread.php?tid=72483)
array must be indexed problem -
Danand - 08.04.2009
C:\Users\Daniel Andersen\Desktop\Annet\SAMP\SAMP Server\filterscripts\test.pwn(186) : error 033: array must be indexed (variable "-unknown-")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
=
Код:
new car;
new carid[256];
format(carid, 256, "%d", GetPlayerVehicleID(playerid));
new confirm[64];
if(sscanf(params, "s", confirm) == "confirm") -- 186 !!
{
if(car == 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "This car is not for sale!");
}
else if(car == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "You bought this car for $10000, check /vhelp for commands.");
dini_Create(carid);
dini_Set(carid, "name", file);
}
}
Re: array must be indexed problem -
Castle - 08.04.2009
On which line you get the Error?
Re: array must be indexed problem -
hanzen - 08.04.2009
if(sscanf(params, "s", confirm) == "confirm") -- 186 !!
Re: array must be indexed problem -
Danand - 08.04.2009
Hmm.. I cant get it work.. No errors now:
Quote:
dcmd_buycar(playerid, params[])
{
new car;
new carid[256];
format(carid, 256, "%d", GetPlayerVehicleID(playerid));
new confirm[64];
sscanf(params, "s", confirm);
if(strcmp(params, carid, true) == 0)
{
if(car == 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "This car is not for sale!");
}
else if(car == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "You bought this car for $10000, check /vhelp for commands.");
dini_Create(carid);
dini_Set(carid, "name", file);
}
}
else
{
if(GetVehicleModel(playerid) == 404)
{
SendClientMessage(playerid, COLOR_YELLOW, "This car costs $10000, type /buycar confirm to buy it.");
car = 1;
}
}
}
|
Re: array must be indexed problem -
Weirdosport - 08.04.2009
What is this supposed to do exactly?
pawn Код:
if(sscanf(params, "s", confirm) == "confirm")
Sscanf is used to save things to variables, and give out some text if the user inputs the wrong syntax... I can't make sense of why you'd want to compare it to confirm..
EDIT: I think what you're after is this sort of thing:
pawn Код:
if(sscanf(params, "s", confirm)) SendClientMessage(playerid, 0xFF00FFAA, "Usage: /command string");
That will save whatever the user types to "confirm" if it's a string. If the user failed to type anything, or gave an interger/Float, it will return the SendClientmessage.
Re: array must be indexed problem -
hanzen - 09.04.2009
I think he is suppose to make a script that you can by cars.
Re: array must be indexed problem -
13th - 09.04.2009
Код:
if(strcmp(params, carid, true) == 0)
should be
Код:
if(strcmp(confirm, carid, true) == 0)