Getting house owner if its right sell it HELP
#1

Ok so i wanted to make a sell house command but i dont know how to get the house owner.... this is what im trying to:
pawn Код:
CMD:sellhouse(playerid, params[])
{
    new name[42], string[128], owner[40];
    GetPlayerName(playerid, name, sizeof(name));
    for(new i; i < MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[i][HouseX],AHouseData[i][HouseY],AHouseData[i][HouseZ]))
        {
            if(strlen(AHouseData[i][Owner]) > 0)
            {
                format(string, sizeof(string), "SELECT Houseowner = '%s' FROM Houses WHERE ID = '%d'", owner, i);
                mysql_query(string);
                mysql_store_result();
                if(AHouseData[i][Owner] == owner)
                {
                }
            }
        }
    }
    return 1;
 }
Anyone has an idea ? if the owner was matching with database it should sell but i cant assign string to string but i dont know how to do it else way :S Thanks in advance
Reply
#2

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "SELECT Houseowner FROM Houses WHERE ID = '%d'", i);
mysql_query(string);
mysql_store_result();
new howner[MAX_PLAYER_NAME];
mysql_fetch_field("Houseowner", howner);
if(!strcmp(howner, name, false)) { // If the name in the database matches with your name...
    // If the player is the owner...
}
else {
    // If the player is not the owner...
}
mysql_free_result();
Example code. Btw, you can't select a query like that, do what I did ^^.
Reply
#3

The mysql_fetch_field part gives a tag mismatch error? :O

Код:
C:\Users\Thimo\Desktop\Sa-mp 0.3d\gamemodes\ER.pwn(1386) : error 035: argument type mismatch (argument 1)
Reply
#4

What SQL plugin are you using? StrickenKid's or BlueG's? I'm using StrickenKid's because BlueG's doesn't work on 64-bit CentOS. I don't know how it is in BlueG's plugin, I could look for it.
Reply
#5

Err i dont know the one wich is named a_mysql
Edit: found it
Код:
/*
	SA-MP MySQL plugin R5
	Copyright © 2008-2010, G-sTyLeZzZ 
*/
Reply
#6

Yes, that's BlueG's plugin.

Then replace that "mysql_fetch_field" line with:


pawn Код:
if(mysql_retrieve_row()) mysql_fetch_field_row(howner, "Houseowner");
Reply
#7

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)