Users modify
#1

Hello guys i created the cmd asellhouse,it works.The single think that is not working: it doesnt set the old owner key to -1 [no house],the old owner stays with the key of the house..i tried to do it you can see between /* */ but did not work.

PHP код:
YCMD:asellhouse(playeridparams[], help)
{
    if(
PlayerData[playerid][Admin] < 6) return SendClientMessage(playeridCOLOR_WHITEAdminOnly);
    new 
str[128],house;
    if(
sscanf(params"i"house)) return SendUsage(playerid,"/asellhouse <house id>");
    {
    
        
//HouseInfo[house][hLocked] = 1;
        
HouseInfo[house][hOwned] = 0;
        
HouseInfo[house][hLock] = 0;
        
strmid(HouseInfo[house][hOwner], "The State"0strlen("The State"), 255);
        
PlayerPlaySound(playerid10520.00.00.0);
        
format(strsizeof(str), "~w~You have sold the House");
        
GameTextForPlayer(playeridstr100003);
        new 
Query[128];
    
/*    mysql_format(SQL, Query, 256,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s'",HouseInfo[house][hOwner]);
        mysql_tquery(SQL, Query, "", ""); */
        
mysql_format(SQLQuery128,"UPDATE houses SET `Owned`='0', `Lockk`='0', `Owner` ='The State' WHERE `ID`='%d'",HouseInfo[house][hID]);
        
mysql_tquery(SQLQuery"""");
    
/*    mysql_format(SQL, Query, 128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",HouseInfo[house][hOwner]);
        mysql_tquery(SQL, Query, "", ""); */
    
        
OnPropTextdrawUpdate(1house);
    } 
// UPDATE houses SET `Owner` = '%s' WHERE ID = %d
    
return 1;

thanks in advance
Reply
#2

Owner has been set to nothing before updating Housekey
PHP код:
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playeridnamesizeof(name));
mysql_format(SQLQuery128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",name); 
OR

PHP код:
YCMD:asellhouse(playeridparams[], help

    if(
PlayerData[playerid][Admin] < 6) return SendClientMessage(playeridCOLOR_WHITEAdminOnly); 
    new 
str[128],house
    if(
sscanf(params"i"house)) return SendUsage(playerid,"/asellhouse <house id>"); 
    { 
     
        
//HouseInfo[house][hLocked] = 1; 
        
HouseInfo[house][hOwned] = 0
        
HouseInfo[house][hLock] = 0
        
strmid(HouseInfo[house][hOwner], "The State"0strlen("The State"), 255); 
        
PlayerPlaySound(playerid10520.00.00.0); 
        
format(strsizeof(str), "~w~You have sold the House"); 
        
GameTextForPlayer(playeridstr100003); 
        new 
Query[128]; 
    
/*    mysql_format(SQL, Query, 128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",HouseInfo[house][hOwner]); 
        
    /*    mysql_format(SQL, Query, 256,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s'",HouseInfo[house][hOwner]); 
        mysql_tquery(SQL, Query, "", ""); */ 
        
mysql_format(SQLQuery128,"UPDATE houses SET `Owned`='0', `Lockk`='0', `Owner` ='The State' WHERE `ID`='%d'",HouseInfo[house][hID]); 
        
mysql_tquery(SQLQuery""""); 
        
mysql_tquery(SQLQuery""""); */ 
     
        
OnPropTextdrawUpdate(1house); 
    } 
// UPDATE houses SET `Owner` = '%s' WHERE ID = %d 
    
return 1

Reply
#3

Quote:

mysql_format(SQL, Query, 128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",HouseInfo[house][hOwner]);
mysql_tquery(SQL, Query, "", ""); */

why is this not working?
It`s set when you buy the house.
Reply
#4

Did you set the query to run before setting the house owner variable to "The State"?
Reply
#5

@Luis- ,i verified and tried this :
PHP код:
YCMD:asellhouse(playeridparams[], help)
{
    if(
PlayerData[playerid][Admin] < 6) return SendClientMessage(playeridCOLOR_WHITEAdminOnly);
    new 
str[128],house;
    if(
sscanf(params"i"house)) return SendUsage(playerid,"/asellhouse <house id>");
    {
        new 
Query[256];
        
mysql_format(SQLQuery256,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s'",HouseInfo[house][hOwner]);
        
mysql_tquery(SQLQuery"""");
        
//HouseInfo[house][hLocked] = 1;
        
HouseInfo[house][hOwned] = 0;
        
HouseInfo[house][hLock] = 0;
        
strmid(HouseInfo[house][hOwner], "The State"0strlen("The State"), 255);
        
PlayerPlaySound(playerid10520.00.00.0);
        
format(strsizeof(str), "~w~You have sold the House");
        
GameTextForPlayer(playeridstr100003);
    
//    new Query[128];
    /*    mysql_format(SQL, Query, 256,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s'",HouseInfo[house][hOwner]);
        mysql_tquery(SQL, Query, "", ""); */
        
mysql_format(SQLQuery256,"UPDATE houses SET `Owned`='0', `Lockk`='0', `Owner` ='The State' WHERE `ID`='%d'",HouseInfo[house][hID]);
        
mysql_tquery(SQLQuery"""");
    
/*    mysql_format(SQL, Query, 128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",HouseInfo[house][hOwner]);
        mysql_tquery(SQL, Query, "", ""); */
    
        
OnPropTextdrawUpdate(1house);
    } 
// UPDATE houses SET `Owner` = '%s' WHERE ID = %d
    
return 1;

But still not updating house key to -1.
Reply
#6

up ? I-VE SET The query to run before setting the owner to the state..still not working
Reply
#7

Check MySQL logs for any error and print the query after formatting it to see if there was any mistake while making the query, like this :
PHP код:
printf("Quey: %s"Query); 
And also I see that you are using mysql_format so use %e instead of %s to prevent MySQL injections.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)