Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Shovon^ on Sep 29, 2016, 10:05 AM

Title: Player.name help
Post by: Shovon^ on Sep 29, 2016, 10:05 AM
I want a help about this
if ( player.name !== Shovon^ )   MessagePlayer("u r not authorized ",player); Now I want this to be two or more names how do I do it??
Title: Re: Player.name help
Post by: Anik on Sep 29, 2016, 10:11 AM
@Shovon^ the thing you are doing is going to give error. Your name needs to be a string. and its player.Name not player.name.
Use like this
example:
if ( player.Name != "Shovon^" ||  player.Name != "[DS]Anik" ||  player.Name != "Anik" ||  player.Name != "Another_name_here" ||  player.Name != "Just_repeat_like_this")   MessagePlayer("u r not authorized ",player);
Title: Re: Player.name help
Post by: Shovon^ on Sep 29, 2016, 12:10 PM
Thnx Anik my problem solved
Title: Re: Player.name help
Post by: KAKAN on Sep 29, 2016, 01:19 PM
Another problem is that you were using !== mark teh 2nd =, in JS, it is an alias for equality check In squirrel, idk what it does.
:edit: Thanks to Thijn, I've corrected it. In squirrel too, it does the same.
Title: Re: Player.name help
Post by: Kewun on Sep 29, 2016, 02:00 PM
you shouldnt be using if player.Name security
what if someone joins as your nick and uses your commands
Title: Re: Player.name help
Post by: Cool on Sep 29, 2016, 02:06 PM
Quote from: Kewun on Sep 29, 2016, 02:00 PMyou shouldnt be using if player.Name security
what if someone joins as your nick and uses your commands
Wrong every server has security no server allow cmd using if he is not login
Title: Re: Player.name help
Post by: Kewun on Sep 29, 2016, 02:11 PM
Did not understand your english but i think you do not know what i mean.
Title: Re: Player.name help
Post by: KAKAN on Sep 29, 2016, 04:17 PM
Quote from: Kewun on Sep 29, 2016, 02:11 PMDid not understand your english but i think you do not know what i mean.
Two players can't join with the same nick. And don't you think he would have something to do? Like changing the name...
Title: Re: Player.name help
Post by: Kewun on Sep 29, 2016, 04:28 PM
but i mean when he leaves the server, other troll can join with his name, and troll plrs
Title: Re: Player.name help
Post by: Thijn on Sep 29, 2016, 04:38 PM
Quote from: KAKAN on Sep 29, 2016, 01:19 PMAnother problem is that you were using !== mark teh 2nd =, in JS, it is an alias for instanceof. In squirrel, idk what it does.
!== most certainly does not mean instanceof in any language, including JS.

For weakly typed (https://en.wikipedia.org/wiki/Strong_and_weak_typing) languages (like JS and squirrel, but also PHP) the === operator means equal value AND equal type.

For example:
if ( "1" == 1 ) will return true
if ( "1" === 1) will return false, since the type (string vs int) does not match.
Title: Re: Player.name help
Post by: KAKAN on Sep 29, 2016, 05:17 PM
Quote from: Thijn on Sep 29, 2016, 04:38 PM
Quote from: KAKAN on Sep 29, 2016, 01:19 PMAnother problem is that you were using !== mark teh 2nd =, in JS, it is an alias for instanceof. In squirrel, idk what it does.
!== most certainly does not mean instanceof in any language, including JS.
Oh yeah, I forgot, it was something like equality check :D
But, still then do you think someone would care for it (http://forum.vc-mp.org/?topic=3766.msg28230#msg28230)?