30.03.2014, 19:54
Hello,
I'm trying to script a teamporary ban system. The player is banned, but he is definitely banned. I would like to ban him for 1, 2, 3 hours for example (I put here 60 to test, basically it would be time*3600).
Here is the command:
And here the TempBanSQL:
thanks !
I'm trying to script a teamporary ban system. The player is banned, but he is definitely banned. I would like to ban him for 1, 2, 3 hours for example (I put here 60 to test, basically it would be time*3600).
Here is the command:
pawn Код:
else if(strcmp(cmd, "/tban", true) == 0)
{
new tmpStr[64];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{ SendClientMessage(playerid, COLOR_USAGE, "{FF6600}[Action]{99EEFF} /tban [ID] [Raison] [heures]"); return 1;}
giveplayerid = ReturnUser(tmp);
tmpStr = strtok(cmdtext, idx);
new time;
time = strval(tmpStr);
if (!pack_isAdmin(playerid, 3))
{SendClientMessage(playerid, COLOR_SERVER, noAcces); return 1;}
if(!player_isValid(giveplayerid))
{SendClientMessage(playerid, COLOR_SERVER, noConnected); return 1;}
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, playername, sizeof(playername));
if (pack_isAdmin(giveplayerid, 4) && PlayerInfo[playerid][pAdmin] == 1000)
{
SendClientMessage(playerid, COLOR_ADMIN, "Vous кtes malveillant et c'est pour зa que votre commande n'a pas йtй exйcutй. Vous allez кtre ban!");
format(string, sizeof(string), "[Warning] %s a tentй de vous ban.", playername);
SendClientMessage(giveplayerid, COLOR_ALERT, string);
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{idx++;}
new offset = idx;
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{result[idx - offset] = cmdtext[idx]; idx++;}
result[idx - offset] = EOS;
if(!strlen(result))
{SendClientMessage(playerid, COLOR_USAGE, "{FF6600}[Action]{99EEFF} /tban [ID] [Raison] [heures]"); return 1;}
format(string,sizeof(string),"Vous venez d'кtre ban de notre serveur, par %s pour % heures.Motif: %s. Postez sur le forum pour un dйban йventuel.",NameUnder(playerid),time,result);
SendClientMessage(giveplayerid, COLOR_ALERT, string);
TempBanSQL(5,giveplayerid, playername, PlayerInfo[giveplayerid][pIP], result,time*60);
return 1;
}
pawn Код:
public TempBanSQL(type,playerid,bannedby[MAX_PLAYER_NAME],ip[],reason[],time)
{
new reasonSQL[MAX_STRING];
mysql_real_escape_string(reason, reasonSQL);
new query[MAX_STRING], query2[80], row[80], string[MAX_STRING];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(query2, sizeof(query2), "SELECT id FROM players_stats WHERE Name='%s'", playername);
MySQLCheckConnection();
mysql_query(query2);
//SQLLog(query2);
mysql_store_result();
mysql_fetch_row(row);
new sqlid = strval(row);
mysql_free_result();
if(type == 5)
{
format(query, sizeof(query), "INSERT INTO log_bans (type,IDsql,player,bannedby,ip,reason,time) VALUES ('%d','%d','%s','%s','%s','%s',UNIX_TIMESTAMP())",
type,sqlid,playername,bannedby,ip,reasonSQL,time);
}
MySQLCheckConnection();
mysql_query(query);
//SQLLog(query);
format(string, sizeof(string), "[Ban] %s a йtй banni par %s pour % heures - Raison : %s",playername,bannedby,time*60,reason);
SendClientMessageToAll(COLOR_SANCTION,string);
SendClientMessage(playerid, COLOR_SERVER, "[Ban] Si vous pensez que c'est une erreur, contactez un administrateur.");
if(gPlayerLogged[playerid]==0)
{SendClientMessage(playerid, COLOR_USAGE, "[Information] Utilisez /q pour quitter le jeu"); Kick(playerid);}
else
{
Kick(playerid);
format(query2, sizeof(query2), "UPDATE players_stats SET Locked=1 WHERE id=%d", sqlid);
MySQLCheckConnection();
mysql_query(query2);
}
return 1;
}