Strings
#1

Hi! I'm somewhat new at scripting and I do not know very much. I know nice sort of things in dialogs and commands but the thing I don't understand almost at all is strings.

There are some ID's of strings, aren't there? like string[254] etc etc. Can someone explain how strings work and what are they used for?
Reply
#2

The number in the square brackets is the size of the string. With 254, it can hold up to 253 characters + NULL.
For more read:
https://sampwiki.blast.hk/wiki/Scripting_Basics#Strings
https://sampforum.blast.hk/showthread.php?tid=284112
Reply
#3

Strings are sequence of characters in a sentence/word. For example:

Hello My Name is Rittik -is an example of String.Each letter used in this sentence is know as characters.

letters from 'A-Z' , '0-9', and some special characters like '.' , ',', '*' etc. -is an example of Character.
Reply
#4

Holy moly in a dolly ****** replied
Reply
#5

Strings work like this:

Say that you want to make a DIALOG that says Welcome back to the server (Playername).

What you're going to do is:

Код:
new string[128], name[MAX_PLAYER_NAME];

GetPlayerName(playerid, name, sizeof(name));

format(string, sizeof(string), "Welcome back to the server, %s", name);

ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Server Name", str, "Login", "Cancel");
Make sure you always use [128] as your string because using [256] or any long length is just waste of memory.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)