Doesn't update label
#1

Actually it doesn't even let me buy the house its like nothing happened.
I have created a command name /buyhouse which will spawn a dialog to set the name of the house
when i put the text it doesnt update the label and doesn't even buy the house?
I noticed at mysql_log that i have a syntax error but there is none.
PHP Code:
        case DIALOG_BUYHOUSE:
        {
            new 
hid GetHouseID(playerid);
            new 
query[200];
            if(!
response) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
            if(
strlen(inputtext) > 30) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
            
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
            
mysql_tquery(mysql,query);
            
inputtext[30] = HouseInfo[hid][HName];
            
BuyHouse(playerid);
        } 
So what i noticed is that it doesn't even call the BuyHouse function.. WHY? D:
PHP Code:
function BuyHouse(playerid)
{
    new 
query[400],label[150];
    new 
houseid GetHouseID(playerid);
    
HouseInfo[houseid][HOwned] = true;
    
mysql_format(mysql,query,sizeof(query), "UPDATE `houses` SET `HOwned` = 1",HouseInfo[houseid][HOwned]);
       
mysql_query(mysqlquery);
    
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HOwnerID`= (SELECT `ID` FROM `players` WHERE `Username` = '%s') WHERE `HID` = '%d'",Name[playerid],HouseInfo[houseid][hID]);
    
mysql_query(mysql,query);
    
format(label,sizeof(label),""COL_GREEN"HouseName"COL_WHITE":%s\n"COL_GREEN"",HouseInfo[houseid][HName]);
    
UpdateDynamic3DTextLabelText(HouseInfo[houseid][H3D],COLOR_YELLOW,label);
    return 
1;

pawn Code:
5:08:58] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE from `houses` SET `HName` = 'blah' WHERE `hID` = 0", callback: "(null)", format: "(null)"
[15:08:58] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[15:08:58] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'from `houses` SET `HName` = 'blah' WHERE `hID` = 0' at line 1
[15:08:58] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[15:08:58] [DEBUG] Calling callback "OnQueryError"..
Mysql_log

EDIT : SO I FIXED ONE - TWO THINGS I FOUND BY MY OWN BUT NOT I NOTICE THAT IT UPDATES THE LABEL BUT SETS HOUSENAME AS BLANK!
Reply
#2

Can you show me GetHouseID?
Reply
#3

PHP Code:
stock GetHouseID(playerid)
{
    for(new 
i=0i<MAX_HOUSESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid1HouseInfo[i][XExit], HouseInfo[i][YExit], HouseInfo[i][ZExit]))
        {
            return 
i;
        }
        else if(
IsPlayerInRangeOfPoint(playerid1HouseInfo[i][XEnt], HouseInfo[i][YEnt], HouseInfo[i][ZEnt]))
        {
            return 
i;
        }
    }
    return 
INVALID_HOUSE_ID;

Reply
#4

PHP Code:
inputtext[30] = HouseInfo[hid][HName]; 
Sets the 30th inputtext value as 0.

If you want to set HName to inputtext value, you need to use
PHP Code:
format(HouseInfo[hid][HName],sizeof(HouseInfo[hid][HName]),"%s",inputtext); 
Reply
#5

Or

Code:
strcat((HouseInfo[hid][HName][0] = EOS, HouseInfo[hid][HName]), inputtext, /*length goes here*/);
Reply
#6

Quote:
Originally Posted by ]Rafaellos[
View Post
Or

Code:
strcat((HouseInfo[hid][HName][0] = EOS, HouseInfo[hid][HName]), inputtext, /*length goes here*/);
what EOS does?
So this?
PHP Code:
        case DIALOG_BUYHOUSE:
        {
            new 
hid GetHouseID(playerid);
            new 
query[200];
            if(!
response) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
            if(
strlen(inputtext) > 30) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
            
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
            
mysql_tquery(mysql,query,"BuyHouse","i",playerid);
            
format(HouseInfo[hid][HName],sizeof(HouseInfo[hid][HName]),"%s",inputtext);  
        }
    }
    return 
1;

How i could use the format in this case
Reply
#7

Yes that's how I meant it, did you test it?
What this format does is basically HName = inputtext now.
EOS stands for End-Of-String, but I dont understand why he used that in his context, maybe he can explain it himself.
Reply
#8

Quote:
Originally Posted by CmZxC
View Post
Yes that's how I meant it, did you test it?
What this format does is basically HName = inputtext now.
EOS stands for End-Of-String, but I dont understand why he used that in his context, maybe he can explain it himself.
pawn Code:
mysql.pwn(7468) : error 001: expected token: "]", but found "-identifier-"
mysql.pwn(7468) : warning 215: expression has no effect
mysql.pwn(7468) : error 001: expected token: ";", but found "]"
mysql.pwn(7468) : error 029: invalid expression, assumed zero
mysql.pwn(7468) : fatal error 107: too many error messages on one line
Shows me 4 errors at the line with the formatted inputtext D: its as i show you before
PHP Code:
        case DIALOG_BUYHOUSE:
        {
            new 
hid GetHouseID(playerid);
            new 
query[200];
            if(!
response) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
            if(
strlen(inputtext) > 30) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
            
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
            
mysql_tquery(mysql,query,"BuyHouse","i",playerid);
        ---> 
error    format(HouseInfo[hid][HName],sizeof(HouseInfo[hid][HName]),"%s",inputtext);  
        } 
Reply
#9

Seems to be a problem with sizeof(HouseInfo[hid][HName]). Replace it with 30, since you deny inputs longer than 30 characters anyway.
Reply
#10

Quote:
Originally Posted by CmZxC
View Post
Seems to be a problem with sizeof(HouseInfo[hid][HName]). Replace it with 30, since you deny inputs longer than 30 characters anyway.
PHP Code:
        case DIALOG_BUYHOUSE:
        {
            new 
hid GetHouseID(playerid);
            new 
query[200];
            if(!
response) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE": You decided not to buy a house. The house sale got cancelled!");
            if(
strlen(inputtext) > 30) return SendClientMessage(playerid, -1""COL_RED"SERVER"COL_WHITE"You must set a name less than 30 characters!");
            
mysql_format(mysql,query,sizeof(query),"UPDATE `houses` SET `HName` = '%s' WHERE `hID` = %d",inputtext,HouseInfo[hid][hID]);
            
mysql_tquery(mysql,query,"BuyHouse","i",playerid);
            
format(HouseInfo[hid][HName],30,"%s",inputtext);  
        } 
It compiles but it doesn't even update the txt label
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)