String trouble
#1

playeritem0 should return string but after use %s is something like ' e []'
what is wrong
Код:
new items[] =
{
	"Phone",
	"Glock"
};
Код:
playeritem0[playerid] = items[1];
Reply
#2

Change:
Код:
new items[] =
To:
Код:
new items[][] =
Reply
#3

now is ' G [] '.
Reply
#4

pawn Код:
new items[][] =
{
    "Phone",
    "Glock"
};

new playeritem0[MAX_PLAYERS][24];
pawn Код:
playeritem0[playerid] = items[1];
Reply
#5

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
playeritem0 should return string but after use %s is something like ' e []'
what is wrong
Код:
new items[] =
{
	"Phone",
	"Glock"
};
Код:
playeritem0[playerid] = items[1];
An array of strings means using [][]
Reply
#6

Код:
error 047: array sizes do not match, or destination array is too small
error 033: array must be indexed (variable "playeritem0")
Код:
playeritem0[playerid] = items[1]; //here first

//in test cmd
if(playeritem0[playerid] == items[1]) //and here second
Код:
new items[][] =
{
    "Phone",
    "Glock"
};

new playeritem0[MAX_PLAYERS][24];
Reply
#7

Change:
Код:
playeritem0[playerid] = items[1];
To:
Код:
format(playeritem0[playerid],sizeof(playeritem0),items[1][0]);
Reply
#8

For strings you have to use strcmp to compare. You can give those items IDs and then get their names through the ID.
Reply
#9

First issue the array sizes are not the same you will need to use strcat() to copy the string.
Second issue as mentioned use strcmp() to compare strings.

Note: Before copying make sure the string you are copying to is cleared. MyString[0] = '\0';
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)