Post: Converting self to player and comparing strings
08-10-2015, 03:25 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Ok so i know a bit of java and c# and was wondering how you compare strings in a gsc. I tried player.name.equals("gamertag") im assuming that player.name is a string btw. Also how would you convert a self into a player or check if it is a player kinda like what you do with a host menu with if(self isHost())

I want the end result to be
if(self isGamertag("gamertag"))
or anything that achieves the same result. Thanks for any help Happy
(adsbygoogle = window.adsbygoogle || []).push({});
08-10-2015, 03:49 AM #2
EternalHabit
Former Staff
Originally posted by 15987632 View Post
Ok so i know a bit of java and c# and was wondering how you compare strings in a gsc. I tried player.name.equals("gamertag") im assuming that player.name is a string btw. Also how would you convert a self into a player or check if it is a player kinda like what you do with a host menu with if(self isHost())

I want the end result to be
if(self isGamertag("gamertag"))
or anything that achieves the same result. Thanks for any help Happy

For a certain player

Foreach(player in level.players)
If(player.name == "gamertag")

For yourself or self

If(self.name == "gamertag")
08-10-2015, 04:03 AM #3
Originally posted by xTurntUpLobbies View Post
For a certain player

Foreach(player in level.players)
If(player.name == "gamertag")

For yourself or self

If(self.name == "gamertag")

I dont think that works for strings as it doesnt in most languages and i already tried it and it gave what i tried to give myself to every player
08-10-2015, 04:45 AM #4
itsSorrow
In my man cave
Originally posted by 15987632 View Post
I dont think that works for strings as it doesnt in most languages and i already tried it and it gave what i tried to give myself to every player


that works..
08-10-2015, 06:59 AM #5
Originally posted by GentleSlugger View Post
that works..


kk i will try again :/
08-10-2015, 12:07 PM #6
dtx12
Do a barrel roll!
In gsc strings compared by their references, but unlike java this comparison is safe to use, because VM is always trying to reuse existing string. Currently I can't imagine case where this comparison may give a wrong result. Although I don't understand why you're thinking that gsc is a copy of java :/

The following user thanked dtx12 for this useful post:

itsSorrow
08-10-2015, 06:02 PM #7
itsSorrow
In my man cave
Originally posted by dtx12 View Post
Unlike java == operator actually compares strings, not their references. Although I don't understand why you're thinking that gsc is a copy of java :/


One of the GSC Gods responded

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo