Housing Command
#1

Hello, I have these two commands:

pawn Code:
CMD:houseprice(playerid, params[])
{
    new string[210], cash;
    new i = GetClosetHouseID(playerid);
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not authorized to use this command.");
    if(AdminDuty[playerid] < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not on duty as an Administrator [/aduty].");
    if(House[i][On_Sell] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: This house price cannot be edited because it isn't for sale.");
    if(i < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not close to a house.");
    if(sscanf(params, "i", cash)) return SendClientMessage(playerid, COLOR_TWGRAY, "USAGE{FFFFFF}: /houseprice [House Price Amount]");
    if(cash < 1 || cash > 2500000) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: The house price can only be between $1 and $2500000.");
    House[i][Price] = cash;
    CheckHouse(i);
    format(string,sizeof(string),"Information{FFFFFF}: You have edited house %d %s price to $%d.", House[i][CheckHouseID], House[i][Address], cash);
    SendClientMessage(playerid, COLOR_ORANGE, string);
    format(string, sizeof(string), "Admin Notice: Administrator %s has changed house %d %s price to $%d.", GetName(playerid), House[i][CheckHouseID], House[i][Address], cash);
    SendClientMessageToAdmins(COLOR_DARKRED, string, 1);
    format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"None\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"$%d\n{29CC3F}Address: "COL_WHITE"%d %s\n{29CC3F}Status: "COL_WHITE"Ownable",House[i][HouseName],House[i][Price],House[i][CheckHouseID],House[i][Address]);
    UpdateDynamic3DTextLabelText(House[i][DLabel],-1,string);
    return 1;
}

CMD:houseaddress(playerid, params[])
{
    new string[210], say;
    new i = GetClosetHouseID(playerid);
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not authorized to use this command.");
    if(AdminDuty[playerid] < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not on duty as an Administrator [/aduty].");
    if(House[i][On_Sell] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: This house price cannot be edited because it isn't for sale.");
    if(i < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not close to a house.");
    if(sscanf(params, "s", say)) return SendClientMessage(playerid, COLOR_TWGRAY, "USAGE{FFFFFF}: /houseaddress [Address (Example: Palomino Creek)]");
    House[i][Address] = say;
    CheckHouse(i);
    format(string,sizeof(string),"Information{FFFFFF}: You have changed the address of house ID %d to %s.", House[i][CheckHouseID], say);
    SendClientMessage(playerid, COLOR_ORANGE, string);
    format(string, sizeof(string), "Admin Notice: Administrator %s has changed address of house ID %d to %s.", GetName(playerid), House[i][CheckHouseID], say);
    SendClientMessageToAdmins(COLOR_DARKRED, string, 1);
    format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"None\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"$%d\n{29CC3F}Address: "COL_WHITE"%d %s\n{29CC3F}Status: "COL_WHITE"Ownable",House[i][HouseName],House[i][Price],House[i][CheckHouseID],House[i][Address]);
    UpdateDynamic3DTextLabelText(House[i][DLabel],-1,string);
    return 1;
}
The /houseprice command works perfectly, but the /houseaddress command only changes the first letter of the address. Say the address says "Palomino Creek" and I type '/houseaddress Dillimore', it'll change the address to 'Dalomino Creek'.
Reply
#2

Your say variable is not a string, but it should be one, because you are trying to change a text. If you fix that, I think it'll work
Reply
#3

I've tried
pawn Code:
new say[128];
if that's what you mean, says the array doesn't match.
Reply
#4

Please help
Reply
#5

Quote:
Originally Posted by AphexCCFC
View Post
I've tried
pawn Code:
new say[128];
if that's what you mean, says the array doesn't match.
That's what I meant

Replace
pawn Code:
new say;
with
pawn Code:
new say[128];
and replace
pawn Code:
if(sscanf(params, "s", say))
with this
pawn Code:
if(sscanf(params, "s[128]", say))
After you did this, it should work
Reply
#6

I have changed the commands to make them easier to use, here is the new one:

pawn Code:
CMD:hedit(playerid, params[])
{
    new string[210], cash, say[128];
    new i = GetClosetHouseID(playerid);
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not authorized to use this command.");
    if(AdminDuty[playerid] < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not on duty as an Administrator [/aduty].");
    if(i < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not close to a house.");
    if(House[i][On_Sell] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: This house cannot be edited because it isn't for sale.");
    if(sscanf(params, "s[32]", params))
    {
        SendClientMessage(playerid, COLOR_TWGRAY, "Usage{FFFFFF}: /hedit [option]");
        SendClientMessage(playerid, COLOR_GREEN, "Options{FFFFFF}: Price, Address.");
        return 1;
    }
    if(!strcmp(params, "price", true, 5))
    {
        if(sscanf(params, "s[32]i", params, cash))
        {
            SendClientMessage(playerid, COLOR_TWGRAY, "Usage{FFFFFF}: /hedit price [amount]");
            return 1;
        }
        if(cash < 1 || cash > 2000000) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: The house price can only be between $1 and $2000000.");
        House[i][Price] = cash;
        CheckHouse(i);
        format(string,sizeof(string),"Information{FFFFFF}: You have edited house %s price to $%d.", House[i][Address], cash);
        SendClientMessage(playerid, COLOR_ORANGE, string);
        format(string, sizeof(string), "Admin Notice{FFFFFF}: Administrator %s has changed house %s price to $%d.", GetName(playerid), House[i][Address], cash);
        SendClientMessageToAdmins(COLOR_DARKRED, string, 1);
        format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"None\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"$%d\n{29CC3F}Address: "COL_WHITE"%s\n{29CC3F}Status: "COL_WHITE"Ownable",House[i][HouseName],House[i][Price],House[i][Address]);
        UpdateDynamic3DTextLabelText(House[i][DLabel],-1,string);
        return 1;
    }
    if(!strcmp(params, "address", true, 7))
    {
        if(sscanf(params, "s[32]s[128]", params, say))
        {
            SendClientMessage(playerid, COLOR_TWGRAY, "Usage{FFFFFF}: /hedit address [text]");
            return 1;
        }
        House[i][Address] = say; // This is the error line
        CheckHouse(i);
        format(string,sizeof(string),"Information{FFFFFF}: You have edited house ID %d address to %s.", House[i][CheckHouseID], House[i][Address]);
        SendClientMessage(playerid, COLOR_ORANGE, string);
        format(string, sizeof(string), "Admin Notice{FFFFFF}: Administrator %s has changed house ID %d address to %s.", GetName(playerid), House[i][CheckHouseID], House[i][Address]);
        SendClientMessageToAdmins(COLOR_DARKRED, string, 1);
        format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"None\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"$%d\n{29CC3F}Address: "COL_WHITE"%s\n{29CC3F}Status: "COL_WHITE"Ownable",House[i][HouseName],House[i][Price],House[i][Address]);
        UpdateDynamic3DTextLabelText(House[i][DLabel],-1,string);
        return 1;
    }
    return 1;
}
Again, editing the house price works, but now when I compile after changing the "say" variable to what you suggested I am getting the error
Code:
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(2643) : error 047: array sizes do not match, or destination array is too small
Here is line 2643 of the error:
pawn Code:
House[i][Address] = say;
I have also marked the error line in the PAWN code above.
Reply
#7

PHP Code:
CMD:hedit(playeridparams[])
{
    new 
string[210], cashsay;
    new 
GetClosetHouseID(playerid);
    if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not authorized to use this command.");
    if(
AdminDuty[playerid] < 1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not on duty as an Administrator [/aduty].");
    if(
1) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not close to a house.");
    if(
House[i][On_Sell] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"Error{FFFFFF}: This house cannot be edited because it isn't for sale.");
    if(
sscanf(params"s[32]"params))
    {
        
SendClientMessage(playeridCOLOR_TWGRAY"Usage{FFFFFF}: /hedit [option]");
        
SendClientMessage(playeridCOLOR_GREEN"Options{FFFFFF}: Price, Address.");
        return 
1;
    }
    if(!
strcmp(params"price"true5))
    {
        if(
sscanf(params"s[32]i"paramscash))
        {
            
SendClientMessage(playeridCOLOR_TWGRAY"Usage{FFFFFF}: /hedit price [amount]");
            return 
1;
        }
        if(
cash || cash 2000000) return SendClientMessage(playeridCOLOR_LIGHTRED"Error{FFFFFF}: The house price can only be between $1 and $2000000.");
        
House[i][Price] = cash;
        
CheckHouse(i);
        
format(string,sizeof(string),"Information{FFFFFF}: You have edited house %s price to $%d."House[i][Address], cash);
        
SendClientMessage(playeridCOLOR_ORANGEstring);
        
format(stringsizeof(string), "Admin Notice{FFFFFF}: Administrator %s has changed house %s price to $%d."GetName(playerid), House[i][Address], cash);
        
SendClientMessageToAdmins(COLOR_DARKREDstring1);
        
format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"None\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"$%d\n{29CC3F}Address: "COL_WHITE"%s\n{29CC3F}Status: "COL_WHITE"Ownable",House[i][HouseName],House[i][Price],House[i][Address]);
        
UpdateDynamic3DTextLabelText(House[i][DLabel],-1,string);
        return 
1;
    }
    if(!
strcmp(params"address"true7))
    {
        if(
sscanf(params"s[32]s[128]"paramssay))
        {
            
SendClientMessage(playeridCOLOR_TWGRAY"Usage{FFFFFF}: /hedit address [text]");
            return 
1;
        }
        
House[i][Address] = say// This is the error line
        
CheckHouse(i);
        
format(string,sizeof(string),"Information{FFFFFF}: You have edited house ID %d address to %s."House[i][CheckHouseID], House[i][Address]);
        
SendClientMessage(playeridCOLOR_ORANGEstring);
        
format(stringsizeof(string), "Admin Notice{FFFFFF}: Administrator %s has changed house ID %d address to %s."GetName(playerid), House[i][CheckHouseID], House[i][Address]);
        
SendClientMessageToAdmins(COLOR_DARKREDstring1);
        
format(string,sizeof(string),"{29CC3F}Owner: "COL_WHITE"None\n{29CC3F}House Name: "COL_WHITE"%s\n{29CC3F}Price: "COL_WHITE"$%d\n{29CC3F}Address: "COL_WHITE"%s\n{29CC3F}Status: "COL_WHITE"Ownable",House[i][HouseName],House[i][Price],House[i][Address]);
        
UpdateDynamic3DTextLabelText(House[i][DLabel],-1,string);
        return 
1;
    }
    return 
1;

Reply
#8

Because House[i][adres] is a string too, you need to format it.
Reply
#9

How do I format it? Yusei that just changes the first letter of the house address.
Reply
#10

format(House[i][adres], sizeof House[i][adres], "%s", say);
Replace House[i][Address] = say; with the format.
Reply
#11

Hmm, but then this happens:

Code:
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(2643) : error 001: expected token: "]", but found "-identifier-"
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(2643) : warning 215: expression has no effect
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(2643) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(2643) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(2643) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#12

Are you sure that House[i][Adres] is a string? And if so, then replace sizeof House[i][Adres] with the size of the string.
Reply
#13

Sorry, House[i][Address] is a variable as I have this written at the top of my game mode:
pawn Code:
new House[MAX_HOUSE][house];
But I can't seem to think of a way to change the variable (as it writes in the house file when changed) to display the new address written even if numbers and spaces are used like "1 Palomino Creek".
Reply
#14

It should be a string, otherwise you can't put a text into it.
Reply
#15

Thanks, it's working now. I used
pawn Code:
format(House[i][Address],32,"%s",say);
and it writes anything typed into the file and displays it. +rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)