Windows
#1

This is my variable:

pawn Код:
new windows[MAX_VEHICLES][4];
What do I want to do?.. I want to loop through every vehicle and set each window (all four of them) to 0.

pawn Код:
for(new i=1; i < MAX_VEHICLES; i++)
{
    windows[MAX_WINDOWS][i];
}
The attempt I did at coding above clearly fails as it fucks up my whole gamemode. Anyone that can teach me how to do this?
Reply
#2

pawn Код:
for(new i= 0; i < MAX_VEHICLES; i++)
{
    for(new ii = 0; ii < MAX_WINDOWS; ii++)
    {
        Windows[i][ii] = 0;
    }
}
Firstly sorry for poor formatting, I don't have a scripting/programming IDE installed to edit it. However your version never worked as in PAWN you cannot NULL an entire block in an array like you can in other languages. The above edit, changes each variable in the array to NULL (0), separately thus allowing you to do this.
Reply
#3

How is it fucking up your whole gamemode? Error messages?
Reply
#4

Same error with crashdetect.

Array index out of bounds. It fucks my gamemode up by resetting all my business and house files and sets everything to 0. Also I get that error message I wrote above in OnGameModeInit. (where this code is)
Reply
#5

Quote:
Originally Posted by Chrillzen
Посмотреть сообщение
Same error with crashdetect.

Array index out of bounds.
This error is caused by you trying to change a memory address that doesn't exist example:

You have defined "Windows[3]", and then used...

pawn Код:
Windows[0]
Windows[1]
Windows[2]
Windows[3] // Doesn't exist.
This I can't imagine being a problem with the Windows code, as this essentially is a set number... you cannot unknowling exceed it unless you mis count.

EDIT: In your loop i = 1? Why? This could cause it depending on what MAX_WINDOWSis set at. Memory/Arrays begin at 0, and work up.

EDIT 2: Infact your orignal code would cause this... because your changing variable ID 4 MAX_WINDOWS. Which the max number is 3, including 0. THe code I posted shouldn't cause this.
Reply
#6

Thanks bro! MAX_WINDOWS was set to 5.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)