Will strval convert a player's name to the player's ID?
#3

Not at all. This is how I am using it:

pawn Код:
if (strcmp("/buyhouse", cmdtext, true, 10) == 0)
    {
        GetHouseID(playerid);
        format(file, sizeof(file), "House_%d.ini", HouseID);
        forSale = dini_Get(file, "ForSale");
        houseOwned = dini_Get(file, "Owned");
        hValue = dini_Get(file, "Price");
        if(strval(forSale) == 1)
        {
            if(strval(houseOwned) == 1)
            {
                OwnerName = dini_Get(file, "Owner");
                GetPlayerName(playerid, name, sizeof(name));
                if(strcmp(name, OwnerName) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You may not buy your own houses");
                if(GetPlayerMoney(playerid) >= strval(hValue))
                {
                    GivePlayerMoney(playerid, GetPlayerMoney(playerid)-strval(hValue));
                    GivePlayerMoney("OwnerName", strval(hValue)/100*75);
                    dini_Set(file, "Owner", name);
                    dini_IntSet(file, "Price", INVALID_HOUSE_PRICE);
                    dini_IntSet(file, "ForSale", 0);
                    dini_IntSet(file, "Pickupid", 1273);
                    dini_IntSet(file, "Owned", 1);
                }
            }
        }
        return 1;
    }
On a house creation, the "Owner" is defined as "None". Although when a player buys the house, his name will replace the "None", notice that "houseOwned".

So, I do have the player's name.. but what now?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)