HELP - array must be indexed
#1

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

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?
Reply
#3

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
Reply
#4

EDIT: i'm too late
Reply
#5

BTW Can you please explain me why is it "== 0"? What would happen if we write "==1"?
@Andre02 Thank you as well :P
Reply
#6

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.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)