How to do this in PAWN
#1

My main programming language is C# and i was able to do this
pawn Код:
string Name = "Healian";
int Age = 25;

Console.WriteLine("Player name = {0} and Age = {1}", FirstName, Age);
__________________________

So now i want to do this in ShowDialog in SAMP i want to define 2 strings and use them like this

pawn Код:
ShowPlayerDialog(playerid, 9647, DIALOG_STYLE_MSGBOX, "Welcome", "Player name = THENAME and AGE THEAGE", "Close", "");
THENAME and THEAGE will be retrieved from variables

and if also want to know how to do this with more or less 2 than variable
Reply
#2

Quote:
Originally Posted by Healian
Посмотреть сообщение
My main programming language is C# and i was able to do this
pawn Код:
string Name = "Healian";
int Age = 25;

Console.WriteLine("Player name = {0} and Age = {1}", FirstName, Age);
__________________________

So now i want to do this in ShowDialog in SAMP i want to define 2 strings and use them like this

pawn Код:
ShowPlayerDialog(playerid, 9647, DIALOG_STYLE_MSGBOX, "Welcome", "Player name = THENAME and AGE THEAGE", "Close", "");
THENAME and THEAGE will be retrieved from variables

and if also want to know how to do this with more or less 2 than variable
Hmm, you can do like this:


pawn Код:
new szStr[ 80 ]; // declaring new variable

new Age = 10, // integer
    Name[ 24 ] = "Healian"; // string we are using 24 because max player name limit is 24 or alternatively MAX_PLAYER_NAME

format( szStr, sizeof( szStr ), "Player Name: %s and Age: %i", Name, Age ); // formatting the string according to our need: %s is string %i is integer
ShowPlayerDialog( playerid, 9647, DIALOG_STYLE_MSGBOX, "caption", szStr, "Close", "" ); // putting szStr as a info[]..
Correct me if I am wrong.
Reply
#3

sorry but what is the benefit of szStr is it working as a container for Age and Name or what ?

and if i want the Name variable to be anything like "I LOVE SAMP" what should i use otherwise 24 ?
Reply
#4

Quote:
Originally Posted by Healian
Посмотреть сообщение
sorry but what is the benefit of szStr is it working as a container for Age and Name or what ?
Well, we actually need one string "szStr" for formatting the age and name!

https://sampwiki.blast.hk/wiki/Format
Reply
#5

The szStr is the string for the format.
Reply
#6

ok what about the 24 ? if am doint any other text other than the Playername in normal text how could i determine the 24
Reply
#7

Quote:
Originally Posted by Healian
Посмотреть сообщение
ok what about the 24 ? if am doint any other text other than the Playername in normal text how could i determine the 24
Hmm good question, there are bunch of tools in the forum for counting the chars and even in PAWNO there is a small box in the bottom at right side showing your string/char length.

Anyway here is one of the tool:-

https://sampforum.blast.hk/showthread.php?tid=321776

"I LOVE SAMP" has 11 Col.
Reply
#8

Ok very thanks its working guys

u both have my rep i really appreciate your help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)