help :) -
Anwix - 24.04.2009
ok , i've searched but nothings what i really wanted or most of this is todo with CMDTEXT ones.
Im using DCMD and atempting to create "/kick [playerid] [reason]"
Код:
dcmd_kick(playerid, params[])
{
new tmp[256],tmp2[256],Index;
tmp = strtok(params,Index);
tmp2 = strtok(params,Index);
new otherid = strval(tmp);
new reason = strval(tmp2);
if (dini_Int(GetPlayerPath(playerid), "admin") >= 3)
{
if (IsPlayerConnected(otherid))
{
if (strlen(tmp) && strlen(tmp2))
{
new player[MAX_PLAYER_NAME];
new admin[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, player, sizeof(player));
GetPlayerName(playerid, admin, sizeof(admin));
format(string, sizeof(string), "Administrator %s kicked %s (Reason: %d)", admin, player, reason);
SendClientMessageToAll(COLOR_WHITE, string);
Kick(otherid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "[USAGE] : /kick [playerid] [reason]");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "That player is not online!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You dont have permission to access this command!");
return 1;
}
return 1;
}
Once using the command it displys : "Administrator Aaron has kicked Guest (Reason: 0)"
0 would be the Guest's ID.
i dont know how to get this to display my reason.
Someone be kind and help
Re: help :) -
Joe Staff - 24.04.2009
Because you have reason being a number.
Remove "new reason = strval(tmp2);"
Change
format(string, sizeof(string), "Administrator %s kicked %s (Reason: %d)", admin, player, reason);
to
format(string, sizeof(string), "Administrator %s kicked %s (Reason: %s)", admin, player, params);
and why are you using strtok AND dcmd?
Re: help :) -
Anwix - 24.04.2009
displays nothing :S
im really confused XD
Re: help :) -
Backwardsman97 - 25.04.2009
Use sscanf.
pawn Код:
dcmd_kick(playerid, params[])
{
new otherid, reason[128];
if(sscanf(params,"ds",otherid,reason))
{
SendClientMessage(playerid, COLOR_WHITE, "[USAGE] : /kick [playerid] [reason]");
return 1;
}
if(dini_Int(GetPlayerPath(playerid), "admin") < 3)
{
SendClientMessage(playerid, COLOR_WHITE, "You dont have permission to access this command!");
return 1;
}
if(!IsPlayerConnected(otherid))
{
SendClientMessage(playerid, COLOR_WHITE, "That player is not online!");
return 1;
}
new player[24],admin[24],string[128];
GetPlayerName(otherid, player, 24);
GetPlayerName(playerid, admin, 24);
format(string, 128, "Administrator %s kicked %s (Reason: %s)", admin, player, reason);
SendClientMessageToAll(COLOR_WHITE, string);
Kick(otherid);
return 1;
}
Makes it much easier and less code.
Re: help :) -
Anwix - 25.04.2009
error 017: undefined symbol "sscanf"