[PEDIDO] Comando para da Respawn em todos os carros
#10

Quote:
Originally Posted by Shadoww5
Посмотреть сообщение
1 - O que й isso: if(~InVeh == -1) ?

2 - Qual a diferenзa de static e new ?

3 - O correto nгo seria static inVeh[MAX_VEHICLES]; ?
Static й uma variбvel STATICA, ou seja, vocк nгo pode modificar, й um valor.
News sгo acopladas na memуria dinвmica.., Dynamic Memory Allocation

Variбveis static's sгo acopladas na memуria estatica, Static Memory Allocation

Quote:
Originally Posted by REI_DO_SAMP_SR_Y_LESS
I think I'll clarify a bit here, as those definitions were a little bit off. In a script you have global memory and stack/heap memory. The global memory is where all your global variables are stored, as they're not different in different functions. This memory is actually included into the .amx, which is why a tiny .pwn can produce a huge .amx. The stack and heap are allocated when you execute the script and store function local variables, this is because a function can call itself, so you need two copies of the same variable - if they were global they would be the same variable.

Local static variables are essentially global variables, but you can only use them in one function. If you decompile a .amx with static locals you will see them listed as globals - them being limited to one function is purely a compiler restriction, there's actually nothing in the VM itself to enforce this.

A const variable is not variable, it is just like a macro in that it always has the same value - it's just useful for defining things.

A global static variable is limited to only being used in the file in which it's declared (technically section, a file can have multiple sections, but a section can't have multiple files and the default is one section per file). These are used extensively through YSI to hide implementation details from people and stop them breaking things. But again, this is purely a compiler restriction.

Edit: You said you've been told 201 times, but it's clearly not sunk in yet, so I'm telling you a 202nd time: Don't use 256 for command variables, it's entirely pointless and a waste, the effects of which you are clearly seeing in your code or you wouldn't be getting heap space overflows when you compile.

I'm also going to tell you to use zcmd and sscanf - you say that you use those variables in almost every command, you'll use them in next to none if you bother to code properly, plus your code will be faster and more secure.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)