[Pedido] /prender [id] [motivo] [tempo]
#8

pawn Код:
CMD:prender(playerid, params[]) {

    static
        id,
        tempo,
        motivo[32]
    ;
   
    if ( sscanf(params, "uis[32]", id, tempo, motivo) )
        return SendClientMessage(playerid, -1, "Use: /prender [id] [tempo(em minutos)] [motivo]");
       
    if (!IsPlayerConnected(id))
        return SendClientMessage(playerid, -1, "Jogador offline!");
       
    static
        tempo_s,
        nome[24],
        nome_admin[24],
        arquivo[35],
        str[128]
    ;
   
    tempo_s = tempo * 60;
   
    GetPlayerName(playerid, nome_admin, 24);
    GetPlayerName(id, nome, 24);

    format (arquivo, 35, "Presos/%s.ini", nome);
   
    if (!fexist(arquivo))
        DOF2_CreateFile(arquivo));
       
    DOF2_SetInt(arquivo, "tempo", tempo_s);
    DOF2_SetString(arquivo, "admin", nome_admin);
    DOF2_SetString(arquivo, "motivo", motivo);
    DOF2_SaveFile();
   
    SetPVarInt(id, "tempo_cadeia", tempo_s);
   
    SetTimerEx("reduzirTempo", 1000, false, "d", id);
   
    // SetPlayerPos(....); // posiзгo da cadeia
    // SetPlayerInterior(..); // interior cadeia
   
    format (str, 128, "AdmCmd: %s prendeu %s por %d minutos, motivo: %s", nome_admin, nome, tempo, motivo);
    SendClientMessageToAll(-1, str);
   
    return 1;
}
forward reduzirTempo(i);
public reduzirTempo(i) {

    SetPVarInt(i, "tempo_cadeia", (GetPVarInt(i, "tempo_cadeia") - 1) );
   
    if ( GetPVarInt(i, "tempo_cadeia") <= 0 ) {
   
        DeletePVar(i, "tempo_cadeia");
       
        static
            nome[24],
            local[35]
        ;
       
        GetPlayerName(i, nome, 24);
       
        format(local, 35, "Presos/%s.ini", nome);
        fremove(local);
       
        SendClientMessage(i, -1, "Vocк esta solto!");
        SpawnPlayer(i);
   
        return 1;
    }
   
    SetTimerEx("reduzirTempo", 1000, false, "d", i);
   
    return 1;
}

public OnPlayerDisconnect(playerid, reason) {

    if ( GetPVarInt(playerid, "tempo_cadeia") != 0 ) {
   
        static
            nome[24],
            local[35]
        ;

        GetPlayerName(playerid, nome, 24);

        format(local, 35, "Presos/%s.ini", nome);
       
        DOF2_SetInt(local, "tempo", GetPVarInt(playerid, "tempo_cadeia"));
        DOF2_SaveFile();
   
    }

    return 1;
}
Logo apуs o jogador efetuar o login e necessбrio verificar se a puniзгo jб foi cumprida.

pawn Код:
static
    nome[24],
    arquivo[35],
    str[128]
;

GetPlayerName(playerid, nome, 24);

format (arquivo, 35, "Presos/%s.ini", nome);

if (fexist(arquivo)) {

    format (str, 128, "Admin: %s - Motivo: %s - Tempo restante: %d segundos", DOF2_GetString(arquivo, "admin"), DOF2_GetString(arquivo, "motivo"), DOF2_GetInt(arquivo, "tempo") );
    SendClientMessage(playerid, -1, "Sentenзa incompleta! Detalhes da prisгo:");
    SendClientMessage(playerid, -1, str);
   
    SetPVarInt(playerid, "tempo_cadeia", DOF2_GetInt(arquivo, "tempo") );
    SetTimerEx("reduzirTempo", 1000, false, "d", playerid);

    // SetPlayerPos(....); // posiзгo da cadeia
    // SetPlayerInterior(..); // interior cadeia
   
}

OBS: Nгo testei, muito menos compilei.

OBS2: Crie a pasta Presos!
Reply


Messages In This Thread
/prender [id] [motivo] [tempo] - by eNtinityGaming - 07.02.2014, 02:27
Re: /prender [id] [motivo] [tempo] - by GuilhermeH - 07.02.2014, 11:30
Re: /prender [id] [motivo] [tempo] - by eNtinityGaming - 07.02.2014, 13:34
Re: /prender [id] [motivo] [tempo] - by DanDRT - 07.02.2014, 15:29
Re: /prender [id] [motivo] [tempo] - by eNtinityGaming - 07.02.2014, 18:03
Re: /prender [id] [motivo] [tempo] - by PT - 07.02.2014, 20:03
Re: /prender [id] [motivo] [tempo] - by eNtinityGaming - 07.02.2014, 21:27
Re: /prender [id] [motivo] [tempo] - by Gii - 07.02.2014, 21:53
Re: /prender [id] [motivo] [tempo] - by eNtinityGaming - 07.02.2014, 22:46
Respuesta: /prender [id] [motivo] [tempo] - by eNtinityGaming - 07.02.2014, 23:23

Forum Jump:


Users browsing this thread: 3 Guest(s)