03.01.2017, 08:45
as the title says my command is not working properly.
i had added hours as 3rd part but that is not working it is coming as reason
i had added hours as 3rd part but that is not working it is coming as reason
PHP код:
if(strcmp(cmd, "/ban", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /ban (id/name) hours (reason)");
return 1;
}
new giveplayerid;
new len;
giveplayerid = ReturnUser(tmp);
len = strvalEx(tmp);
if(IsPlayerNPC(giveplayerid)) return 1;
if(PInfo[playerid][AdminLevel] >= 1)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[156];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /ban (id/name) (reason)");
return 1;
}
new date,month,year;
getdate(date,month,year);
new hour,minute,second;
gettime(hour,minute,second);
format(string, sizeof(string), "Administrator %s has banned %s due to %s",PlayerName(playerid), PlayerName(giveplayerid), (result));
SendClientMessageToAll(COLOR_WHITE, string);
PInfo[giveplayerid][Banned] = len;
GettingBanned[giveplayerid] = 1;
new Name[MAX_PLAYER_NAME];
new plrIP[25];
new query[256];
//new date2[128];
//format(date2, sizeof(date2), "%d/%d/%d", year,month,date);
GetPlayerName(giveplayerid,Name,sizeof(Name));
GetPlayerName(playerid,sendername,sizeof(sendername));
GetPlayerIp(giveplayerid, plrIP, sizeof(plrIP));
mysql_real_escape_string(Name,Name);
mysql_real_escape_string((result),(result));
mysql_real_escape_string(sendername,sendername);
mysql_real_escape_string(plrIP,plrIP);
format(query,sizeof(query),"INSERT INTO `bans` (Username, Reason, Administrator, IP, Date, Time) VALUES ('%s','%s','%s','%s','%d/%d/%d','%d:%d:%d')",Name,(result),sendername,plrIP,year,month,date,hour,minute,second);
mysql_reconnect();
mysql_query(query);
AdminLog(playerid, "/ban", (result), Name);
Kick(giveplayerid);
return 1;
}
}
else
{
format(string, sizeof(string), "Could not find player (%d)", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
}
}
return 1;
}
return SendClientMessage(playerid, COLOR_ERROR, "Unknown command, please type /commands for a list of available commands to use.");
}