One question for strings...
#1

Can we define 1 string on top of the script like this:
new globalstring[2500];
And use it for everything in script?

And is it possible to 2 players receive same message - string, ex:
1. player say /myname, and second say /myages, and both of them receive message for command /myages?(In both command we use this globalstring defined on top of the script)
Reply
#2

You can, but it is not recommended: https://sampforum.blast.hk/showthread.php?tid=491035
Reply
#3

I remember ****** explaining why you shouldn't do that, just can't find the topic.

EDIT: Again.. Didn't reload the page, sorry.
Reply
#4

Thank you, but is it recommended to use global string for strings that are same for all players, like rules?
Reply
#5

Yes you can do that , it makes it a lot easier to change such messages but it takes a lil bit more memory since they have an unlimited lifetime , i wouldn't worry about that tho. But if you only need 50 letters only make it as big as you need it to be for 50 letters to fit in and not 2500, ok? ^^
Reply
#6

That's fine I guess, making it also const. Another possibility is to use static local as well.
Reply
#7

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Yes you can do that , it makes it a lot easier to change such messages but it takes a lil bit more memory since they have an unlimited lifetime , i wouldn't worry about that tho. But if you only need 50 letters only make it as big as you need it to be for 50 letters to fit in and not 2500, ok? ^^
Server rules using 2000

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That's fine I guess, making it also const. Another possibility is to use static local as well.
Can you give me ex for that const and static local?
Reply
#8

Constant:
PHP код:
new const
    
CONSTANT_NUMBER 
static:
PHP код:
static
    
staticVar 10
Reply
#9

pawn Код:
// global:
new const Rules[] = "... ... ...";
and
pawn Код:
// in a function:
static Rules[] = "... ... ...";
Reply
#10

Wait wait wait, if we have this rules:
(DM)Deathmatching:
Deathmatching means that you kill someone without a valid IC reason.
How to avoid Deathmatching: Have a good reason if you want to attack someone. Also RP with the person first or it will be KoS(explained below)
(MG)Metagaming:
Metagaming is using the information gained OOCly to influence an IC Situation
How to avoid metagaming: Don't use "lol","rofl","lmao" or any other internet shortcuts in IC Chat. (Normal Chat). To use those; type /b [text] and write them. Also if you'd like to talk in other Languages, other than English, Feel free to talk in /b.

And in global, i need to write:
Код:
new const Rules[] = "(DM)Deathmatching- Deathmatching means that you kill someone without a valid IC reason.
(MG)Metagaming: - Metagaming is using the information gained OOCly to influence an IC Situation"
or how?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)