24.03.2019, 17:35
Ok so, i have almost 50 admin commands and i'm planning to add more. Since most of them (i'd say 99%), have some basilar checks, this to be clear:
I was thinking, it's possible to create a function that has this checks and return error messages in case?
I mean something like: BasicPlayerChecks(id);
Then in the command, imagine i type an invalid playername/id, it will return: "Invalid playername/id" calling the id == INVALID_PLAYER_ID check.
How? Hope i've been clear.
pawn Code:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player is not connected.");
if(id == playerid) returnSendClientMessage(playerid, -1, "You can't use this command on yourself.");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid playername/id.");
I mean something like: BasicPlayerChecks(id);
Then in the command, imagine i type an invalid playername/id, it will return: "Invalid playername/id" calling the id == INVALID_PLAYER_ID check.
How? Hope i've been clear.