SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/05/2020, 10:16 AM   #1
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 251
Reputation: 1
Default 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
Filbert is offline   Reply With Quote
Old 19/05/2020, 01:17 PM   #2
GTLS
High-roller
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 1,072
Reputation: 119
Default 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);
__________________

I don't help for rep. I help cuz I was helped in the past.


Retired from SAMP Scene. Might open SAMP Forums once in a while.

Some treats for ya. Click em
Basic House System
Simple Speedo
Base Login/Register Script

GTLS is offline   Reply With Quote
Old 20/05/2020, 01:10 PM   #3
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 251
Reputation: 1
Default Re: dini to mysql

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;".
Filbert is offline   Reply With Quote
Old 20/05/2020, 02:22 PM   #4
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,735
Reputation: 1686
Default Re: dini to mysql

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!"
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dini in mysql Sn4ke2 Scripting Help 3 17/03/2016 09:07 PM
[MYSQL]Help Please(CAN SOMEBODY do this in dini please) AlbaniaMafiaRP Scripting Help 4 12/01/2016 05:57 PM
dini to mysql aboa Scripting Help 6 14/07/2014 06:05 PM
dINI vs MySql Nostrum Scripting Help 14 10/05/2013 10:54 PM
DINI to MYSQL TGameR Scripting Help 2 08/04/2013 09:13 PM


All times are GMT. The time now is 12:50 AM.


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