stock SaveInventory(playerid){gItemList=\"\";new filename[48];GetPlayerName(playerid,filename,24);format(filename,48,\"Inventory/%s.inv\",filename);new File:file=fopen(filename,io_write);for(new item;item<MAX_ITEMS;item++){if(!strlen(_GetItemNamePVar(playerid,item))||!_GetItemAmountPVar(playerid,item))continue;format(gItemList,sizeof(gItemList),\"%s%s\\n%d\\n\",gItemList,_GetItemNamePVar(playerid,item),_GetItemAmountPVar(playerid,item));}fwrite(file,gItemList);fclose(file);GetPlayerName(playerid,filename,24);printf(\"[iNV] %s[%d]\'s inventory saved.\",filename,playerid);}stock LoadInventory(playerid){new tstring[48];new tstring2[12];GetPlayerName(playerid,tstring,48);format(tstring,48,\"Inventory/%s.inv\",tstring);if(!fexist(tstring))return 0;new File:file=fopen(tstring,io_read);fread(file,tstring);while(tstring[0]){format(tstring,strlen(tstring),\"%s\",tstring); //Delete last characterfread(file,tstring2);AddItem(playerid,tstring,strval(tstring2));fread(file,tstring);}fclose(file);GetPlayerName(playerid,tstring,24);printf(\"[iNV] %s[%d]\'s inventory loaded.\",tstring,playerid);return 1;}
Miért nem használsz magyar nyelvût? Van itt a fórumon is...Egyébként a mentést + betöltést kell csak megoldani MySQL-el ha jól néztem. Szóval ezt a részt: stock SaveInventory(playerid){gItemList=\"\";new filename[48];GetPlayerName(playerid,filename,24);format(filename,48,\"Inventory/%s.inv\",filename);new File:file=fopen(filename,io_write);for(new item;item<MAX_ITEMS;item++){if(!strlen(_GetItemNamePVar(playerid,item))||!_GetItemAmountPVar(playerid,item))continue;format(gItemList,sizeof(gItemList),\"%s%s\\n%d\\n\",gItemList,_GetItemNamePVar(playerid,item),_GetItemAmountPVar(playerid,item));}fwrite(file,gItemList);fclose(file);GetPlayerName(playerid,filename,24);printf(\"[iNV] %s[%d]\'s inventory saved.\",filename,playerid);}stock LoadInventory(playerid){new tstring[48];new tstring2[12];GetPlayerName(playerid,tstring,48);format(tstring,48,\"Inventory/%s.inv\",tstring);if(!fexist(tstring))return 0;new File:file=fopen(tstring,io_read);fread(file,tstring);while(tstring[0]){format(tstring,strlen(tstring),\"%s\",tstring); //Delete last characterfread(file,tstring2);AddItem(playerid,tstring,strval(tstring2));fread(file,tstring);}fclose(file);GetPlayerName(playerid,tstring,24);printf(\"[iNV] %s[%d]\'s inventory loaded.\",tstring,playerid);return 1;} Lehet hogy megirom neked.
stock SaveItems(playerid){new query[128]; new num_rows,num_fields;cache_get_data(num_rows,num_fields,dbhandle); for(new i; i<MAX_ITEMS; i++){format(query,sizeof(query),\"UPDATE user SET pTargyak = \'%s\',pTargyMennyiseg = \'%d\' WHERE pName=\'%s\'\",ItemName[playerid],ItemAmount[playerid],GetName(playerid));mysql_function_query(dbhandle,query,false,\"\",\"\");}return 1;}stock LoadItems(playerid){ new num_fields,num_rows;cache_get_data(num_rows,num_fields,dbhandle);if(num_rows==1){ ResetPlayerItems(playerid); for(new i; i<MAX_ITEMS; i++){ cache_get_field_content(0, \"pTargyak\", ItemName[playerid],dbhandle,sizeof( ItemName[playerid] )); ItemAmount[playerid] = cache_get_field_content_int(0,\"pTargyMennyiseg\",dbhandle); mysql_function_query(dbhandle,query,false,\"\",\"\");}}else{format(query,sizeof(query),\"UPDATE user SET pTargyak = \'%s\',pTargyMennyiseg = \'%d\' WHERE pName=\'%s\'\",ItemName[playerid],ItemAmount[playerid],GetName(playerid));mysql_function_query(dbhandle,query,false,\"\",\"\");ResetPlayerItems(playerid);SaveItems(playerid);}return 1;}
cache_get_field_content(0, \"pTargyak\", ItemName[playerid],dbhandle,sizeof( ItemName[playerid] ));
stock SaveItems(playerid){new m[128]; format(itemfile,sizeof(itemfile),\"/Inv/%s.ini\",GetNamei(playerid)); for(new i; i<MAX_ITEMS; i++){ format(m,128,\"Item%d\",i); dini_Set(itemfile,m,ItemName[playerid]); format(m,128,\"Itemamount%d\",i); dini_IntSet(itemfile,m,ItemAmount[playerid]);}return 1;}stock LoadItems(playerid){new m[128]; format(itemfile,sizeof(itemfile),\"/Inv/%s.ini\",GetNamei(playerid)); if(dini_Exists(itemfile)) { ResetPlayerItems(playerid); for(new i; i<MAX_ITEMS; i++){ format(m,128,\"Item%d\",i); new item[128]; format(item,128,\"%s\",dini_Get(itemfile,m)); format(ItemName[playerid],128,\"%s\",item); format(m,128,\"Itemamount%d\",i); ItemAmount[playerid] = dini_Int(itemfile,m);}}else{dini_Create(itemfile);ResetPlayerItems(playerid);SaveItems(playerid);}return 1;}
Hát én igazából nem nagyon használtam még sampban mysqlt, mert a csatlakozásnál elakadtam már.. Egyébként mit ír az errorban?
invalid token ] but found ;
stock SaveItems(playerid){ new bool: elso = true, mennyiseg[256], targyak[256], query[512]; for(new x = 0; x < MAX_ITEMS; x++) { if(elso){ format(targyak, 512, \"%s\", ItemName[playerid]
stock split(const strsrc[], strdest[][], delimiter){new i, li;new aNum;new len;while(i <= strlen(strsrc)){ if(strsrc==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++;}i++;}return 1;}
format(mennyiseg, 512, \"%d\", ItemAmount[playerid]
if(elso) { format(mennyiseg, 512, \"%d\", ItemAmount[playerid]
error 029: invalid expression, assumed zero
stock SaveItems(playerid){ new bool: elso = true, mennyiseg[256], targyak[256], query[512]; for(new x = 0; x < MAX_ITEMS; x++) { if(elso) { format(targyak, 512, \"%s\", ItemName[playerid]