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



Windows - Chrillzen - 12.10.2014

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?


Re: Windows - IceCube! - 12.10.2014

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.


Re: Windows - VitalRP - 12.10.2014

How is it fucking up your whole gamemode? Error messages?


Re: Windows - Chrillzen - 12.10.2014

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)


Re: Windows - IceCube! - 12.10.2014

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.


Re: Windows - Chrillzen - 12.10.2014

Thanks bro! MAX_WINDOWS was set to 5.