SA-MP Forums Archive
/createhouse problems. - 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: /createhouse problems. (/showthread.php?tid=283778)



/createhouse problems. - DiiP - 16.09.2011

Hello.
I have this command, but it moves house ID 0 and doesn't create a new one, I cannot seem to find the problem.
pawn Код:
if(strcmp(cmd, "/createhouse", true) == 0)
        {
            new house;
            if (PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid,COLOR_WHITE,"You're not authroized to use this command !");
            print("Debug above loop");
            for(new h; h < sizeof(HouseInfo); h++)
                {
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(playerid,X,Y,Z);
                print("Debug in loop");
                HouseInfo[house][hEntrancex] = X;
                printf("House ID %d, X[%f]", house, X);
                HouseInfo[house][hEntrancey] = Y;
                printf("House ID %d, Y[%f]", house, Y);
                HouseInfo[house][hEntrancez] = Z;
                printf("House ID %d, Z[%f]", house, Z);
                HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 1, X, Y, Z);
                OnPropUpdate();
                return 1;
            }
            print("Debug after loop");
            return 1;
        }



Re: /createhouse problems. - =WoR=Varth - 16.09.2011

Because you create a local variable which set to 0 every you create it.
pawn Код:
new House;

//Inside the command.
House++;



Re: /createhouse problems. - DiiP - 16.09.2011

if(strcmp(cmd, "/createhouse", true) == 0)
{
new house;
if (PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid,COLOR_WHITE,"You're not authroized to use this command !");
print("Debug above loop");
for(new h = 0; h < SCRIPT_MAXHOUSES; h++)
{
if(HouseInfo[house][hOwned] == 1)
{
house = h;
break;
}
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
print("Debug in loop");
HouseInfo[house][hEntrancex] = X;
printf("House ID %d, X[%f]", house, X);
HouseInfo[house][hEntrancey] = Y;
printf("House ID %d, Y[%f]", house, Y);
HouseInfo[house][hEntrancez] = Z;
printf("House ID %d, Z[%f]", house, Z);
HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 1, X, Y, Z);
house++;
OnPropUpdate();
return 1;
}
print("Debug after loop");
return 1;
}

It moves house ID 0, and it dosnt create a new house..


Re: /createhouse problems. - =WoR=Varth - 16.09.2011

pawn Код:
new House;//On top of your script


House++;//Inside your command

You get me wrong, and use pawn tag.


Re: /createhouse problems. - DiiP - 16.09.2011

pawn Код:
if(strcmp(cmd, "/createhouse", true) == 0)
        {
            if (PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid,COLOR_WHITE,"You're not authroized to use this command !");
            print("Debug above loop");
            for(new h = 0; h < sizeof(HouseInfo); h++)
                {
                    if(HouseInfo[House][hOwned] == 1)
                        {
                            House = h;
                                break;
                        }
                new Float:X,Float:Y,Float:Z;
                GetPlayerPos(playerid,X,Y,Z);
                print("Debug in loop");
                HouseInfo[House][hEntrancex] = X;
                printf("House ID %d, X[%f]", House, X);
                HouseInfo[House][hEntrancey] = Y;
                printf("House ID %d, Y[%f]", House, Y);
                HouseInfo[House][hEntrancez] = Z;
                printf("House ID %d, Z[%f]", House, Z);
                HouseInfo[House][hPickupID] = CreateDynamicPickup(1273, 1, X, Y, Z);
                        House++;
                OnPropUpdate();
                return 1;
            }
            print("Debug after loop");
            return 1;
        }
It yet, moves house ID 0 and doesn't create a new one.


Re: /createhouse problems. - Tee - 16.09.2011

Do you mean you every time you use /createhouse, you want to make it create a new one with a new ID?
Example:
1. /createhouse would create house 0.
2. /createhouse would create house 1.
3. And so on?


Re: /createhouse problems. - Jack_Leslie - 17.09.2011

Quote:
Originally Posted by Tee
Посмотреть сообщение
Do you mean you every time you use /createhouse, you want to make it create a new one with a new ID?
Example:
1. /createhouse would create house 0.
2. /createhouse would create house 1.
3. And so on?
Yes, that's what he means, he wants to create a house. But instead it's moving houses.