Command Help: Dynamic House Create
#1

Hello guys. I'm kind of know the Pawno language but When it's come for this command I can't do anything only errors.
I'm just trying when I'm do /createhouse It's will create a house like I set in the SavedHouse (scriptfiles).
But there's alot of errors.

(24433) : error 001: expected token: ">", but found "++"
(24433) : error 029: invalid expression, assumed zero
(24439) : error 047: array sizes do not match, or destination array is too small
(24449) : error 047: array sizes do not match, or destination array is too small
(24484) : error 017: undefined symbol "sendername"
(24485) : error 035: argument type mismatch (argument 2)
(24486) : error 017: undefined symbol "MAX_HOUSES"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


7 Errors.

Those are the lines...
(I'm really can't control it..) sorry. :S

Код HTML:
 new idx<MAX_HOUSES, idx++;
	{
	  // Getting House Setup
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        //Making House
        HouseInfo[idx][hName]= "Property For Sale!";
		HouseInfo[idx][hLock] = 1;
		HouseInfo[idx][hHours] = 10;
		HouseInfo[idx][hPrice] = 15000;
		HouseInfo[idx][hEnterX] = X;
		HouseInfo[idx][hEnterY] = Y;
		HouseInfo[idx][hEnterZ] = Z;
		HouseInfo[idx][hExitX] = 2496.098876;
		HouseInfo[idx][hExitY] = -1692.503051;
		HouseInfo[idx][hExitZ] = 1014.742187;
		HouseInfo[idx][hOwner] = "The State";
		HouseInfo[idx][hOwned] = 0;
		HouseInfo[idx][hRentable] = 0;
		HouseInfo[idx][hRent] = 1;
		HouseInfo[idx][hInterior] = 2;
		HouseInfo[idx][hMoney] = 0;
		HouseInfo[idx][hGun][0] = 0;
		HouseInfo[idx][hGunAmmo][0] = 0;
		HouseInfo[idx][hWeed] = 0;
		HouseInfo[idx][hCocaine] = 0;
		HouseInfo[idx][hCrack] = 0;
		HouseInfo[idx][hArmour] = 0;
		HouseInfo[idx][hType] = 0;
		HouseInfo[idx][hEInt] = 0;
		HouseInfo[idx][hEWorld] = 0;
		HouseInfo[idx][hTime] = 0;
		HouseInfo[idx][hGun][1] = 0;
		HouseInfo[idx][hGunAmmo][1] = 0;
		HouseInfo[idx][hGun][2] = 0;
		HouseInfo[idx][hGunAmmo][2] = 0;
		HouseInfo[idx][hGun][3] = 0;
		HouseInfo[idx][hGunAmmo][3] = 0;
		HouseInfo[idx][hComd] = 0;
		HouseInfo[idx][hGun][4] = 0;
		HouseInfo[idx][hGunAmmo][4] = 0;
		HouseInfo[idx][hGun][5] = 0;
		HouseInfo[idx][hGunAmmo][5] = 0;
		HouseInfo[idx][hGun][6] = 0;
		HouseInfo[idx][hGunAmmo][6] = 0;
		HouseInfo[idx][hGun][7] = 0;
		HouseInfo[idx][hGunAmmo][7] = 0;
		HouseInfo[idx][hGun][8] = 0;
		HouseInfo[idx][hGunAmmo][8] = 0;
		HouseInfo[idx][hGun][9] = 0;
		HouseInfo[idx][hGunAmmo][9] = 0;
		format(string, sizeof(string), "{FF0000}[Admin Warn]:{FF6347} %s has created house ID %d.", sendername, idx);
		SendAdminMessage(COLOR_LIGHTRED, 1, string);
		idx = MAX_HOUSES;
	}
	return 1;
}
Reply
#2

UP++
Reply
#3

You're using a "new", while you should use a "for" loop.
"new" explantion -> https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
"for" loop -> https://sampwiki.blast.hk/wiki/Loops

Focus on the line,
pawn Код:
new idx<MAX_HOUSES, idx++;
Reply
#4

Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
You're using a "new", while you should use a "for" loop.
"new" explantion -> https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
"for" loop -> https://sampwiki.blast.hk/wiki/Loops

Focus on the line,
pawn Код:
new idx<MAX_HOUSES, idx++;
So i did it like it.
pawn Код:
new idk, MAX_HOUSES, idkx++;
Reply
#5

Quote:
Originally Posted by wakeuptomer
Посмотреть сообщение
So i did it like it.
pawn Код:
new idk, MAX_HOUSES, idkx++;
Again,
Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
You're using a "new", while you should use a "for" loop.
"new" explantion -> https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
"for" loop -> https://sampwiki.blast.hk/wiki/Loops

Focus on the line,
pawn Код:
new idx<MAX_HOUSES, idx++;
You need to use a for loop(Tutorial), NOT new.
EDIT: And when I mean not a new, I mean not as a starter. You need to use the full for syntax.
pawn Код:
for( ; ; ) { .. }
Reply
#6

Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
Again,


You need to use a for loop(Tutorial), NOT new.
EDIT: And when I mean not a new, I mean not as a starter. You need to use the full for syntax.
pawn Код:
for( ; ; ) { .. }
If not it's not correct please show me how you do it.
because i will never understand how.
Thank's for the help.

pawn Код:
for(new idx = 0,idx<MAX_HOUSES; idx++)
Reply
#7

