HELP - array must be indexed - 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 - array must be indexed (
/showthread.php?tid=588387)
HELP - array must be indexed -
Balcan Fox - 08.09.2015
Hello x)
Код:
new owner[24];
cache_get_field_content(i, "Owner",owner, mysql, 129);
if(owner == "Drzava")
{
}
compiler says:
Код:
.pwn(589) : error 033: array must be indexed (variable "owner")
line 589 is: if(owner == "Drzava")
Re: HELP - array must be indexed -
Sjn - 08.09.2015
The "owner" is a string so use strcmp to compare it with "Drzava".
Код:
if (strcmp(owner, "Drzava") == 0)
Also, your owner's array size is 24, why would you need to put 129 in cache_get_field_content?
Re: HELP - array must be indexed -
Balcan Fox - 08.09.2015
Works now, thank you.
I copied this 129 from log/reg system...it is used on password load, did not know what is it for but now I do ^^ ty
Re: HELP - array must be indexed -
Andre02 - 08.09.2015
EDIT: i'm too late
Re: HELP - array must be indexed -
Balcan Fox - 08.09.2015
BTW Can you please explain me why is it "== 0"? What would happen if we write "==1"?
@Andre02 Thank you as well :P
Re: HELP - array must be indexed -
Sjn - 08.09.2015
Quote:
Originally Posted by Balcan Fox
BTW Can you please explain me why is it "== 0"? What would happen if we write "==1"?
@Andre02 Thank you as well :P
|
https://sampwiki.blast.hk/wiki/Strcmp
Quote:
Return Values:
0 if strings match each other on given length;
1 o r -1 if some character do not match: string1[i] - string2[i] ('i' represents character index starting from 0);
difference in number of characters if one string matches only part of another string.
|