house system GivePlayerMoney
#1

The GivePlayerMoney doesn't work for this /buyhouse command. It also doesn't set the owner when typing /buyhouse, so you can't /sellhouse because it don't set the owner!

pawn Код:
CMD:buyhouse(playerid, params[])
    {
    new string[100], owner[30], ID;
    if(sscanf(params, "d", ID)) return UsageMessage(pid, "/buyhouse [houseaddress]");
    if(!IsPlayerInRangeOfPoint(pid, 5.5, HouseInfo[ID][hextX], HouseInfo[ID][hextY], HouseInfo[ID][hextZ])) return SCM(pid, COLRED, "Server: {F0F0F0}You are not in range of house!");
    if(GetPlayerMoney(playerid) >= HouseInfo[ID][hPrice])
        {
        if(strmatch(HouseInfo[ID][hOwner], "None"))
            {
            new price = HouseInfo[ID][hPrice];
            GivePlayerMoney(playerid, - price);
            format(owner, sizeof(owner), "%s", GetName(playerid));
            HouseInfo[ID][hOwner] = owner;
            Delete3DTextLabel(HouseInfo[ID][hLabel]);
            format(string, sizeof(string), "%House\nAddress: %d", ID);
            HouseInfo[ID][hLabel] = Create3DTextLabel(string, COLBLUE, HouseInfo[ID][hextX], HouseInfo[ID][hextY], HouseInfo[ID][hextZ], 20.0, 0, 1);
            }
        else return SCM(pid, COLRED, "Server: {f0f0f0}this house is owned.");
        }
    else
        {
        SCM(pid, COLRED, "Server: {f0f0f0}You don't have enough money.");
        }
    return 1;
    }
Reply
#2

pawn Код:
format(HouseInfo[ID][hOwner], sizeof(HouseInfo[ID][hOwner]), "%s", GetName(playerid));
Try that and, have you got a variable, EG:

pawn Код:
PlayerInfo[playerid][pMoney]
?
Reply
#3

I do but I'd prefer not to use it lol
Reply
#4

Try these and give me a reply, if it works

pawn Код:
CMD:buyhouse(playerid, params[])
{
    new string[100], owner[30], ID;
    if(sscanf(params, "d", ID)) return UsageMessage(pid, "/buyhouse [houseaddress]");
    if(!IsPlayerInRangeOfPoint(pid, 5.5, HouseInfo[ID][hextX], HouseInfo[ID][hextY], HouseInfo[ID][hextZ])) return SCM(pid, COLRED, "Server: {F0F0F0}You are not in range of house!");
    if(GetPlayerMoney(playerid) >= HouseInfo[ID][hPrice])
    {
        if(strmatch(HouseInfo[ID][hOwner], "None"))
        {
            new price = HouseInfo[ID][hPrice];
            GivePlayerMoney(playerid, -price); //removed the space     
                       
            strmid(HouseInfo[ID][sOwner], PlayerName(playerid), 24 , strlen(PlayerName(playerid)), 24); //24 = MAX_PLAYER_NAME // removed the format and changed it with strlen and strmid
           
            Delete3DTextLabel(HouseInfo[ID][hLabel]);
            format(string, sizeof(string), "%House\nAddress: %d", ID);
            HouseInfo[ID][hLabel] = Create3DTextLabel(string, COLBLUE, HouseInfo[ID][hextX], HouseInfo[ID][hextY], HouseInfo[ID][hextZ], 20.0, 0, 1);
        }
        else return SCM(pid, COLRED, "Server: {f0f0f0}this house is owned.");
    }  
    else   
    {
        SCM(pid, COLRED, "Server: {f0f0f0}You don't have enough money.");
    }
    return 1;
}
Reply
#5

didnt work
Reply
#6

Have you got a variable, something like this?, it would be easier if you do have a variable, similar to this

pawn Код:
HouseInfo[ID][hOwned]
Reply
#7

You can just use this for GiveMoney

Код:
GivePlayerMoney(playerid, -HouseInfo[ID][hPrice]);
About ower

If you are using this

Код:
 if(strmatch(HouseInfo[ID][hOwner], "None"))
Then here

Код:
strmid(HouseInfo[ID][sOwner], PlayerName(playerid), 24 , strlen(PlayerName(playerid)), 24);
It Should be the same huh?

Код:
strmid(HouseInfo[ID][hOwner], PlayerName(playerid), 24 , strlen(PlayerName(playerid)), 24);
All code.


Код:
CMD:buyhouse(playerid, params[])
{
    new string[100], owner[30], ID;
    if(sscanf(params, "d", ID)) return UsageMessage(pid, "/buyhouse [houseaddress]");
    if(!IsPlayerInRangeOfPoint(pid, 5.5, HouseInfo[ID][hextX], HouseInfo[ID][hextY], HouseInfo[ID][hextZ])) return SCM(pid, COLRED, "Server: {F0F0F0}You are not in range of house!");
    if(GetPlayerMoney(playerid) >= HouseInfo[ID][hPrice])
    {
        if(strmatch(HouseInfo[ID][hOwner], "None"))
        {
            GivePlayerMoney(playerid, -HouseInfo[ID][hPrice]); //removed the space      
                        
            strmid(HouseInfo[ID][hOwner], PlayerName(playerid), 24 , strlen(PlayerName(playerid)), 24); //24 = MAX_PLAYER_NAME // removed the format and changed it with strlen and strmid
            
            Delete3DTextLabel(HouseInfo[ID][hLabel]);
            format(string, sizeof(string), "%House\nAddress: %d", ID);
            HouseInfo[ID][hLabel] = Create3DTextLabel(string, COLBLUE, HouseInfo[ID][hextX], HouseInfo[ID][hextY], HouseInfo[ID][hextZ], 20.0, 0, 1);
        }
        else return SCM(pid, COLRED, "Server: {f0f0f0}this house is owned.");
    }   
    else    
    {
        SCM(pid, COLRED, "Server: {f0f0f0}You don't have enough money.");
    }
    return 1
Reply
#8

That didnt work, the money issue is my biggest issue atm
Reply
#9

Then problem is not in this command!

Just your hPrice is 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)