Strona 1 z 2 12 OstatniOstatni
Pokaż wyniki od 1 do 10 z 11

Wątek: Hotel + time() + if == zawrót głowy... Nie wiem jak to uło??yć!

  1. #1
    Zarejestrowany Awatar ArekJ
    Dołączył
    Oct 2008
    Posty
    81

    Domyślnie Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    Witam!
    Modyfikuję modyfikację Hotel. Chce użyć funkcji time(), żeby odpoczynek trwał kolejno 3, 5, 7 min. To już mam za sobą. Teraz jak zrobić, żeby podczas gdy postać śpi nie wyświetlała się reszta Hotelu, tylko napis teraz śpisz. zostało jeszcze xxx minut. Proszę nie odsyłajcie mnie do tutoriala o time() na waszym forum bo kompletnie nie mam pomysłu gdzie mogę tego if'a wstawić, żeby działało. Kod w linku...
    http://wklejto.pl/16023

  2. #2
    Pesymista :( Awatar Harrocan
    Dołączył
    Sep 2007
    Posty
    1,663

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    if($czas != NULL)
    {
    jeszcze kimasz
    }
    else
    {
    costam

    Nie wiem czy zadziała, bo pisane z rana ^^
    }

  3. #3
    Zarejestrowany Awatar ArekJ
    Dołączył
    Oct 2008
    Posty
    81

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    Niestety, ale cos nadal nie dziala... Na 100% cos zle robie, ale co? :P
    http://wklejto.pl/16028

  4. #4
    Zarejestrowany
    Dołączył
    Oct 2007
    Posty
    450

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    To co napisałeś powinno działać (chyba że coś pomieszałeś z nawiasami klamrowymi ale tego na wklejto nie sprawdzę). Ale z drobnym ale.
    Czy w klasie players zdeklarowałeś zmienną czasczynnosci przechowującą ten wpis z bazy danych?
    Pierniki górą!

  5. #5
    Zarejestrowany Awatar ArekJ
    Dołączył
    Oct 2008
    Posty
    81

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    No coś tam deklarowałem, ale może ??le?
    Kod:
    <?php
    class Player 
    {
      var $user;
      var $id;
      var $level;
      var $exp;
      var $hp;
      var $max_hp;
      var $mana;
      var $energy;
      var $max_energy;
      var $credits;
      var $bank;
      var $platinum;
      var $tribe;
      var $rank;
      var $location;
      var $ap;
      var $race;
      var $clas;
      var $agility;
      var $strength;
      var $inteli;
      var $pw;
      var $wins;
      var $losses;
      var $lastkilled;
      var $lastkilledby;
      var $age;
      var $logins;
      var $smith;
      var $attack;
      var $miss;
      var $magic;
      var $ip;
      var $speed;
      var $cond;
      var $alchemy;
      var $gg;
      var $avatar;
      var $wisdom;
      var $shoot;
      var $tribe_rank;
      var $fletcher;
      var $immunited;
      var $corepass;
      var $trains;
      var $fight;
      var $deity;
      var $maps;
      var $rest;
      var $page;
      var $profile;
      var $crime;
      var $gender;
      var $style;
      var $leadership;
      var $graphic;
      var $lang;
      var $seclang;
      var $antidote;
      var $breeding;
      var $battlelog;
      var $poll;
      var $mining;
      var $lumberjack;
      var $herbalist;
      var $jeweller;
      var $graphbar;
      var $czasczynnosci;
    /**
    * Class constructor - get data from database and write it to variables
    */
      function Player($pid) 
      {
        global $db;
        $stats = $db -> Execute("SELECT * FROM `players` WHERE `id`=".$pid);
        $this -> user = $stats -> fields['user'];
        $this -> id = $stats -> fields['id'];
        $this -> level = $stats -> fields['level'];
        $this -> exp = $stats -> fields['exp'];
        $this -> hp = $stats -> fields['hp'];
        $this -> max_hp = $stats -> fields['max_hp'];
        $this -> mana = $stats -> fields['pm'];
        $this -> energy = $stats -> fields['energy'];
        $this -> max_energy = $stats -> fields['max_energy'];
        $this -> credits = $stats -> fields['credits'];
        $this -> bank = $stats -> fields['bank'];
        $this -> platinum = $stats -> fields['platinum'];
        $this -> tribe = $stats -> fields['tribe'];
        $this -> rank = $stats -> fields['rank'];
        $this -> location = $stats -> fields['miejsce'];
        $this -> ap = $stats -> fields['ap'];
        $this -> race = $stats -> fields['rasa'];
        $this -> clas = $stats -> fields['klasa'];
        $this -> agility = $stats -> fields['agility'];
        $this -> strength = $stats -> fields['strength'];
        $this -> inteli = $stats -> fields['inteli'];
        $this -> pw = $stats -> fields['pw'];
        $this -> wins = $stats -> fields['wins'];
        $this -> losses = $stats -> fields['losses'];
        $this -> lastkilled = $stats -> fields['lastkilled'];
        $this -> lastkilledby = $stats -> fields['lastkilledby'];
        $this -> age = $stats -> fields['age'];
        $this -> logins = $stats -> fields['logins'];
        $this -> smith = $stats -> fields['ability'];
        $this -> attack = $stats -> fields['atak'];
        $this -> miss = $stats -> fields['unik'];
        $this -> magic = $stats -> fields['magia'];
        $this -> ip = $stats -> fields['ip'];
        $this -> speed = $stats -> fields['szyb'];
        $this -> cond = $stats -> fields['wytrz'];
        $this -> alchemy = $stats -> fields['alchemia'];
        $this -> gg = $stats -> fields['gg'];
        $this -> avatar = $stats -> fields['avatar'];
        $this -> wisdom = $stats -> fields['wisdom'];
        $this -> shoot = $stats -> fields['shoot'];
        $this -> tribe_rank = $stats -> fields['tribe_rank'];
        $this -> fletcher = $stats -> fields['fletcher'];
        $this -> immunited = $stats -> fields['immu'];
        $this -> corepass = $stats -> fields['corepass'];
        $this -> trains = $stats -> fields['trains'];
        $this -> fight = $stats -> fields['fight'];
        $this -> deity = $stats -> fields['deity'];
        $this -> maps = $stats -> fields['maps'];
        $this -> rest = $stats -> fields['rest'];
        $this -> page = $stats -> fields['page'];
        $this -> profile = $stats -> fields['profile'];
        $this -> crime = $stats -> fields['crime'];
        $this -> gender = $stats -> fields['gender'];
        $this -> style = $stats -> fields['style'];
        $this -> leadership = $stats -> fields['leadership'];
        $this -> graphic = $stats -> fields['graphic'];
        $this -> lang = $stats -> fields['lang'];
        $this -> seclang = $stats -> fields['seclang'];
        if (!empty($stats -> fields['antidote']))
        {
          $this -> antidote = $stats -> fields['antidote']{0};
        }
          else
        {
          $this -> antidote = '';
        }
        $this -> breeding = $stats -> fields['breeding'];
        $this -> battlelog = $stats -> fields['battlelog'];
        $this -> poll = $stats -> fields['poll'];
        $this -> mining = $stats -> fields['mining'];
        $this -> lumberjack = $stats -> fields['lumberjack'];
        $this -> herbalist = $stats -> fields['herbalist'];
        $this -> jeweller = $stats -> fields['jeweller'];
        $this -> graphbar = $stats -> fields['graphbar'];
        $this -> user = $stats -> fields['czasczynnosci'];
        $stats -> Close();
      }
      /**
      * Function return values of selected atributes in array
      */
      function stats($stats) 
      {
        $arrstats = array();
        foreach ($stats as $value) 
        {
          $arrstats[$value] = $this -> $value;
        }
        return $arrstats;
      }
    
      /**
      * Function return values of equiped items
      */
      function equipment()
      {
        global $db;
    
        $arrEquip = array(array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                 array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        $arrEquiptype = array('W', 'B', 'H', 'A', 'L', 'S', 'R', 'T', 'C', 'I');
        $objEquip = $db -> Execute("SELECT `id`, `name`, `power`, `type`, `minlev`, `zr`, `wt`, `szyb`, `poison`, `ptype`, `maxwt` FROM `equipment` WHERE `owner`=".$this -> id." AND status='E'");
        while (!$objEquip -> EOF)
        {
          $intKey = array_search($objEquip -> fields['type'], $arrEquiptype);
          if ($arrEquip[9][0] && $objEquip -> fields['id'] != $arrEquip[9][0] && $objEquip -> fields['type'] == 'I')
          {
            $intKey = 10;
          }
          $arrEquip[$intKey][0] = $objEquip -> fields['id'];
          $arrEquip[$intKey][1] = $objEquip -> fields['name'];
          $arrEquip[$intKey][2] = $objEquip -> fields['power'];
          $arrEquip[$intKey][3] = $objEquip -> fields['ptype'];
          $arrEquip[$intKey][4] = $objEquip -> fields['minlev'];
          $arrEquip[$intKey][5] = $objEquip -> fields['zr'];
          $arrEquip[$intKey][6] = $objEquip -> fields['wt'];
          $arrEquip[$intKey][7] = $objEquip -> fields['szyb'];
          $arrEquip[$intKey][8] = $objEquip -> fields['poison'];
          $arrEquip[$intKey][9] = $objEquip -> fields['maxwt'];
          $objEquip -> MoveNext();
        }
        $objEquip -> Close();
        return $arrEquip;
      }
    }
    EDIT: musiałem coś ??le w klasie zmodyfikować, bo zamiast nicku pokazuje mi ten czas Tylko nie wiem co...

  6. #6
    Zasłużony Awatar sazian
    Dołączył
    Jul 2008
    Posty
    1,721

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    znajd??
    Kod:
    $this -> user = $stats -> fields['czasczynnosci'];
    i zamień na
    Kod:
    $this -> czasczynnosci = $stats -> fields['czasczynnosci'];
    edit
    w bazie masz pole czasczynnosci ??

  7. #7
    Zarejestrowany Awatar ArekJ
    Dołączył
    Oct 2008
    Posty
    81

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    Nie no, taki n00bek nie jestem zeby do bazy nie dodac Dobra, teraz nawet po daniu
    $czasczynnosci = var_dump($player -> czasczynnosci);

    echo $czasczynnosci;
    To sie wyswietla
    string(10) "1227439263"
    Ale if'a nadal mam chyba w zlym miejscu bo w dalszym ciagu moge sobie spac tez w innych pokojach i skrypt ma gdzies tego if'a :/

  8. #8
    Zarejestrowany
    Dołączył
    Oct 2007
    Posty
    450

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    To nie mam pomysłu. Może go boli fakt, że ma do czynienia ze stringiem?
    Spróbuj takiego ifa:
    Kod:
    if ((int)$player -> czasczynnosci <= time())
    (po wprowadzeniu tego co Sazian mówił)
    Pierniki górą!

  9. #9
    Zarejestrowany Awatar ArekJ
    Dołączył
    Oct 2008
    Posty
    81

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    Nie idzie :/ A w kodzie to na 100% w dobrym miejscu mam?

  10. #10
    Grupa MmoCenter Awatar Kiri
    Dołączył
    Sep 2007
    Posty
    1,741

    Domyślnie Odp: Hotel + time() + if == zawrót głowy... Nie wiem jak to ułożyć!

    Po co każde zapytanie update przypisujesz do zmiennej $zapytanie ? ;o
    Sio, nie pomagam via PM !



Strona 1 z 2 12 OstatniOstatni

Informacje o wątku

Użytkownicy przeglądający ten wątek

Aktualnie 1 użytkownik(ów) przegląda ten wątek. (0 zarejestrowany(ch) oraz 1 gości)

Podobne wątki

  1. Zmodyfikowany Hotel
    Przez sopel95 w dziale Race
    Odpowiedzi: 9
    Ostatni post / autor: 07-10-2010, 23:45
  2. Hotel
    Przez htmlxp w dziale Modyfikacje Vallheru
    Odpowiedzi: 18
    Ostatni post / autor: 27-06-2010, 19:59
  3. hotel.php odebranie promili
    Przez PICHU w dziale Race
    Odpowiedzi: 7
    Ostatni post / autor: 30-07-2009, 10:40
  4. Mod Hotel
    Przez jasza w dziale Support Vallheru
    Odpowiedzi: 2
    Ostatni post / autor: 21-05-2008, 13:01

Zakładki

Uprawnienia umieszczania postów

  • Nie możesz zakładać nowych tematów
  • Nie możesz pisać wiadomości
  • Nie możesz dodawać załączników
  • Nie możesz edytować swoich postów
  •