SA-MP Forums Archive
Is it possible.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Is it possible.. (/showthread.php?tid=111912)



Is it possible.. - Luka P. - 04.12.2009

.. to create a formatted variable (new).

I want to write something like
pawn Код:
format(pName,128,"%s",ReturnName(playerid));
new pName;
and compiler should understand it as
pawn Код:
new Firstname_Lastname;



Re: Is it possible.. - Zamaroht - 04.12.2009

I'm not sure, maybe it's possible using preprocessor, but I'm still not sure...
Anyway, in these kind of cases it's always a good option to use arrays and enums.


Re: Is it possible.. - RaFsTar - 04.12.2009

new PFirstName[MAX_PLAYER_NAME];
new PLastName[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];

format(name,sizeof(name),"%s_%s",PFirstName,PLastN ame);

SetPlayerName(playerid,name);


Make your changes depending on your saving sys !


Re: Is it possible.. - Luka P. - 04.12.2009

Quote:
Originally Posted by RaFsTar[PT
]
new PFirstName[MAX_PLAYER_NAME];
new PLastName[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];

format(name,sizeof(name),"%s_%s",PFirstName,PLastN ame);

SetPlayerName(playerid,name);


Make your changes depending on your saving sys !
You probably don't get the point of this.
I don't want to do Firstname_Lastname, it's just example.


Re: Is it possible.. - RaFsTar - 05.12.2009

Quote:
Originally Posted by Luka™
Quote:
Originally Posted by RaFsTar[PT
]
new PFirstName[MAX_PLAYER_NAME];
new PLastName[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];

format(name,sizeof(name),"%s_%s",PFirstName,PLastN ame);

SetPlayerName(playerid,name);


Make your changes depending on your saving sys !
You probably don't get the point of this.
I don't want to do Firstname_Lastname, it's just example.
Nobody got the "point" you want ..


Re: Is it possible.. - Luka P. - 05.12.2009

Quote:
Originally Posted by RaFsTar[PT
]
Quote:
Originally Posted by Luka™
Quote:
Originally Posted by RaFsTar[PT
]
new PFirstName[MAX_PLAYER_NAME];
new PLastName[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];

format(name,sizeof(name),"%s_%s",PFirstName,PLastN ame);

SetPlayerName(playerid,name);


Make your changes depending on your saving sys !
You probably don't get the point of this.
I don't want to do Firstname_Lastname, it's just example.
Nobody got the "point" you want ..
Really, Zamaroth answer in 3 minutes... I think he get the point..
But you probably don't know what means formatted, variable, and other shit
Don't be too smart


Re: Is it possible.. - KnooL - 05.12.2009

new pName gets replaced and will be seen as new realplayername what is so hard to understand by that?

Sorry, but I'm not experienced in this, just wanted to post the thing above.


Re: Is it possible.. - MenaceX^ - 05.12.2009

Quote:
pawn Код:
format(pName,128,"%s",ReturnName(playerid));
new pName;
You can't do this because pName is not an array.


Re: Is it possible.. - Luka P. - 05.12.2009

Quote:
Originally Posted by KnooL
new pName gets replaced and will be seen as new realplayername what is so hard to understand by that?

Sorry, but I'm not experienced in this, just wanted to post the thing above.
Yeah, true. pName is just example, I was asking if is possible to create a formatted variable (so it should work like a macro).

EDIT: MenaceX, I know it isn't possible by doing
pawn Код:
format(pName,128,"%s",ReturnName(playerid));
new pName;
But I'm asking if there is any way to do it.


Re: Is it possible.. - Google63 - 05.12.2009

It isn't because variable is just readable reference to memory location where data is. You can get variable as value or as reference.


Re: Is it possible.. - Luka P. - 05.12.2009

Quote:
Originally Posted by JoeBullet
It isn't because variable is just readable reference to memory location where data is. You can get variable as value or as reference.
Okay, thanks