about strings
#1

hello guys

i have a question..
i saw in ****** guide that strings are NOT global or static stored in stack

so, when i create a global variables where they stored?

and what is better:
1. use a global variable and everytime that il send message or dialog to player il use the string
2. create the string everytime before i sebd nesssage or dialog
and why??

thanks for all helpers
Reply
#2

Well it depends on how long your client message is, so I prefer you make a new string when you need it, you don't always use strings.
and for dialogs, they are already dialog, but for variables for personal player stuff, i prefer [MAX_PLAYERS], but golbal are for all players for example "time to rob 24/7 again" etc..

I don't know if I got you correctly..
Reply
#3

Quote:
Originally Posted by Vanter
Посмотреть сообщение
Well it depends on how long your client message is, so I prefer you make a new string when you need it, you don't always use strings.
and for dialogs, they are already dialog, but for variables for personal player stuff, i prefer [MAX_PLAYERS], but golbal are for all players for example "time to rob 24/7 again" etc..

I don't know if I got you correctly..
amm are you sure i need to create string every time i need it?
are you sure its ok?
i mean if il create a commands and i need string il create string and if i need it for some dialog so il create another string..

then will be alot of "new string[..]" in my mode
Reply
#4

Yes it's okay, everyone makes a new string in there commands.

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 54 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 32 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 12 seconds.
Reply
#5

Quote:
Originally Posted by Vanter
Посмотреть сообщение
Yes it's okay, everyone makes a new string in there commands.

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 54 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 32 seconds.
This forum requires that you wait 120 seconds between posts. Please try again in 12 seconds.
ok but can you tell me the reason why its better then just create one string in the top of the mode?
Reply
#6

I am not aware of any advantage, though it reduces the chances of inadvertently overwriting data.
Reply
#7

It might mix client messages, and it's extremely risky to use one string for ALL your gamemode.
and don't make too many high strings, it lags the server
Reply
#8

Quote:
Originally Posted by Vanter
Посмотреть сообщение
it's extremely risky to use one string for ALL your gamemode.
No, it's not. If you only send client messages, I declare one with size 128 and I'm fine.

I had sent a message to ****** about this few months ago and he answered me

Quote:
Originally Posted by ******
I go for method 1 all the time, simply because then there's no chance of subtle bugs. However, if you do go for method 2 make sure you name it something like "gString" instead of just "string" to make it clear that it's a global variable. There is also method 3 which uses "static" locals instead. They all have advantages and disadvantages.
The first method was to declare a string locally, the second way was globally.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
No, it's not. If you only send client messages, I declare one with size 128 and I'm fine.

I had sent a message to ****** about this few months ago and he answered me



The first method was to declare a string locally, the second way was globally.
hello but im using my string not only for client message.. im using this string alot
so its still risky?

amm what you advice to me./?
Reply
#10

I would create a string locally, and basically I do.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)