[QUESTION] Possible to use 1 variable on 2 uses?
#1

hello guys. im just gonna ask if i can use this without any conflicting on each other,

is it possible to use 1 variable with 2 uses? example

pawn Код:
new cpandpickup;

public OnGameModeInit()
{
cpandpickup = CreateDynamicCP(1352.294677,-1759.066284,13.507812, 1.5, -1, -1, -1, 75.0);
cpandpickup = CreateDynamicPickup(1318, 2, -30.9822,-92.0099,1003.5469, 0);
return
}
is it gonna conflict? i hope anyone could answer my Question " it is going to conflict? "
Reply
#2

Yes it is going to conflict. After that part of code you wont be able to know when player enters the Checkpoint. Maybe the more important thing: you won't be able to destroy the checkpoint.
Reply
#3

here ya go,

pawn Код:
new cpandpickup[2];

public OnGameModeInit()
{
cpandpickup[0] = CreateDynamicCP(1352.294677,-1759.066284,13.507812, 1.5, -1, -1, -1, 75.0);
cpandpickup[1] = CreateDynamicPickup(1318, 2, -30.9822,-92.0099,1003.5469, 0);
return 1;
}
Reply
#4

@ HimSelf i know those, im just asking if its possible so i could use less variables

@Roko_Foko thanks, for the info
Reply
#5

Quote:
Originally Posted by pds2012
Посмотреть сообщение
@ HimSelf i know those, im just asking if its possible so i could use less variables

@Roko_Foko thanks, for the info
Let me explain why it wouldnt work.

Each of those functions return the id of the check point or pickup created, so if you have the variable pie, and assign it to a function, what ever the function returns pie will become, and for later use for manipluation of an item, IE deletion, you requre the id, so if you use the same variable and assign it to a different function the value of pie would change and it would no longer be the value for the other one, thus you couldn't delete it or what ever else by using the variable pie.
Reply
#6

Quote:
Originally Posted by pds2012
Посмотреть сообщение
@ HimSelf i know those, im just asking if its possible so i could use less variables

@Roko_Foko thanks, for the info
HimSelfs example is still better then creating two separate variables because when you make a variables such as
pawn Код:
new
    Object1,
    Object2
;
you are using 64 bits of memory, however with this

pawn Код:
new Object[2];
you are only using 32 bits of memory if I am not mistaken.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)