Most SQLite Weird Problem
#3

Quote:
Originally Posted by __
Посмотреть сообщение
You've changed your code from what was shown in that screenshot. Try again now and take a new screenshot, you've commented out the main part of the code shown in your screenshot that executes.
Ok, thanks for answer.

The code:
pawn Код:
#include <a_samp>

new DB:MyDB;

//==============================================================================
public OnFilterScriptInit()
{
    MyDB = db_open("iPhone.db");
    db_free_result(db_query(MyDB, "CREATE TABLE IF NOT EXISTS `Users` (`Name`,`Number`)"));

    return 1;
}

public OnFilterScriptExit()
{
    db_close(MyDB);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/number", true))
    {
        new query[256], DBResult:Result;

        new pName[24];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(query, sizeof(query), "SELECT * FROM `Users` WHERE `Name` = '%s'", pName);
        Result = db_query(MyDB, query);

        if(!db_num_rows(Result))
        {
            new MyNumber[10];

            MyNumber[0] = '0';
            MyNumber[1] = '7';
            MyNumber[2] = (1 + random(8)) + '0';
            for(new i = 3; i < 10; i++)
            MyNumber[i] = random(10) + '0';

            format(query, sizeof(query), "INSERT INTO Users (Name, Number) VALUES('%s', '%s')", pName, MyNumber);
            db_free_result(db_query(MyDB, query));

            SendClientMessage(playerid, -1, query);

            format(query, 128, "Name: %s | Phone number: %s", pName, MyNumber);
            SendClientMessage(playerid, -1, query);
        }
        return 1;
    }
    return 0;
}
The photo: http://imageshack.us/photo/my-images/600/samp034p.png/
Reply


Messages In This Thread
Most SQLite Weird Problem - by MJ! - 16.07.2011, 19:01
Re: Most SQLite Weird Problem - by __ - 16.07.2011, 20:16
Re: Most SQLite Weird Problem - by MJ! - 16.07.2011, 20:24
Re: Most SQLite Weird Problem - by [NoV]LaZ - 16.07.2011, 20:27
Re: Most SQLite Weird Problem - by MJ! - 16.07.2011, 20:30
Re: Most SQLite Weird Problem - by __ - 16.07.2011, 20:31
Re: Most SQLite Weird Problem - by MJ! - 16.07.2011, 20:32

Forum Jump:


Users browsing this thread: 1 Guest(s)