21.04.2012, 10:46
Therefore you normally use the unix timestamp
I am using as example the dudb file system, so its quite clear what the code does
I am using as example the dudb file system, so its quite clear what the code does
pawn Код:
CMD:tempban(playerid, params[]) {
new
id,
hours
;
if(sscanf(params, "uis", id, hours, params)) {
SendClientMessage(playerid, -1, "Usage: \"/ban <playerid><hours><reason>\"");
} else {
if(id == INVALID_PLAYER_ID) {
SendClientMessage(playerid, -1, "Player not found");
} else {
if(0 < hours < 24) {
// some nice messages to the players
// the unix timestap is in seconds, so we convert the hours to seconds
dUserSetINT(PlayerName(id)).("ban", (gettime() + (hours * 60 * 60)));
Kick(id);
} else {
SendClientMessage(playerid, -1, "You can only ban him for 1 - 23 hours!");
}
}
}
return true;
}
pawn Код:
// OnPlayerConnect
new
banned = dUserINT(PlayerName(playerid)).("ban")
;
if(banned) {
if(banned == 1) { // default ban without time
Kick(playerid);
} else {
if(banned < gettime()) { // reset his ban
dUserSetInt(PlayerName(playerid)).("ban", 0);
} else { // if the time hasnt passed kick him
Kick(playerid);
}
}
}