Nah, die Funktion ist ganz schön veraltet
Und war glaube ich nicht mit allem kombatibel...
Es gibt Alternativen wie: http://forum.sa-mp.com/showthread.php?t=48439
Oder hier habe ich mal auch eine Funktion geschrieben:
C
stock d_JSON(const json[], const format[], {Float,_}:...)
{
const start=2;
new a=strfind(json,":"), b=strfind(json,","), tmp[64], index=start;
while(a != -1)
{
if(b==-1) b=strlen(json)-1;
switch(format[index-start])
{
case 'd','i': strmid(tmp,json,a+1,b,sizeof(tmp)),setarg(index,0,strval(tmp));
case 'f': strmid(tmp,json,a+2,b-1,sizeof(tmp)),setarg(index,0,_:floatstr(tmp));
case 's': {
strmid(tmp,json,a+1,b,sizeof(tmp));
for(new i,l=strlen(tmp),idx; i<l; i++)
{
if(tmp[i] == '"') continue;
setarg(index,idx++,tmp[i]);
}
}
}
index++;
a=strfind(json,":",false,a+1),b=strfind(json,",",false,b+1);
}
return 1;
}
//Funktioniert so:
new id,Name[MAX_PLAYER_NAME],Wohnort[32];
d_JSON(file_get_content("json.txt"),"dss",id,Name,Wohnort);
//in der json.txt steht zum Beispiel:
//{"id":5,"Name":"Hans","Wohnort":"Los Santos"}
printf("%d|%s|%s",id,Name,Wohnort);
//Output: 5|Hans|Los Santos
Alles anzeigen
Kannst dir was aussuchen ![]()
//edit: ..joa sry ...letzter edit xD