Closed Dmitriy51 closed 2 years ago
You have to use the "u" specifier instead of the "d" one. Then, instead of checking for !SSCANF_IsConnected(player)
, you can simply use player == INVALID_PLAYER_ID
. "u" automatically checks for invalid names/IDs in the input and puts INVALID_PLAYER_ID
in the required parameter.
If you really want to keep the "d" specifier, so a player name won't be able to be used, the check should probably look like
if(!(0 <= player < MAX_PLAYERS) || !SSCANF_IsConnected(player)) return SendClientMessagef(playerid, red,"|ERROR|: {00FFFF}Player not connected!");
You have to use the "u" specifier instead of the "d" one. Then, instead of checking for
!SSCANF_IsConnected(player)
, you can simply useplayer == INVALID_PLAYER_ID
. "u" automatically checks for invalid names/IDs in the input and putsINVALID_PLAYER_ID
in the required parameter.If you really want to keep the "d" specifier, so a player name won't be able to be used, the check should probably look like
if(!(0 <= player < MAX_PLAYERS) || !SSCANF_IsConnected(player)) return SendClientMessagef(playerid, red,"|ERROR|: {00FFFF}Player not connected!");
thaks
Why are you calling SSCANF_IsConnected
anyway? That's an internal function.
I've now hidden this function completely.
f(sscanf(params, "d", player)) return SendClientMessagef(playerid, red,"|USE|: {333333} /ban |id]"); if(!SSCANF_IsConnected(player)) return SendClientMessagef(playerid, red,"|ERROR|: {00FFFF}Player not connected!");
SSCANF_IsConnected(player) this function crash the server, if (player = -11111111111 or player = 11111111111 )