SA-MP Forums Archive
Users modify - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Users modify (/showthread.php?tid=583585)



Users modify - PepsiCola23 - 29.07.2015

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(playerid, params[], help)
{
    if(
PlayerData[playerid][Admin] < 6) return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
    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", 0, strlen("The State"), 255);
        
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        
format(str, sizeof(str), "~w~You have sold the House");
        
GameTextForPlayer(playerid, str, 10000, 3);
        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(SQL, Query, 128,"UPDATE houses SET `Owned`='0', `Lockk`='0', `Owner` ='The State' WHERE `ID`='%d'",HouseInfo[house][hID]);
        
mysql_tquery(SQL, Query, "", "");
    
/*    mysql_format(SQL, Query, 128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",HouseInfo[house][hOwner]);
        mysql_tquery(SQL, Query, "", ""); */
    
        
OnPropTextdrawUpdate(1, house);
    } 
// UPDATE houses SET `Owner` = '%s' WHERE ID = %d
    
return 1;
} 
thanks in advance


Re: Users modify - nezo2001 - 29.07.2015

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

PHP код:
YCMD:asellhouse(playerid, params[], help) 
{ 
    if(
PlayerData[playerid][Admin] < 6) return SendClientMessage(playerid, COLOR_WHITE, AdminOnly); 
    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", 0, strlen("The State"), 255); 
        
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0); 
        
format(str, sizeof(str), "~w~You have sold the House"); 
        
GameTextForPlayer(playerid, str, 10000, 3); 
        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(SQL, Query, 128,"UPDATE houses SET `Owned`='0', `Lockk`='0', `Owner` ='The State' WHERE `ID`='%d'",HouseInfo[house][hID]); 
        
mysql_tquery(SQL, Query, "", ""); 
        
mysql_tquery(SQL, Query, "", ""); */ 
     
        
OnPropTextdrawUpdate(1, house); 
    } 
// UPDATE houses SET `Owner` = '%s' WHERE ID = %d 
    
return 1; 
} 



Re: Users modify - PepsiCola23 - 29.07.2015

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.


Re: Users modify - Luis- - 29.07.2015

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


Re: Users modify - PepsiCola23 - 29.07.2015

@Luis- ,i verified and tried this :
PHP код:
YCMD:asellhouse(playerid, params[], help)
{
    if(
PlayerData[playerid][Admin] < 6) return SendClientMessage(playerid, COLOR_WHITE, AdminOnly);
    new 
str[128],house;
    if(
sscanf(params, "i", house)) return SendUsage(playerid,"/asellhouse <house id>");
    {
        new 
Query[256];
        
mysql_format(SQL, Query, 256,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s'",HouseInfo[house][hOwner]);
        
mysql_tquery(SQL, Query, "", "");
        
//HouseInfo[house][hLocked] = 1;
        
HouseInfo[house][hOwned] = 0;
        
HouseInfo[house][hLock] = 0;
        
strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
        
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        
format(str, sizeof(str), "~w~You have sold the House");
        
GameTextForPlayer(playerid, str, 10000, 3);
    
//    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(SQL, Query, 256,"UPDATE houses SET `Owned`='0', `Lockk`='0', `Owner` ='The State' WHERE `ID`='%d'",HouseInfo[house][hID]);
        
mysql_tquery(SQL, Query, "", "");
    
/*    mysql_format(SQL, Query, 128,"UPDATE `users` SET `HouseKey`='-1' WHERE username='%s' LIMIT 1",HouseInfo[house][hOwner]);
        mysql_tquery(SQL, Query, "", ""); */
    
        
OnPropTextdrawUpdate(1, house);
    } 
// UPDATE houses SET `Owner` = '%s' WHERE ID = %d
    
return 1;
} 
But still not updating house key to -1.


Re: Users modify - PepsiCola23 - 30.07.2015

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


Re: Users modify - BroZeus - 30.07.2015

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.