array must be indexed(variable "-unknown") help
#3

Strings are arrays of symbols, read some theory @ SA-MP wiki.

Код:
CMD:port(playerid,params[])
{
		new lokejsn[8]; //Since lokejsn is a string, you define it as an array like that.
		if(sscanf(params,"s[8]",lokejsn)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /port [location]");
                //I have to admit, since you type location ID, if I were you, I had rather stick to integer, but it's up to you to decide that, so I'll patch it up your way.
                //You do need to define array size in sscanf line there; and you don't need to do !sscanf later, it's irrelative and is not required.
                if(!strcmp(lokejsn, "1", true)) { JBC_SetPlayerPos(playerid,1819.2871,-2066.6099,13.3828); }
                //DIY other location numbers like that
                ...
                ...
		if(!strcmp(lokejsn, "16", true)) { JBC_SetPlayerPos(playerid,1228.7247,-1565.4233,13.5741); }
		SendClientMessage(playerid,GRAY,"Teleported!");
		return 1;
}
Hope you get the idea. The variable you defined is an integer, not a string.

Код:
new lokejsn;
and you define strings as if you were defining an array...

Код:
new lokejsn[SIZE];
Reply


Messages In This Thread
array must be indexed(variable "-unknown") help - by DrAkE127 - 05.05.2018, 20:54
Re: array must be indexed(variable "-unknown") help - by Dayrion - 05.05.2018, 22:50
Re: array must be indexed(variable "-unknown") help - by Maxandmov - 06.05.2018, 09:49
Re: array must be indexed(variable "-unknown") help - by DrAkE127 - 06.05.2018, 11:51

Forum Jump:


Users browsing this thread: 1 Guest(s)