SA-MP Forums Archive
How to check if someone is house owner - 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: How to check if someone is house owner (/showthread.php?tid=509970)



How to check if someone is house owner - AphexCCFC - 29.04.2014

How would I check if the player is house owner or not?

pawn Код:
if(strcmp("None", HouseInfo[id][hOwner], true))
How can I turn "None" into a string %s to check if owner is same as the one in the HouseInfo[id][hOwner] variable using strcmp?


Re: How to check if someone is house owner - Dignity - 29.04.2014

Getting their name and checking if the string matches. Something like this: (not sure if you use this to check if strings match seeing I don't use strcmp)

pawn Код:
new name[MAX_PLAYER_NAME]
GetPlayerName(playerid, name, sizeof(name));

if(strcmp(name, HouseInfo[id][hOwner], true))
// etc



Respuesta: Re: How to check if someone is house owner - Swedky - 29.04.2014

Quote:
Originally Posted by Mionee
Посмотреть сообщение
Getting their name and checking if the string matches. Something like this: (not sure if you use this to check if strings match seeing I don't use strcmp)

pawn Код:
new name[MAX_PLAYER_NAME]
GetPlayerName(playerid, name, sizeof(name));

if(strcmp(name, HouseInfo[id][hOwner], true))
// etc
pawn Код:
new name[MAX_PLAYER_NAME]
GetPlayerName(playerid, name, sizeof(name));

if(strcmp(name, HouseInfo[id][hOwner], true) == 0) // If the value that he returns is '0'.
// etc



Re: How to check if someone is house owner - AphexCCFC - 29.04.2014

Hmm. I wanted it so if a house row owned by a player is deleted in the database and the player has the house id (PlayerInfo[playerid][pHouse]) in their variable, it lets them know via message.

I added this into where my players log in and it doesn't send the message when I buy a house and delete the row:

pawn Код:
new id = PlayerInfo[playerid][pHouse];

    if(PlayerInfo[playerid][pHouse] >= 0)
    {
        if(strcmp(Player(playerid), HouseInfo[id][hOwner], false) == 0)
        {
            SendClientMessage(playerid, COLOR_ORANGE, "You have been removed as ownership from your house.");
        }
    }
I use Player(playerid) to set the owner of the house

pawn Код:
stock Player(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
Thanks