ACS Strings
ACS Strings
I was talking about perhaps adding an ACS function called getname() to the Skulltag/Zdoom ACS which would return the name of the player so you could assign it to a variable earlier in the Skulltag forums.
I was thinking something along the lines of
playername = getname()
However I was informed that ACS doesn't support dynamic strings making this type of function impossible even though in print statements you can use n:0 to refer to the player who activated the script. I was just wondering if this was true or not. Would something like this really be virtually impossible to implement? (Without making *serious* changes to the way ACS works)
Would a hackish solution be possible so that a statement like this would work?
playername = n:0
I'm just curious and looking for confirmation is all as this is something I'd really like to harass somebody into adding eventually and it'd be a bit depressing if it's not at all possible.
I was thinking something along the lines of
playername = getname()
However I was informed that ACS doesn't support dynamic strings making this type of function impossible even though in print statements you can use n:0 to refer to the player who activated the script. I was just wondering if this was true or not. Would something like this really be virtually impossible to implement? (Without making *serious* changes to the way ACS works)
Would a hackish solution be possible so that a statement like this would work?
playername = n:0
I'm just curious and looking for confirmation is all as this is something I'd really like to harass somebody into adding eventually and it'd be a bit depressing if it's not at all possible.
I may be mistaken, but n:<someNumberHere> should let you print any given player's name. In fact, I'm really pretty confident it should because off the top of my head I'm remembering HotWax's Catch the Chicken score board, which did make use of the player's names.
In essence you really shouldn't need any more. The only thing you can do with strings in ACS is output them or pass them to functions that take them specifically (and none of those would have anything useful to do with a player's name.) Is there some specific reason you want to be storing a player's name in a variable? I'm pretty confident that anything you want to get done by storing a player name in a variable could easily be done in an alternate fashion without it.
In essence you really shouldn't need any more. The only thing you can do with strings in ACS is output them or pass them to functions that take them specifically (and none of those would have anything useful to do with a player's name.) Is there some specific reason you want to be storing a player's name in a variable? I'm pretty confident that anything you want to get done by storing a player name in a variable could easily be done in an alternate fashion without it.
Zippy: He knows that.
aabra: Confirmation you shall have!
http://forum.zdoom.org/potato.php?p=217333
aabra: Confirmation you shall have!
http://forum.zdoom.org/potato.php?p=217333
Well, I was asked this by someone who wanted to add a 'high scores' list to his wad. The only thing I could tell him was if the player got a high score - teleport him to another room and have him enter his 3 initials ala oldschool arcade style.
This however doesn't permit the user to have his complete name and is really a bit of a meh solution. It'd be nice if you could save a player's name to a variable somehow and then spew it out later. Say a player connected to a server and as he entered it would say "Current Champion is Doogie Howser" or whatever. (But Doogie Howser of course had long since left the server.) I think that'd be neat.
Any ideas on how to do something like this?
This however doesn't permit the user to have his complete name and is really a bit of a meh solution. It'd be nice if you could save a player's name to a variable somehow and then spew it out later. Say a player connected to a server and as he entered it would say "Current Champion is Doogie Howser" or whatever. (But Doogie Howser of course had long since left the server.) I think that'd be neat.
Any ideas on how to do something like this?
Something based on this should work:
Code: Select all
#include "zcommon.acs"
int score[8] = {0,0,0,0,0,0,0,0}; //stores the score
script 1 void
{
//who is the highest?
int high = 0;
for(int i = 0; i<8; i++) if(score[high] < score[i]) high = i;
//print the highest
printbold(n: high+1, s:" has the highest score");
}
Last edited by Necromage on Fri Sep 28, 2007 12:20 pm, edited 2 times in total.
As long as you store the champion's name in a global or map variable, the name should stay there until you replace it with something else.
ALINV's last map, Seriously Unrealistic Quake prints out the name of the player who finds the BFG10K secret.
DTINV's last map also prints the name of the player who tries to bypass a certain force field in the later stages of the invasion.
ALINV's last map, Seriously Unrealistic Quake prints out the name of the player who finds the BFG10K secret.
DTINV's last map also prints the name of the player who tries to bypass a certain force field in the later stages of the invasion.
Yeah, but imagine in a game player 8 (which we will call Some Dude) gets the high score early on.
The script says that Some Dude has the highest score.
Happy at his victory, Some Dude leaves the game as he has some work to do.
Now, the slot is free. What does the script say? Maybe it retains the last name. But let say that now that a slot is free, the game is joined by Random Chump, who becomes the new player 8. What happens?
I think the script will say that Random Chump has the highest score.
The script says that Some Dude has the highest score.
Happy at his victory, Some Dude leaves the game as he has some work to do.
Now, the slot is free. What does the script say? Maybe it retains the last name. But let say that now that a slot is free, the game is joined by Random Chump, who becomes the new player 8. What happens?
I think the script will say that Random Chump has the highest score.
- MartinHowe
- Posts: 2078
- Joined: Mon Aug 11, 2003 1:50 pm
- Preferred Pronouns: He/Him
- Location: East Suffolk (UK)
There's nothing theoretically impossible about adding strings to ACS, but the only way to do it without turning ACS into a whole new language would be to allow the internal string table to grow (and maybe shrink, though not below its initial size, since the literal strings in the script must be final) and use a C style strings.h lookalike with unique string IDs instead of pointers.
Lack of time and lots of other things to do prevents me, and I suspect other coders, from actually having a go at doing this.
Lack of time and lots of other things to do prevents me, and I suspect other coders, from actually having a go at doing this.
All you need to do is check if the player is in the game with [wiki]PlayerInGame[/wiki]. Then you can change this:aabra wrote:That will work even if the player is no longer connected?
I'll need to test that.
Code: Select all
for(int i = 0; i<8; i++) if(score[high] < score[i]) high = i;
Code: Select all
for(int i = 0; i<8; i++) if(PlayerInGame(i)) if(score[high] < score[i]) high = i;
Not quite:Risen wrote:Zippy: He knows that.
which is quite a bit different that being able to access any player's name in a Print/HudMessage statement by their fixed numbers.aabra wrote:However I was informed that ACS doesn't support dynamic strings making this type of function impossible even though in print statements you can use n:0 to refer to the player who activated the script.