save data to string -
ic3cr3am - 22.03.2014
Код:
public Update(index, response_code, data[])
{
if(response_code == 200)
{
**save 'date' to string
}
}
^^ i got one small problem, i would like to know how to save 'data' to string.
Re: save data to string -
Konstantinos - 22.03.2014
It depends on what you want to do with it. If you want to store the data to a global variable (for everyone) then:
pawn Код:
// global:
new Update_data[128];
and to copy a string to another:
pawn Код:
strcpy(Update_data, data, 128);
and the macro:
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
However, if you wanted to save each data for a different player, then you'd need to use 1 more dimension for the playerid.
Re: save data to string -
ic3cr3am - 22.03.2014
Quote:
Originally Posted by Konstantinos
It depends on what you want to do with it. If you want to store the data to a global variable (for everyone) then:
pawn Код:
// global: new Update_data[128];
and to copy a string to another:
pawn Код:
strcpy(Update_data, data, 128);
and the macro:
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
However, if you wanted to save each data for a different player, then you'd need to use 1 more dimension for the playerid.
|
ok, thx, but i still get a error, can i send you code in PM? it's only 103 lines, please
Re: save data to string -
Konstantinos - 22.03.2014
Post the error code and line here instead.
Re: save data to string -
ic3cr3am - 22.03.2014
Код:
C:\Users\Ronaldo\Music\Bass\samp03z_svr_R1_win32\filterscripts\CreamyProtection.pwn(94) : error 033: array must be indexed (variable "Update_data")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: save data to string -
Konstantinos - 22.03.2014
The error itself says nothing. You need to post the line 94 as well as how you declared Update_data.
Re: save data to string -
ic3cr3am - 22.03.2014
iiii
Re: save data to string -
Konstantinos - 22.03.2014
I asked for the error code and line. Anyways, the line is:
pawn Код:
if(Update_data > CP_VERSION)
Update_data is string and it uses indexes. You try to compare it like an integer without an index too which is incorrect.
You can compare it like string (strcmp) and send a message that the version does not match the latest one which is the simpler way.
If you want to check if the greater version, then again it depends on the version. How is it supposed to be? So I can tell you how to compare it.
PS: You need to use format to pass the version in the string.
Re: save data to string -
ic3cr3am - 22.03.2014
the version is 1.0
You can compare it like string (strcmp) and send a message that the version does not match the latest one which is the simpler way.
^^ahh, ok, i'l do this, thx
Re: save data to string -
Konstantinos - 22.03.2014
Comparing the strings (equal or not equal):
pawn Код:
if (strcmp(Update_data, CP_VERSION))
{
// versions do not match
}
Assuming CP_VERSION is defined as:
and it returns a version as x.y (x and y are values between 0 and 9).