SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   dini to mysql (https://forum.sa-mp.com/showthread.php?t=675712)

Filbert 19/05/2020 10:16 AM

dini to mysql
 
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

GTLS 19/05/2020 01:17 PM

Re: dini to mysql
 
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);


Filbert 20/05/2020 01:10 PM

Re: dini to mysql
 
Quote:

Originally Posted by GTLS (Post 4146869)
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;".

Kwarde 20/05/2020 02:22 PM

Re: dini to mysql
 
Quote:

Originally Posted by GTLS (Post 4146869)
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!"


All times are GMT. The time now is 01:31 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.