SA-MP Forums Archive
house system GivePlayerMoney - 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: house system GivePlayerMoney (/showthread.php?tid=468740)



house system GivePlayerMoney - Mattakil - 10.10.2013

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;
    }



Re: house system GivePlayerMoney - iGetty - 10.10.2013

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]
?


Re: house system GivePlayerMoney - Mattakil - 11.10.2013

I do but I'd prefer not to use it lol


Re: house system GivePlayerMoney - Patrick - 11.10.2013

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;
}



Re: house system GivePlayerMoney - Mattakil - 11.10.2013

didnt work


Re: house system GivePlayerMoney - Patrick - 11.10.2013

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]



Re: house system GivePlayerMoney - edzis84 - 11.10.2013

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



Re: house system GivePlayerMoney - Mattakil - 11.10.2013

That didnt work, the money issue is my biggest issue atm


Re: house system GivePlayerMoney - edzis84 - 11.10.2013

Then problem is not in this command!

Just your hPrice is 0