How to set a variable to string
#1

Hello.
Can someone how to set something to string not to a number.
Example:
Код:
label = params;
But the code above won't work because "params" is not a number, Can someone tell me what is the function to set label string params ?
Reply
#2

EDIT:
pawn Код:
strpack(label, params);
// You also can use also 'format' but in this case you don't need to format string and 'strpack' is much faster
Reply
#3

label = strval(params) ?
Reply
#4

Convert a string to an integer:
https://sampwiki.blast.hk/wiki/Strval

Convert an integer into a string:
https://sampwiki.blast.hk/wiki/Valstr
Reply
#5

pawn Код:
new string[24] = "up to 24 letters";
like this?

actually do you mean like this
pawn Код:
new label[24];
copy(label,params,sizeof(label));
Reply
#6

Do you mean like:

pawn Код:
new label[128];
format(label, sizeof(label), "%s", params);
Reply
#7

Quote:
Originally Posted by J4Rr3x
Посмотреть сообщение
EDIT:
pawn Код:
strpack(label, params);
// You also can use also 'format' but in this case you don't need to format string and 'strpack' is much faster
Are you confused with strcpy? Strpack, as its name suggests, packs the string to use less space. However, many functions do not work well, or even at all with packed strings so you'll need to unpack it first before using it.
Reply


Forum Jump:


Users browsing this thread: