• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    Ayuda necesito un rebird para mysql

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1Thông báo Ayuda necesito un rebird para mysql el Sáb Feb 10, 2018 2:58 pm

    forgeofcha

    avatar
    Nuevo Miembro
    Nuevo Miembro
    necesito un rebird para mysql.. cheers

    Ver perfil de usuario

    2Thông báo Re: Ayuda necesito un rebird para mysql el Sáb Feb 10, 2018 3:04 pm

    [Admin] God Maya

    avatar
    Administrador
    Administrador
    creaturescripts\scripts
    rebirthdescription.lua
    Código:
    function onLook(cid, thing, position, lookDistance)
        if(isPlayer(thing.uid) and thing.uid ~= cid and getPlayerRebirth(thing.uid) ~= -1) then
            doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == PLAYERSEX_FEMALE and ".\nShe" or ".\nHe") .. " has " .. getPlayerRebirth(thing.uid) .. " " .. (getPlayerRebirth(thing.uid) == 1 and "rebirths" or "rebirth"))
        elseif(thing.uid == cid and getPlayerRebirth(cid) ~= -1) then
            local message = "You see yourself."
            if(getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
                message = message .. " You are " .. getPlayerGroupName(cid) .. "."
            elseif(getPlayerVocation(cid) ~= 0) then
                message = message .. " You are a " .. getPlayerVocationName(cid):lower() .. "."
            else
                message = message .. " You have no vocation."
            end
     
            if(getPlayerByName(getPlayerPartner(cid), false, false) ~= nil) then
                message = message .. " You are " .. (getPlayerSex(cid) == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerByName(getPlayerPartner(cid)) .. "."
            end
     
            if(getPlayerGuildId(cid) > 0) then
                message = message .. " You are " .. (getPlayerGuildRank(cid) == "" and "a member" or getPlayerGuildRank(cid)) .. " of the " .. getPlayerGuildName(cid)
                message = getPlayerGuildNick(cid) ~= "" and message .. " (" .. getPlayerGuildNick(cid) .. ")." or message .. "."
            end
     
            if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
                message = message .. "\nHealth: [" .. getCreatureHealth(cid) .. " / " .. getCreatureMaxHealth(cid) .. "], Mana: [" .. getCreatureMana(cid) .. " / " .. getCreatureMaxMana(cid) .. "]."
                message = message .. "\nIP: " .. doConvertIntegerToIp(getPlayerIp(cid)) .. "."
            end
     
            if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
                message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
            end
     
            return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. " \nYou have " .. getPlayerRebirth(cid) .. " " .. (getPlayerRebirth(cid) == 1 and "rebirths." or "rebirth."))
        end
     
        return true
    end

    login.lua

    Código:
    registerCreatureEvent(cid, "RebirthDescription")

    en creaturescripts.xml

    Código:
    <event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>

    lib buscas 050-function.lua

    Código:
    function getPlayerRebirth(cid)
        local Info = db.getResult("SELECT `Rebirths` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
            if Info:getID() ~= LUA_ERROR then
            local rebs= Info:getDataInt("Rebirths")
            Info:free()
            return rebs
        end
        return LUA_ERROR
    end
     
    function doAddRebirth(cid, rebs)
        db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` + " .. rebs .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    end
     
    function doRemoveRebirth(cid, rebs)
        db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` - " .. rebs .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    end

    ---------------------------------------------------

    npc Rebirth.xml

    Código:
    <?xml version="1.0" encoding="UTF-8"?>
    <npc name="Modern Rebirth" script="rebirth.lua" walkinterval="0" floorchange="0">
        <health now="100" max="100"/>
        <look typeex="12319"/>
        <parameters>
            <parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to {reborn}?!"/>
            <parameter key="message_farewell" value="Cya later!"/>
        </parameters>
    </npc>

    npc\scripts

    rebirth.lua

    Código:
    local config = {
        price = 0, -- Price of first rebirth
        priceIncrease = 0, -- Works as 'price' + current rebirths * priceIncrease.
        rebirthLevel = 717171, -- Level for first rebirth.
        rebirthIncrease = 0, -- Works as 'rebirthLevel' + current rebirths * rebirthIncrease.
        maxRebirths = 1000, -- Number of times a player can rebirth.
        level = 8, -- The level the player is set to apon rebirth.
        healthPercent = 1.00, -- 1.00 = 100%.
        health = 100, -- Only used if 'healthPercent' = 0.
        manaPercent = 1.00, -- 1.00 = 100%.
        mana = 100, -- Only used if 'manaPercent' = 0.
        keepSkills = true, -- Wether players keep skills and level apon rebirth.
        skillLevel = 10, -- Only used if 'keepSkills' = false.
        magicLevel = 0, -- Only used if 'keepSkills' = false.
        capacity = 10000, -- The capacity players are set to apon rebirth.
        templePos = {x = 0, y = 0, z = 0}, -- The place where players reset to should there town id return 0.
        Rebirth = 1 -- how many Rebirth player will get.
    }
     
    local focuses = {}
    local function isFocused(cid)
        for i, v in pairs(focuses) do
            if(v == cid) then
                return true
            end
        end
        return false
    end
     
    local function addFocus(cid)
        if(not isFocused(cid)) then
            table.insert(focuses, cid)
        end
    end
    local function removeFocus(cid)
        for i, v in pairs(focuses) do
            if(v == cid) then
                table.remove(focuses, i)
                break
            end
        end
    end
    local function lookAtFocus()
        for i, v in pairs(focuses) do
            if(isPlayer(v)) then
                doNpcSetCreatureFocus(v)
                return
            end
        end
        doNpcSetCreatureFocus(0)
    end
     
    function onCreatureDisappear(cid)
        if(isFocused(cid)) then
            selfSay("Goodbye.")
            removeFocus(cid)
        end
    end
     
     
    function onCreatureSay(cid, type, msg)
        if((msg == "hi") and not (isFocused(cid))) then
            selfSay("Welcome, ".. getCreatureName(cid) ..".", cid, true)
            selfSay("Im in charge of the {Rebirth} system.", cid)
            addFocus(cid)
            status = 1
        elseif((isFocused(cid)) and (msg == "rebirth")  or (msg == "Rebirth") or (msg == "reb")  and (status == 1)) then
                  if(isInArray({1,2,3,4,5, 6, 7, 8,9,10,11,12}, getPlayerVocation(cid))) then
            if (getPlayerRebirth(cid, config.Rebirth) < config.maxRebirths) then
                Rebirth = getPlayerRebirth(cid, config.Rebirth)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * Rebirth)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * Rebirth)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Once you rebirth you will have to level up again from the beginning! Are you sure you still want to rebirth?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can rebirth.", cid)
                        status = 1
                    end
                    else
                        selfSay("You need to be at least level " .. rebirthLevel .. " before you can rebirth.", cid)
                    status = 1
                    end
                else
                selfSay("It seems you can not rebirth anymore you are max rebirth .", cid)
                status = 1
                end
            else
                selfSay("Please talk with Zarzor King and promote first.", cid)
                status = 1
            end
        elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
            selfSay("Ok then i will rebirth you.", cid)
            selfSay("You will now be logged out.", cid)
            doPlayerRemoveMoney(cid, money)
            addEvent(doRebirthPlayer, 0, {cid=cid})
            removeFocus(cid)
        elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
            selfSay("Maybe one day you will wise up and change your mind!", cid)
            status = 1
        elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
            selfSay("Goodbye!", cid, true)
            removeFocus(cid)
        end
    end
     
    function onPlayerCloseChannel(cid)
        if(isFocused(cid)) then
            selfSay("Goodbye.")
            removeFocus(cid)
        end
    end
     
    function onThink()
        for i, focus in pairs(focuses) do
            if(not isCreature(focus)) then
                removeFocus(focus)
            else
                local distance = getDistanceTo(focus) or -1
                if((distance > 4) or (distance == -1)) then
                    selfSay("Goodbye.")
                    removeFocus(focus)
                end
            end
        end
        lookAtFocus()
    end
     
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
     
        local guid = getPlayerGUID(cid)
     
        if (config.healthPercent > 0) then
            health = getCreatureMaxHealth(cid) * config.healthPercent
        else
            health = config.health
        end
        if (config.manaPercent > 0) then
            mana = getCreatureMaxMana(cid) * config.manaPercent
        else
            mana = config.mana
        end
        if (getPlayerTown(cid) > 0) then
            pos = getTownTemplePosition(getPlayerTown(cid))
        else
            pos = config.templePos
    end
     
        doAddRebirth(cid, config.Rebirth, getPlayerRebirth(cid, config.Rebirth) + 1)
     
        doRemoveCreature(cid, true)
        db.executeQuery("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
     
        if (not config.keepSkills) then
            db.executeQuery("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
            db.executeQuery("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
        end
        return true
    end
     


    en el phpmyadmin ejecutar esta tabla mysql

    Código:
    ALTER TABLE `players` ADD `rebirths` INT NOT NULL DEFAULT 0;


    y en su web remplazar highscores.php por este contenidio

    Código:
    <?PHP
    $list = $_REQUEST['list'];
    $page = $_REQUEST['page'];
    switch($list)
    {
      case "fist":
      $id = 0;
      $list_name = 'Fist Fighting';
      break;
      case "club":
      $id = 1;
      $list_name = 'Club Fighting';
      break;
      case "sword":
      $id = 2;
      $list_name = 'Sword Fighting';
      break;
      case "axe":
      $id = 3;
      $list_name = 'Axe Fighting';
      break;
      case "distance":
      $id = 4;
      $list_name = 'Distance Fighting';
      break;
      case "shield":
      $id = 5;
      $list_name = 'Shielding';
      break;
      case "fishing":
      $id = 6;
      $list_name = 'Fishing';
      break;
    }
    if(!isset($id))
        if($list == "magic")
            $list_name = "Magic Level";
        elseif($list == "rebirths")
            $list_name = "rebirths";
        else
        {
            $list_name = 'Experience';
            $list = 'experience';
        }
    if(count($config['site']['worlds']) > 1)
    {
        $worlds .= '<i>Select world:</i> ';
        foreach($config['site']['worlds'] as $idd => $world_n)
        {
            if($idd == (int) $_GET['world'])
            {
                $world_id = $idd;
                $world_name = $world_n;
            }
        }
    }
            if($idd == (int) $_GET['world'])
            {
                $world_id = $idd;
                $world_name = $world_n;
            }
    if(!isset($world_id))
    {
        $world_id = 0;
        $world_name = $config['server']['serverName'];
    }
    $offset = $page * 100;
    if(isset($id))
        $skills = $SQL->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = '.$id.' ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
    elseif($list == "magic")
        $skills = $SQL->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
    elseif($list == "rebirths")
        $skills = $SQL->query('SELECT name,online,rebirths,level,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY rebirths DESC LIMIT 101 OFFSET '.$offset);
    elseif($list == "experience")
        $skills = $SQL->query('SELECT name,online,level,experience,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);
     
    //wyswietlanie wszystkiego
    $main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD><CENTER><H2>Ranking for '.$list_name.' on '.$world_name.'</H2></CENTER><BR>';
        $main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD></TD><TD>
    <FORM ACTION="?subtopic=highscores" METHOD=get><INPUT TYPE=hidden NAME=subtopic VALUE=highscores><INPUT TYPE=hidden NAME=list VALUE=experience>
    <TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>World Selection</B></TD></TR><TR><TD BGCOLOR="'.$config['site']['lightborder'].'">
        <TABLE BORDER=0 CELLPADDING=1><TR><TD>World: </TD><TD><SELECT SIZE="1" NAME="world"><OPTION VALUE="" SELECTED>(choose world)</OPTION>';
        foreach($config['site']['worlds'] as $id => $world_n)
    {
        $main_content .= '<OPTION VALUE="'.$id.'">'.$world_n.'</OPTION>';
    }
        $main_content .= '</SELECT> </TD><TD><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>
            </TD></TR></TABLE></TABLE></FORM></TABLE><br><br><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=10% CLASS=whites><B>Rank</B></TD><TD WIDTH=75% CLASS=whites><B>Name</B></TD><TD WIDTH=15% CLASS=whites><b><center>Level</center></B></TD><TD WIDTH=5% CLASS=whites><b><center>Vip Status</center></B></TD>';
    if($list == "experience")
        $main_content .= '<TD CLASS=whites><b><center>Points</center></B></TD>';
    $main_content .= '</TR><TR>';
    foreach($skills as $skill)
     
    {
    $player = $ots->createObject('Player');
    $player->find($skill['name']);
    $account = $player->getAccount();
    $ban = '';
    if($account->isBanned())
    $ban = '<font color="red"> [Banished]</font>';
        if($number_of_rows < 100)
        {
            if($list == "magic")
                $skill['value'] = $skill['maglevel'];
            if($list == "rebirths")
                $skill['value'] = $skill['rebirths'];
            if($list == "experience")
                $skill['value'] = $skill['level'];
            if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
            $main_content .= '<tr bgcolor="'.$bgcolor.'"><td>'.($offset + $number_of_rows).'.</td><td><a href="?subtopic=characters&name='.urlencode($skill['name']).'">'.($skill['online']>0 ? "<font color=\"green\">".$skill['name']."</font>" : "<font color=\"red\">".$skill['name']."</font>").'</a> '.$ban.'<br><small>'.$skill['level'].' '.$vocation_name[$world_id][$skill['promotion']][$skill['vocation']].'</small></td><td><center>'.$skill['value'].'</center></td><td>'.$vipp.'</td>  ';
            if($list == "experience")
                $main_content .= '<td><center>'.$skill['experience'].'</center></td>';
            $main_content .= '</tr>';
        }
        else
            $show_link_to_next_page = TRUE;
            $vip = $SQL->query('SELECT `player_storage`.`player_id`, `player_storage`.`key`, `players`.`id` FROM `player_storage`, `players` WHERE `player_storage`.`player_id` = '.$player->getId().' AND `key` = 11551;')->fetchall();
    if($vip[0]['key'] == 11551)
        $vipp = '<center><font color="green"><b>VIP</b></font></center>';
    else
        $vipp = '<center><font color="red"><b>Non Vip</b></font></center>';
    }
    $main_content .= '</TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>';
    if($page > 0)
        $main_content .= '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="?subtopic=highscores&list='.$list.'&page='.($page - 1).'" CLASS="size_xxs">Previous Page</A></TD></TR>';
    if($show_link_to_next_page)
        $main_content .= '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="?subtopic=highscores&list='.$list.'&page='.($page + 1).'" CLASS="size_xxs">Next Page</A></TD></TR>';
    $main_content .= '</TABLE></TD><TD WIDTH=5%><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD><TD WIDTH=15% VALIGN=top ALIGN=right><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=whites><B>Choose a skill</B></TD></TR><TR BGCOLOR="'.$config['site']['lightborder'].'"><TD><A HREF="?subtopic=highscores&list=experience&world='.$world_id.'" CLASS="size_xs">Experience</A><BR><A HREF="?subtopic=highscores&list=magic&world='.$world_id.'" CLASS="size_xs">Magic</A><BR><A HREF="?subtopic=highscores&list=shield&world='.$world_id.'" CLASS="size_xs">Shielding</A><BR><A HREF="?subtopic=highscores&list=distance&world='.$world_id.'" CLASS="size_xs">Distance</A><BR><A HREF="?subtopic=highscores&list=club&world='.$world_id.'" CLASS="size_xs">Club</A><BR><A HREF="?subtopic=highscores&list=sword&world='.$world_id.'" CLASS="size_xs">Sword</A><BR><A HREF="?subtopic=highscores&list=axe&world='.$world_id.'" CLASS="size_xs">Axe</A><BR><A HREF="?subtopic=highscores&list=fist&world='.$world_id.'" CLASS="size_xs">Fist</A><BR><A HREF="?subtopic=highscores&list=fishing&world='.$world_id.'" CLASS="size_xs">Fishing</A><BR><A HREF="?subtopic=highscores&list=rebirths&world='.$world_id.'" CLASS="size_xs">rebirths</A><BR></TD></TR></TABLE></TD><TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD></TR></TABLE>';
    $main_content .='autor: <a href="http://otland.net/members/god+batonik/">GoD BaToNiK</a>';
     
    ?>






    Ver perfil de usuario http://www.tibiaface.com

    3Thông báo Re: Ayuda necesito un rebird para mysql el Sáb Feb 10, 2018 3:26 pm

    forgeofcha

    avatar
    Nuevo Miembro
    Nuevo Miembro
    Lo agrege y me dio este error de principio:
    data/creaturescripts/creaturescripts.xml:44: parser error : attributes construct error
    <event type="look" name="RebirthDescription" event="script" value="rebirthdescri

    Ver perfil de usuario

    4Thông báo Re: Ayuda necesito un rebird para mysql el Sáb Feb 10, 2018 3:27 pm

    [Admin] God Maya

    avatar
    Administrador
    Administrador
    lo agregaste bien asi

    Código:
    <event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>



    Ver perfil de usuario http://www.tibiaface.com

    5Thông báo Re: Ayuda necesito un rebird para mysql el Sáb Feb 10, 2018 4:00 pm

    forgeofcha

    avatar
    Nuevo Miembro
    Nuevo Miembro
    Listo ya funciona ese script gracias Very Happy rep++

    Ver perfil de usuario

    Contenido patrocinado


    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).