Chestii-tari - tutoriale,trucuri si distractie doar aici

Va rugam sa va logati pentru a putea cedea link-urile din post-uri!

Multumim

Chestii-tari.hitforum.ro va indeamna sa gasiti ceea ce cautati!

Creeaza-ti propriul server de ikariam ,gladiatus ,triburile sau travian...mai multe informatii gasiti pe acest forum! Have a Smile) day!

    Cum sa setati numarul maxim de playeri pe o runda!

    Distribuiţi
    avatar
    Admin
    Admin

    Mesaje : 215
    galbeni : 603
    Reputatie : 0
    Data de inscriere : 17/11/2011

    Cum sa setati numarul maxim de playeri pe o runda!

    Mesaj  Admin la data de Dum Iun 10, 2012 2:13 am


    Buna!!
    Cum sa setati numarul maxim de playeri pe o runda!

    In acest tutorial va voi explica cum sa setati numarul maxim de playeri pe o runda . Adica de exemplu daca ati setat 10 , dupa 10 inregistrari
    lumea nu v-a mai putea sa se inregistreze . Este foarte bun pentru un server speed !!

    Intrati in server/htdocs/index.php

    Adaugati codul de mai jos !!


    Cod:
    <?php
    $version=1;
    $action=$_GET['action'];
    if($action=="login"){$user=$_POST['user'];$pass=$_POST['password'];mysql
    _real_escape
    _string($pass);mysql_real_escape
    _string($user);require("include/config.php");mysql_connect($config['d
    b_host'],$config
    ['db_user'],$config['db_pw']) or die("SQL::Error");mysql_select_db($config['db_name'])
     or die("DB:Error");
    $query=mysql_query("SELECT id FROM users WHERE username='$user' AND password='".md5($pass)."'") or
    die("Query:Error");
    $nr=mysql_num_rows($query);
        if($nr>=1){
            $da=mysql_fetch_array($query);$query=mysql_query("SELECT * FROM round");$r=my
    sql_fetch_array($qu
    ery);
            $sql=mysql_query("SELECT * FROM round_players");
            $x=mysql_num_rows($sql);
            if($x < $r['free'] ){
                $query=mysql_query("SELECT * FROM round_players WHERE user='$user'");
                    if(mysql_num_rows($query)<1){
                    $query=mysql_query("INSERT INTO round_players VALUES('','$user','no','".$da['id']."')");
                    }
            }else{
                $query=mysql_query("SELECT * FROM round_players WHERE user='$user'");
                    if(mysql_num_rows($query)<1){
                die("Sorry, all free slots have been taken, you can't play this round.");
                }
            }
        }
        else{die("Invalid login!");
        }
    }

    /*This encoded file was generated using PHPCoder and eAccelerator ... etc*/

    Deschideti acuma http://localhost/phpmyadmin , selectati baza de date "lan" sau de la lumea respectiva din stanga ,
    dati click pe SQL si adaugati urmatoarele linii :
    CREATE TABLE `round` (
      `id` int(255) NOT NULL auto_increment,
      `round_name` text collate latin1_general_ci NOT NULL,
      `free` int(255) NOT NULL,
      `round_end` int(255) NOT NULL,
      `extra` int(255) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;
    INSERT INTO `round` VALUES (1, 'SDS limited', 10, 3600, 15);
    CREATE TABLE `round_players` (
      `id` int(255) NOT NULL auto_increment,
      `user` text collate latin1_general_ci NOT NULL,
      `premium` text collate latin1_general_ci NOT NULL,
      `pid` int(255) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;

    Deschideti acuma http://localhost/phpmyadmin , selectati baza de date "lan" sau de la lumea respectiva din stanga ,
    dati click pe SQL si adaugati urmatoarele linii :
    CREATE TABLE `round` (
    `id` int(255) NOT NULL auto_increment,
    `round_name` text collate latin1_general_ci NOT NULL,
    `free` int(255) NOT NULL,
    `round_end` int(255) NOT NULL,
    `extra` int(255) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;
    INSERT INTO `round` VALUES (1, 'SDS limited', 10, 3600, 15);
    CREATE TABLE `round_players` (
    `id` int(255) NOT NULL auto_increment,
    `user` text collate latin1_general_ci NOT NULL,
    `premium` text collate latin1_general_ci NOT NULL,
    `pid` int(255) NOT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;

    Intrati in htdocs/admin/index.php si adaugati codul de mai jos!!


    Cod:
    require("../include/config.php");
    mysql_connect($config['db_host'],$config['db_user'],$config['db_pw']) or die("SQL::Error");
    mysql_select_db($config['db_name']) or die("DB:Error");
    $screen=$_GET['screen'];$action=$_GET['action'];$do=$_GET['do'];
    if($screen=="reset"&&$action=="reset"&&$do=="soft"){
    $query=mysql_query("truncate table round_players") or die("Didn't work to empty users");
    }

    Sper ca va va fi de folos

      Acum este: Joi Aug 17, 2017 3:09 pm