Okay so with much time I have created it (my way)
I used TMP globally and I found out that the cause was that, so now the command atleast works, but there is one more problem:
I globally defined the GetPlayerName and at the top and the name ID vars etc...so it is like this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
new playername[MAX_PLAYER_NAME];
new pname[18];
new target[18];
new targetid = strval(tmp);
new string[128];
new reason[128];
new ipvar1[16];
new ipvar[16];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(targetid, target, sizeof(target));
and then after the /register and /login commands:
Код:
if(strcmp(cmd, "/kick",true) == 0)
{
if(PlayerInfo[playerid][pAdmin] > 1)
{
new tmp[65];
tmp = strtok(cmdtext, idx);
reason = bigstrtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");
return 1;
}
if(targetid == playerid)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Selecting your Own ID might be messy");
}
else if(IsPlayerConnected(targetid) == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Player is not connected");
}
else
{
GetPlayerIp(playerid, ipvar1, 16);
GetPlayerIp(targetid, ipvar, 16);
format(string, sizeof(string), "%s(%d) has been kicked by administrator %s | Reason: %s", target, targetid, pname, reason);
SendClientMessageToAll(COLOR_YELLOW, string);
format(string, sizeof(string), "You kicked %s", target);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
SendClientMessage(targetid, COLOR_LIGHTRED, "You were kicked!");
printf("%s(%d)[%d] kicked %s(%d)[%d] | Reason: %s", pname, playerid, ipvar1, target, targetid, ipvar, reason);
Kick(targetid);
}
}
}
Don't worry bout the PlayerInfo stuff, I have already defined that etc... I just want to know if there is an easier way to use the GetPlayerName globally without having to type it out all the time. because no there is no TMP to support the above statement..
I also tried defining the variable
Код:
new targetid = strval(tmp);
as
Код:
new targetid = strval(strtok(cmdtext, idx));
but it seems to not work...so..is there any other way to get a globally defined variable in this case?