Dynamic Array
#1

i am in need of creating dynamic arrays in some script of mine and as it is not possible using pawn i tried Malloc plugin witch i found hard to understand (i am dumb ) i need some help from u guys to know how to create an array with a size taken from a variable for example (this is the worst peace of code in life and ignored the rules of coding) :

pawn Код:
new Var = 5;
new Array[Var];
And again i know it is impossible using pawn.
Reply
#2

Use sizeof:
pawn Код:
new Var = 5;
new Array[sizeof(Var)];
Reply
#3

That will just create an array with a size of 1. Pawn does not support dynamic arrays. All array sizes must be known at compile time. sizeof is an operator, not a function. Its values are calculated at compile time.
Reply
#4

first sorry for the delay !@#$% ISP

well thank u all guys but the thing is i am making a grenade launcher that needs to be moved every 0.1 seconds or it will seem weird (it even seems weird with 0.1 secs) and for the grenade object i need its pos every 0.1 secs
so there are 2 ways of doing that (that i know of)
1) creating a timer of 100 as delay and calculate its pos int the timer (and this is really tiring for any pc or server)
2)Creating an array with all the poses of the object an the timer set before will only move it

and there is the problem ... the array size may vary with huge numbers so sometimes i maybe need only 4 poses an other times i may need 100 poses so i am in need of a dynamic array to fulfill that OR another way of coding it.

and ****** the thing is i don't wanna use 4 spaces of an array of 100 ... that's horrible for me and also if many ones are using the grenade launcher at the same time i may need a huge computer memory.
Reply
#5

well when i try it with a lot of players things get messed up so timers take time to function and there is a weird delay and the object just stops for a little then continues moving ... but when i am with a few players things are just fine ... IDK but i think it is caused by the big number of calculations in the timer .

So i would like to know any possible solution for this andd thanks of course ******
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)