IsPlayerConnected
#1

Is usefull to use that function (IsPlayerConnected) inside a cmd? I don't find his role. If I type a command, it's pretty logic that I'm online, no?
Reply
#2

Quote:
Originally Posted by Mauricee
Посмотреть сообщение
Is usefull to use that function (IsPlayerConnected) inside a cmd? I don't find his role. If I type a command, it's pretty logic that I'm online, no?
It isn't needed as you said; an offline player can't execute the command
Reply
#3

But why this function is used in all GM's inside the commands?
Reply
#4

I suggest you to use INVALID_PLAYER_ID if you want to check if someone is online. (like if you want to give him admin, you can't give an admin to offline player, right?)
Reply
#5

I have once experienced a 'hack' or cheat of some sort, where there was a player who was apparently not even existent, but he was still speaking through main chat. We couldn't kick him or anything because we had 'IsPlayerConnected' checks in our commands, which kept telling us the player we were trying to kick did not exist. He had no player name, but he was taking up a player id. To this day, I still don't know what he was using, or whether this is even possible any more. I see no harm in having it, but preferably, I would still keep that check.

Rather than having an 'IsPlayerConnected' check in every single command, just put it at the top of your 'OnPlayerCommandText' or 'OnPlayerCommandReceived' (if using zcmd) callbacks.
pawn Код:
if(!IsPlayerConnected(playerid)) return 1;
Reply
#6

It is really an artifact from the days of 0.1b (yes, that old) where, due to a bug, players that were kicked or banned could still execute commands. To this day people are still copying those old commands (mostly Godfather edits) without even the slightest thought to what they're doing or even whether there might be a better version available. I still regularly see "PlayerToPoint" to this day even though IsPlayerInRangeOfPoint was implemented as a native in 0.3a.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)