array must be indexed problem
#1

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);
		}
	}
Reply
#2

On which line you get the Error?
Reply
#3

if(sscanf(params, "s", confirm) == "confirm") -- 186 !!
Reply
#4

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;
}
}
}

Reply
#5

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.
Reply
#6

I think he is suppose to make a script that you can by cars.
Reply
#7

Код:
if(strcmp(params, carid, true) == 0)
should be
Код:
if(strcmp(confirm, carid, true) == 0)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)