gms_self_name

Usage: gms_self_name ( )

Description

Returns the player's name. To obtain other player's names, you should use server_other_get_string(player_id, "name")

Replies (21)

Last message on 16 Feb 2022

Bluecore on 29 Jul 2016, 22:16:38
server_other_get_string(player_id, "name") is no longer a function. Someone help me out by telling me how I can display other people's names. This is how I am displaying the user's name.

#DRAW EVENT
var PlayerName
PlayerName = gms_self_name();
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_font(EightBitOperatorJVE);
draw_text_ext_colour(objPlayer.x+9,objPlayer.y-10,PlayerName,10,200,c_white,c_white,c_white,c_white,1);

However, I'm not sure how to make it so other people's names float on top of their players.
amkgames on 31 Jul 2016, 08:30:23
Try gms_other_get_string(player_id, "name") instead.
Bluecore on 31 Jul 2016, 18:06:34
I'm not actually sure how to use that piece of code. Where do I find the player_id? How do I know which player goes with which objectOtherPlayer? Can you write out the code for me because I do not understand how it works.
amkgames on 1 Aug 2016, 10:25:02
gms_other_get_string(player_id, "name") is to get name of other player, I use it to draw other players' name on their head.
I use it something like this:
//Draw Event of obj_other_player
draw_text(x, y-18gms_other_get_string(player_id, "name"));
Bluecore on 7 Aug 2016, 08:45:14
Sorry for the late reply, wasn't able to try this out until now.

Okay this code does work, however, using the draw event on obj_other_player makes the sprites for the other player invisible even though their name does show up. What can I do about this?
amkgames on 7 Aug 2016, 09:16:10
If you are using Game Maker: Studio or Game Maker 8.1 then put this code before the above one.
draw_self();

If you are using Game Maker 8 then put this code:
draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);
Bluecore on 7 Aug 2016, 09:28:55
Thank you so much Amkgames for all of the help! You are a lifesaver.
amkgames on 7 Aug 2016, 09:31:01
It was nothing. :)
Bluecore on 12 Aug 2016, 00:31:56
Sorry to bringing this thread up again, but I've just notice that when there are three people in the same room. One player gets two names layed on top of each other. While the other player has no name. Any fix for this?

Draw Event Of objPlayerOther:
draw_self();
var PlayerName
PlayerName = gms_other_get_string(player_id, "name");
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_font(EightBitOperatorJVE);
draw_text_ext_colour(objPlayerOther.x+9,objPlayerOther.y-10,PlayerName,10,200,c_white,c_white,c_white,c_white,1);
R3styn on 8 Jun 2019, 16:13:17
I want the server to select random at the beginning of the game
a player who gets a "hot potato" and that player explodes after 120 seconds
My project file:http://www.mediafire.com/file/5u99oxrqvhxhpx4/TNT_Tag.zip/file
amkgames on 12 Aug 2016, 06:04:24
You don't need to use objPlayerOther.x+9 and objPlayerOther.y-10, since it's same object.
Just use x+9 and y-10.
Bluecore on 12 Aug 2016, 06:19:37
You saved me again! Thank you so much AMK! You rock!
amkgames on 12 Aug 2016, 06:20:36
No problem! :)
M4RC0S on 16 Feb 2022, 19:23:11
How do I convert a player's name to a string?
Because I want to remove the "Guest_" to turn it into "Player" and then put the name
Bluecore on 16 Feb 2022, 19:28:42
Both gms_self_name() and gms_other_get_string(player_id, "name") are returns as strings, you don't need to convert it. Any function that requires a string to work, you can use these in. For example: draw_text(16, 16, gms_self_name());
BabyGolden12 on 20 Mar 2020, 06:44:26
say i wanted to make a text say a player name how would this work
Bluecore on 20 Mar 2020, 08:05:47
var playername = gms_self_name();
draw_text(16, 16, playername);
BabyGolden12 on 20 Mar 2020, 22:02:40
Thank you but i should have said How Would I other player name like say Player challenge P2 im not reall good with the pvp script sorry :D
Bluecore on 20 Mar 2020, 22:20:25
var playerothername = gms_other_get_string(player_id, "name");
draw_text(16, 16, playerothername);
NSXdev on 28 Apr 2019, 14:02:06
Hey, so can i use this like this gms_self_name(playername,playername1)?
Bluecore on 28 Apr 2019, 14:13:44
gms_self_name doesn't take any arguments. It just returns the name of the user currently playing your game. If you want the names of the other players on the server, you should use server_other_get_string(player_id, "name")