Joining a few different integer values in a single string
#1

Is it possible to store, let's say four different values in a single string?

For example:
pawn Код:
new skin1 = 235;
new pskin2 = 192;
new pskin3 = 190;
new pskin4 = 20;
if I want all these values to merge in a single string, and give out a result like:
Код:
19219020
I saw a tutorial or something about this a while back, but can't find it. I want to use this so I don't have to create different string values for every house a player purchases, and also because so the player could buy how many he wishes.
Reply
#2

pawn Код:
format(string, sizeof(string), "%i%i%i%i", skin1, pskin2, pskin3, pskin4);
Should work.
Reply
#3

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
pawn Код:
format(string, sizeof(string), "%i%i%i%i, skin1, pskin2, pskin3, pskin4);
Should work.
It would if you closed your apostrophe
Reply
#4

Quote:
Originally Posted by BuuGhost
Посмотреть сообщение
It would if you closed your apostrophe
Fixed, thanks for pointing that out.
Reply
#5

And how am I going to load them separately again?

Quote:
Originally Posted by BuuGhost
Посмотреть сообщение
It would if you closed your apostrophe
Your signature has a unclosed apostrophe.
Reply
#6

You can't unless you separate the values in the string by a special character, and use either the split function or sscanf.
Reply
#7

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
You can't unless you separate the values in the string by a special character, and use either the split function or sscanf.
You mean a '-' or a ',' right? ok. But I was thinking, how many many digits can a single string aray hold? I mean I don't think I can avail players to buy houses on a large scale then.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)