10.08.2013, 19:02
Galera como eu crio um comando de prender, de minutos... EX 300Mins... alguem me ajuda? pf
dcmd_prender(playerid,params[]) {
if(PlayerInfo[playerid][LoggedIn] == 1) {
if(PlayerInfo[playerid][Level] >= 4) {
new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
if(!strlen(params)) return SendClientMessage(playerid, red, "USO: /jail [playerid] [minutos] [motivo]");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
if(PlayerInfo[player1][Jailed] == 0) {
GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
new jtime = strval(tmp2);
if(jtime == 0) jtime = 9999;
CMDMessageToAdmins(playerid,"JAIL");
PlayerInfo[player1][JailTime] = jtime*1000*60;
SetTimerEx("JailPlayer",5000,0,"d",player1);
SetTimerEx("Jail1",1000,0,"d",player1);
PlayerInfo[player1][Jailed] = 1;
if(jtime == 9999) {
if(!strlen(params[strlen(tmp2)+1])) format(string,sizeof(string),"Administrador %s prendeu %s ",adminname, playername);
else format(string,sizeof(string),"Administrador %s prendeu %s [motivo: %s]",adminname, playername, params[strlen(tmp)+1] );
} else {
if(!strlen(tmp3)) format(string,sizeof(string),"Administrador %s prendeu %s por %d minutos",adminname, playername, jtime);
else format(string,sizeof(string),"Administrador %s prendeu %s por %d minutos [motivo: %s]",adminname, playername, jtime, params[strlen(tmp2)+strlen(tmp)+1] );
}
return SendClientMessageToAll(blue,string);
} else return SendClientMessage(playerid, red, "O jogador jб estб na cadeia");
} else return SendClientMessage(playerid, red, "Jogador nгo conectado ou й um admin com nнvel alto");
} else return SendClientMessage(playerid,red,"ERRO: Vocк nгo tem nнvel alto suficiente para usar este comando");
} else return SendClientMessage(playerid,red,"ERRO: Vocк deve estar logado para usar este comando");
}
COMMAND:prender(playerid, params[])
{
new PlayerToJail, JailTime, Reason[128], Msg[128], Name[24], AdminName[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/prender", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 2)
{
if (sscanf(params, "uis[128]", PlayerToJail, JailTime, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Use: /prender [id] [tempo] [motivo]");
else
if (IsPlayerConnected(PlayerToJail)) // If the player is a valid playerid (he's connected)
{
// Jail the player
Police_JailPlayer(PlayerToJail, JailTime);
// Get the name of the player who jailed the player
GetPlayerName(playerid, AdminName, sizeof(AdminName));
// Get the name of the player who's being sent to jail
GetPlayerName(PlayerToJail, Name, sizeof(Name));
// Send the jailed player a message who jailed him, why he's been jailed and how long
format(Msg, 128, "Vocк foi preso por %s %s por %i segundos.", AdminLevelName[APlayerData[playerid][PlayerLevel]], AdminName, JailTime);
SendClientMessage(PlayerToJail, 0xFF0000FF, Msg);
format(Msg, 128, "Motivo: %s", Reason);
SendClientMessage(PlayerToJail, 0xFF0000FF, Msg);
format(Msg, 128, "{00FF00}Vocк prendeu {FFFF00}%s{00FF00} por {FFFF00}%i{00FF00} segundos.", Name, JailTime);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
else
SendClientMessage(playerid, 0xFF0000FF, "Esse jogador nгo estб online.");
}
else
return 0;
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}