/createhouse problems.
#1

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;
        }
Reply
#2

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

//Inside the command.
House++;
Reply
#3

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..
Reply
#4

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


House++;//Inside your command

You get me wrong, and use pawn tag.
Reply
#5

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.
Reply
#6

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?
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)