16.07.2011, 20:24
Quote:
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.
|
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;
}