SA-MP Forums Archive
dini to mysql - 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: dini to mysql (/showthread.php?tid=675712)



dini to mysql - Filbert - 19.05.2020

Is this correct?

PHP Code:
stock afixhs(playerid)
{
    new 
asname[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,asnamesizeof(asname));
    new 
str1[256],str[256];
    
format(strsizeof(str), "ladmin/users/%s.sav"udb_encode(asname));
    new 
housenumber dini_Int(str"hID");
    
format(str1sizeof(str1), "SATDM/houses/%d"housenumber);//"%d" is the house id
    
dini_Set(str1"Owner"asname);
    
HouseInfo[housenumber][Owner]=asname;
    
DestroyDynamicPickup(HousePickup[housenumber]);
    
HousePickup[housenumber] = CreateDynamicPickup(127323HouseInfo[housenumber][iconx], HouseInfo[housenumber][icony], HouseInfo[housenumber][iconz]);
    new 
hnowner[30];
    
format(hnowner,128,"%s",HouseInfo[housenumber][Owner]);
    if(
strcmp(HouseInfo[housenumber][Owner],DEFAULT_OWNER,false) == 0) {
        
format(hnowner,128,"Not Owned");
    }
    
UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0xFF0000FF,hnowner);
    
DestroyDynamicMapIcon(housemapicon[housenumber]);
    
housemapicon[housenumber] = CreateDynamicMapIcon(HouseInfo[housenumber][iconx], HouseInfo[housenumber][icony], HouseInfo[housenumber][iconz],32,c_y);

PHP Code:
stock afixhs(playerid)
{
    new 
asname[MAX_PLAYER_NAME], Query[250], Query1[250];
    
GetPlayerName(playerid,asnamesizeof(asname));
    
mysql_format(mysqlQuerysizeof Query"SELECT * FROM `accounts` WHERE `Name` = '%s'"asname);
    new 
rowsfieldshousenumber;
       
cache_get_data(rowsfieldsmysql);
    
housenumber cache_get_field_content_int(0"hID"mysql);//'hID' is the house id in 'accounts' table
    
mysql_format(mysqlQuery1sizeof Query1"UPDATE `houses` SET `Owner` = '%s' WHERE `ID` = '%d'"asnamehousenumber);//'%d' is the house id in 'houses' table
     
mysql_tquery(mysqlQuery1"""");
    
HouseInfo[housenumber][Owner]=asname;//<<<<<<<<<<<<<<<<<<Line 49010
    
DestroyDynamicPickup(HousePickup[housenumber]);
    
HousePickup[housenumber] = CreateDynamicPickup(127323HouseInfo[housenumber][HX], HouseInfo[housenumber][HY], HouseInfo[housenumber][HZ]);
    new 
hnowner[30];
    
format(hnowner,128,"%s",HouseInfo[housenumber][Owner]);
    if(
strcmp(HouseInfo[housenumber][Owner],DEFAULT_OWNER,false) == 0) {
        
format(hnowner,128,"Not Owned");
    }
    
UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0xFF0000FF,hnowner);
    
DestroyDynamicMapIcon(housemapicon[housenumber]);
    
housemapicon[housenumber] = CreateDynamicMapIcon(HouseInfo[housenumber][HX], HouseInfo[housenumber][HY], HouseInfo[housenumber][HZ],32,c_y);

I got this :

Code:
(49012) : error 047: array sizes do not match, or destination array is too small



Re: dini to mysql - GTLS - 19.05.2020

1> Inside mysql_tquery, mention a function name and use threaded query.
2> You can not copy strings like that. Use format or strcat.

EG:
Code:
 format(HouseInfo[housenumber][Owner], MAX_PLAYER_NAME, "%s", aname);
Or, strcat(HouseInfo[housenumber][Owner], aname, MAX_PLAYER_NAME);



Re: dini to mysql - Filbert - 20.05.2020

Quote:
Originally Posted by GTLS
View Post
1> Inside mysql_tquery, mention a function name and use threaded query.
2> You can not copy strings like that. Use format or strcat.

EG:
Code:
 format(HouseInfo[housenumber][Owner], MAX_PLAYER_NAME, "%s", aname);
Or, strcat(HouseInfo[housenumber][Owner], aname, MAX_PLAYER_NAME);
I dont get it. I can compiled the old gm with the same "HouseInfo[housenumber][Owner]=asname;".


Re: dini to mysql - Kwarde - 20.05.2020

Quote:
Originally Posted by GTLS
View Post
You can not copy strings like that. Use format or strcat.
Sidenote: It is possible but only with constant values, eg.

pawn Code:
new myArray[] = "Hello world!", otherArray[] = "Hello other world!";
otherArray = myArray;
//Now both arrays will print "Hello world!"