Quote:
Originally Posted by wakeuptomer
Посмотреть сообщение
If not it's not correct please show me how you do it.
because i will never understand how.
Thank's for the help.

pawn Код:
for(new idx = 0,idx<MAX_HOUSES; idx++)
It's correct now, you can try an complie it. And check it by yourself.
Just a little TIP! Always, MAX_HOUSES would not be loaded.

Explanation:
If your MAX_HOUSES is set to 500
It will load everything from 0 to 499.
500 will not be loaded, cause it says while id is less then 500.

So it basicly does:
pawn Код:
if(idx != 500) {...} // (if idx does not(!=) equels to 500)
When it reaches 500, it does:
pawn Код:
if(500 != 500) {...} // (if idx(500) does not(!=) equel to 500)
// But it does equel to 500, so it won't run and just end the process.
Reply
#8

Almost got that for loop there! Just one tiny problem:

pawn Код:
for(new idx = 0; idx < MAX_HOUSES; ++idx)
When you did "idx = 0" you put a comma when it should be a semicolon.

Also, idx++ and ++idx are the same thing
Reply
#9

Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
Again,


You need to use a for loop(Tutorial), NOT new.
EDIT: And when I mean not a new, I mean not as a starter. You need to use the full for syntax.
pawn Код:
for( ; ; ) { .. }
Quote:
Originally Posted by sammp
Посмотреть сообщение
Almost got that for loop there! Just one tiny problem:

pawn Код:
for(new idx = 0; idx < MAX_HOUSES; ++idx)
When you did "idx = 0" you put a comma when it should be a semicolon.

Also, idx++ and ++idx are the same thing
It's just not working please show me what you are doing to fix it. show me the full line.

It's still erroring

(24433) : error 021: symbol already defined: "idx"
(24433) : error 001: expected token: ">", but found ";"
(24439) : error 047: array sizes do not match, or destination array is too small
(24449) : error 047: array sizes do not match, or destination array is too small
(24485) : error 035: argument type mismatch (argument 2)
(24486) : error 017: undefined symbol "MAX_HOUSES"
(24433) : warning 204: symbol is assigned a value that is never used: "idx"


pawn Код:
for(new idx = 0,idx <MAX_HOUSES; ++idx)
    {
      // Getting House Setup
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        //Making House
        HouseInfo[idx][hName]= "Property For Sale!";
        HouseInfo[idx][hLock] = 1;
        HouseInfo[idx][hHours] = 10;
        HouseInfo[idx][hPrice] = 15000;
        HouseInfo[idx][hEnterX] = X;
        HouseInfo[idx][hEnterY] = Y;
        HouseInfo[idx][hEnterZ] = Z;
        HouseInfo[idx][hExitX] = 2496.098876;
        HouseInfo[idx][hExitY] = -1692.503051;
        HouseInfo[idx][hExitZ] = 1014.742187;
        HouseInfo[idx][hOwner] = "The State";
        HouseInfo[idx][hOwned] = 0;
        HouseInfo[idx][hRentable] = 0;
        HouseInfo[idx][hRent] = 1;
        HouseInfo[idx][hInterior] = 2;
        HouseInfo[idx][hMoney] = 0;
        HouseInfo[idx][hGun][0] = 0;
        HouseInfo[idx][hGunAmmo][0] = 0;
        HouseInfo[idx][hWeed] = 0;
        HouseInfo[idx][hCocaine] = 0;
        HouseInfo[idx][hCrack] = 0;
        HouseInfo[idx][hArmour] = 0;
        HouseInfo[idx][hType] = 0;
        HouseInfo[idx][hEInt] = 0;
        HouseInfo[idx][hEWorld] = 0;
        HouseInfo[idx][hTime] = 0;
        HouseInfo[idx][hGun][1] = 0;
        HouseInfo[idx][hGunAmmo][1] = 0;
        HouseInfo[idx][hGun][2] = 0;
        HouseInfo[idx][hGunAmmo][2] = 0;
        HouseInfo[idx][hGun][3] = 0;
        HouseInfo[idx][hGunAmmo][3] = 0;
        HouseInfo[idx][hComd] = 0;
        HouseInfo[idx][hGun][4] = 0;
        HouseInfo[idx][hGunAmmo][4] = 0;
        HouseInfo[idx][hGun][5] = 0;
        HouseInfo[idx][hGunAmmo][5] = 0;
        HouseInfo[idx][hGun][6] = 0;
        HouseInfo[idx][hGunAmmo][6] = 0;
        HouseInfo[idx][hGun][7] = 0;
        HouseInfo[idx][hGunAmmo][7] = 0;
        HouseInfo[idx][hGun][8] = 0;
        HouseInfo[idx][hGunAmmo][8] = 0;
        HouseInfo[idx][hGun][9] = 0;
        HouseInfo[idx][hGunAmmo][9] = 0;
        format(string, sizeof(string), "{FF0000}[Admin Warn]:{FF6347} %s has created house ID %d.", sendername, idx);
        SendAdminMessage(COLOR_LIGHTRED, 1, string);
        idx = MAX_HOUSES;
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by sammp
Посмотреть сообщение
Also, idx++ and ++idx are the same thing
No they're not. idx++ increments it after the iteration, ++idx increments it before the iteration, the difference would be ++idx would mean 0 is never called and the loop would start at 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)