It's quite alright, here, i'll give you an example.. Say you wanted to just send a message to everyone saying that someone has typed a command.
(Note: I use ZCMD, as you're a beginner, you probably made your command using OnPlayerCommandText, but it's still the base that counts.)
Correct:
pawn Code:
zcmd(test, playerid, params[])
{
new string[128];
new name;
GetPlayerName(playerid, name, sizeof(name));
SendClientMessageToAll(playerid, white, "%s has typed \"/TEST\"!", name); // The \" is used to make Quotation marks in-game, as using just " " would close your SendClientMessage.
return 1;
}
Incorrect:
pawn Code:
zcmd(test, playerid, params[])
{
new string[256];
new name;
GetPlayerName(playerid, name, sizeof(name));
SendClientMessageToAll(playerid, white, "%s has typed \"/TEST\"!", name);
return 1;
}
As i don't think you would need 256 cells in order to just tell everyone that someone has typed a command.
Also, consider breaking away from Strtok, and things like that, ZCMD and DCMD are the most effecient commands, and they're also very very powerful.
Example:
/SetHP using STRTOK = 19 Lines:
pawn Code:
if(strcmp(cmd, "/sethealth", true)==0||strcmp(cmd, "/sethp", true)==0)
{
new varhp;
tmp=strtok(cmdtext,idx);
if(strlen(tmp)==0) return SendClientMessage(playerid, COLOR_LB, "Syntax: /SetHP <Player ID/Part of Name> <Amount>");
player = ReturnUser(tmp);
tmp=strtok(cmdtext,idx);
if(strlen(tmp)==0) return SendClientMessage(playerid, COLOR_LB, "Syntax: /SetHP <Player ID/Part of Name> <Amount>");
varhp=strval(tmp);
if(player != INVALID_PLAYER_ID)
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
SetPlayerHealth(player, varhp);
}
else return SendClientMessage(playerid, COLOR_RED, "(Error): You're not an administrator! (Error Code: 45)");
}
else return SendClientMessage(playerid, COLOR_RED, "(Error): Player does not exist.");
return 1;
}
/SetHP using ZCMD = 17 Lines.
pawn Code:
zcmd(sethp, playerid, params[])
{
new player,hp;
if(!sscanf(params, "ui", player, hp))
{
if(player != INVALID_PLAYER_ID)
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
SetPlayerHealth(player, hp);
}
else return SendClientMessage(playerid, red, "(Error): You're not an administrator!");
}
else return SendClientMessage(playerid, red, "(Error): Player does not exist.");
}
else return SendClientMessage(playerid, lb, "Syntax: /SetHP <Player ID/Part of Name> <Amount>");
return 1;
}