From one string to several integers
#1

Hello there

I'm making a tiki system (like horse shoes) where a player has to find 25 tikis that are hidden in the server.
One of the most important things about this is that even when a player has disconnected their tikis (the ones they've already found) remain 'found'.
I did this by making a 25 character string, where each character (either 0 or 1) represents each tiki.
So if a player has found tiki id 1, 2, 7 and 25 this is the string:
Код:
1100001000000000000000001
I then save this string in a database (so I do not have to make a new cel for every single tiki)
Now the saving works, when a player disconnects the string is properly saved, and when a player connects the string is properly loaded.
However I have some trouble turning the string (which now consists of characters 0 and 1) into integer values for each tiki

So this:
pawn Код:
1100001000000000000000001
Should become this:
pawn Код:
PInfo[playerid][FoundTiki][0] = 1; //Where 0 stands for the tiki id
PInfo[playerid][FoundTiki][1] = 1; //Where 1 stands for the tiki id
PInfo[playerid][FoundTiki][2] = 0; //Where 2 stands for the tiki id
I tried doing this with the following code:
pawn Код:
for(new ti; ti < sizeof TIInfo; ti ++) //TIInfo is an array that contains information for all tikis, so its size equals the total amount of tikis in the server
                {
                    PInfo[playerid][FoundTiki][ti] = strval(PInfo[playerid][TikiString][ti]); //convert each char into an int
                }
So what I try to do here is I start a loop goin from 0 to 25 and I then store the value of the string for a specific tikiid into the corresponding tiki.
But this does not seem to work :/

Does anyone know how I can make this work properly?
Any help is well appreciated
Thanks in advance
Reply


Messages In This Thread
From one string to several integers - by knackworst - 28.10.2014, 20:10
Re: From one string to several integers - by fordawinzz - 28.10.2014, 20:16
Re: From one string to several integers - by knackworst - 28.10.2014, 20:17
Re: From one string to several integers - by RedFusion - 28.10.2014, 20:22
Re: From one string to several integers - by fordawinzz - 28.10.2014, 20:30
AW: From one string to several integers - by Nero_3D - 28.10.2014, 20:31
Re: AW: From one string to several integers - by knackworst - 28.10.2014, 20:39
AW: Re: AW: From one string to several integers - by Nero_3D - 28.10.2014, 21:16

Forum Jump:


Users browsing this thread: 2 Guest(s)