How to check if someone is house owner
#1

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?
Reply
#2

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
Reply
#3

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
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)