dini to mysql
#1

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
Reply
#2

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);
Reply
#3

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;".
Reply
#4

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!"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)