SA-MP Forums Archive
How to do this in PAWN - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to do this in PAWN (/showthread.php?tid=367445)



How to do this in PAWN - Healian - 10.08.2012

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


Re: How to do this in PAWN - FalconX - 10.08.2012

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.


Re: How to do this in PAWN - Healian - 10.08.2012

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 ?


Re: How to do this in PAWN - FalconX - 10.08.2012

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


Re: How to do this in PAWN - Kitten - 10.08.2012

The szStr is the string for the format.


Re: How to do this in PAWN - Healian - 10.08.2012

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


Re: How to do this in PAWN - FalconX - 10.08.2012

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.


Re: How to do this in PAWN - Healian - 10.08.2012

Ok very thanks its working guys

u both have my rep i really appreciate your help