CMD:Sellhouse bug
#1

I made my command: /Sellhouse and in game no error or effect happens, it states im still the owner:

Код:
CMD:sellhouse(playerid, params[])
{
	new house = House[playerid][hOwner];
	if(IsPlayerInRangeOfPoint(playerid, 4.0,House[house][hExteriorX],House[house][hExteriorY],House[house][hExteriorZ]))
	{
		if(House[playerid][hOwner] == 1)
		{
	    	if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_WHITE,"{00C0FF}[SYNTAX]: {FFFFFF}/sellhouse");
	    	new id;
			House[id][hOwned] = 0;
  			SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have successfully sold your house!");
  			SaveHouse(id);
		}
		else
		{
	 		SendClientMessage(playerid, COLOR_WHITE, "{F81414}[ERROR]: {FFFFFF}You do not own or not at your house!");
		}
	}
	return 1;
}
Reply
#2

Bump, please help!
Reply
#3

Try this

Код:
CMD:sellhouse(playerid, params[])
{
	if(sscanf(params, "u", playerid)) return SendClientMessage(playerid, COLOR_WHITE,"{00C0FF}[SYNTAX]: {FFFFFF}/sellhouse");
	new house = House[playerid][hOwner];
	if(IsPlayerInRangeOfPoint(playerid, 4.0,House[house][hExteriorX],House[house][hExteriorY],House[house][hExteriorZ]))
	{
		if(House[playerid][hOwner] == 1)
		{
	    	new id;
			House[id][hOwned] = 0;
  			SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have successfully sold your house!");
  			SaveHouse(id);
		} else return SendClientMessage(playerid, COLOR_WHITE, "{F81414}[ERROR]: {FFFFFF}You do not own or not at your house!");
	} 
	return 1;
}
Reply
#4

It does not work, you've placed the 'Nul' syntax at the top so they only see that and when placed back, still nothing happens.
Reply
#5

There's no value assigned to the variable 'id', you could say it's meaningless. Why don't you continue to use the house variable? I believe that were your intentions when creating the 'id' variable, right?

Like so:
PHP код:
CMD:sellhouse(playeridparams[])
{
    new 
house House[playerid][hOwner];
    if(
IsPlayerInRangeOfPoint(playerid4.0House[house][hExteriorX],House[house][hExteriorY],House[house][hExteriorZ]))
    {
        if(
House[playerid][hOwner] == 1)
        {
            if(
sscanf(params"u"playerid)) return SendClientMessage(playeridCOLOR_WHITE,"{00C0FF}[SYNTAX]: {FFFFFF}/sellhouse");
            
House[house][hOwned] = 0;
            
SendClientMessage(playeridCOLOR_LIGHTBLUE"You have successfully sold your house!");
            
SaveHouse(house);
        }
        else
        {
            
SendClientMessage(playeridCOLOR_WHITE"{F81414}[ERROR]: {FFFFFF}You do not own or not at your house!");
        }
    }
    return 
1;

Could you also elaborate on why you are using the sscanf function? It seems redundant to me.
Reply
#6

Yes but I do need a little house as it seems the dynamic pickup and text are staying the same, and I believe I cannot change that unless I redo my whole house system or if someone could help me on here.
Reply
#7

Destroy the pickup and remake it when this command is executed (when the house is sold), or do you do that under the 'SaveHouse' function? If so, show us that code. The text is easy modifiable with the following function: https://sampwiki.blast.hk/wiki/Update3DTextLabelText
Reply
#8

Код:
stock SaveHouse(houseid)
{
    new File[23];
    format(File, sizeof(File), "Houses/%d.ini", houseid);
    if(fexist(File))
    {
       dini_IntSet(File, "hOwned", House[houseid][hOwned]);
       dini_Set(File, "hOwner", House[houseid][hOwner]);
       dini_IntSet(File, "hPrice", House[houseid][hPrice]);
       dini_IntSet(File, "hLock", House[houseid][hLock]);

       dini_FloatSet(File, "hExteriorX", House[houseid][hExteriorX]);
       dini_FloatSet(File, "hExteriorY", House[houseid][hExteriorY]);
       dini_FloatSet(File, "hExteriorZ", House[houseid][hExteriorZ]);
       dini_FloatSet(File, "hExteriorA", House[houseid][hExteriorA]);
       dini_IntSet(File, "hExteriorVW", House[houseid][hExteriorVW]);
       dini_IntSet(File, "hExteriorInt", House[houseid][hExteriorInt]);

       dini_FloatSet(File, "hInteriorX", House[houseid][hInteriorX]);
       dini_FloatSet(File, "hInteriorY", House[houseid][hInteriorY]);
       dini_FloatSet(File, "hInteriorZ", House[houseid][hInteriorZ]);
       dini_FloatSet(File, "hInteriorA", House[houseid][hInteriorA]);
       dini_IntSet(File, "hInteriorVW", House[houseid][hInteriorVW]);
       dini_IntSet(File, "hInteriorInt", House[houseid][hInteriorInt]);

       RespawnHousePickup(houseid);
	}
	return 1;
}
Reply
#9

Show me the code in the body of the 'RespawnHousePickup' function.
Reply
#10

Код:
stock RespawnHousePickup(houseid)
{
	new string[255];

	DestroyDynamicPickup(House[houseid][hPickupID]);
	DestroyDynamic3DTextLabel(House[houseid][hTextLabelID]);
    if(House[houseid][hOwned] >= 1)
    {
        format(string, sizeof(string), "This house is owned by\n%s\nID: %d", House[houseid][hOwner], houseid);
        House[houseid][hTextLabelID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, House[houseid][hExteriorX], House[houseid][hExteriorY], House[houseid][hExteriorZ]+0.5,10.0, .testlos = 1, .worldid = House[houseid][hExteriorVW], .interiorid = House[houseid][hExteriorVW], .streamdistance = 10.0);
	    House[houseid][hPickupID] = CreateDynamicPickup(1272, 23, House[houseid][hExteriorX], House[houseid][hExteriorY], House[houseid][hExteriorZ], .worldid = House[houseid][hExteriorVW], .interiorid = House[houseid][hExteriorVW]);
	}
	else
	{
        format(string, sizeof(string), "For Sale!\nPrice: %d\nID: %d", House[houseid][hPrice], houseid);
        House[houseid][hTextLabelID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, House[houseid][hExteriorX], House[houseid][hExteriorY], House[houseid][hExteriorZ]+0.5,10.0, .testlos = 1, .worldid = House[houseid][hExteriorVW], .interiorid = House[houseid][hExteriorVW], .streamdistance = 10.0);
	    House[houseid][hPickupID] = CreateDynamicPickup(1273, 23, House[houseid][hExteriorX], House[houseid][hExteriorY], House[houseid][hExteriorZ], .worldid = House[houseid][hExteriorVW], .interiorid = House[houseid][hExteriorVW]);
	}
	return 1;
}

stock RespawnHouseTextLabel(houseid)
{
	new string[128];
	if(House[houseid][hOwned] >= 1)
	{
		format(string, sizeof(string), "This house is owned by\n%s\nID: %d", House[houseid][hOwner], houseid);
	}
	else format(string, sizeof(string), "For Sale!\nPrice: %d\nID: %d", House[houseid][hPrice], houseid);
	UpdateDynamic3DTextLabelText(House[houseid][hTextLabelID], COLOR_GREEN, string);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)