strpack - problem - 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: strpack - problem (
/showthread.php?tid=551436)
strpack - problem -
NickHaudMTA - 18.12.2014
Hello!
As the title says, I have a problem with strpack.
The thing is, I'm making an event system using dialogs.
...
So, I made a dialog to set the name for an event (inputtext), and it works like this:
pawn Код:
strpack(eName, inputtext);
And this is the code that shows the event name in a dialog:
pawn Код:
format(A, sizeof(A), "Event name: %s", eName);
ShowPlayerDialog(playerid, DIALOG_EVENT_NAME, DIALOG_STYLE_MSGBOX, "Event name", A, "Cancel", "");
PROBLEM:
Whenever I show the dialog "DIALOG_EVENT_NAME", the string doesn't show me the correct (name that was actually wrote), it shows me every fourth letter that is in the name.
For an example:
123(4)567(8) > 48
hop(e)goo(d) > ed
hid(e) > e
etc...
I don't see a problem...
Re: strpack - problem -
Jefff - 19.12.2014
format doesn't support packed strings, you need use strunpack
https://sampwiki.blast.hk/wiki/Strunpack
Re: strpack - problem -
PowerPC603 - 19.12.2014
Why would you pack a string anyway?
Can someone explain the benefits of packing a string first and unpacking it afterwards, besides saving memory?
I know packed strings only consume 1 byte per character (8 bit), while unpacked strings consume 4 bytes per character (32 bit).
Perhaps you need packed strings for some DLL communication which only understands strings with 8-bit characters?
Other than that, I don't see a need to pack strings in a standard PAWN script.