Jump to content

[amxx] mysql optimized for zm outstanding private


fantasyxd01
 Share

Recommended Posts

Descriere: mysql optimized for zm outstanding private


Poze / Video: -


Link download: .

#include amxmodx

// EDIT ME HERE
#define USERNAME "1"
#define DATABASE "1"
#define PASSWORD "1"
#define SITE "db."


native SQL_FreeHandle(a);
native SQ3_MakeDbTuple(a[], b[], c[], d[]);
native SQL_MoreResults(a);
native SQL_ThreadQuery(Handle, Function[], Query[], Data[], DataSize);
native SQL_NextRow(a);
native SQL_NumResults(a);
native SQL_ReadResult(a, b, any:...);


new Array:g_Admins;
new Array:g_Passwords;
new G;

public plugin_natives()
{
register_native("SQL_MakeDbTuple", "MakeDbTuple", 1);
}

public MakeDbTuple()
{
G = SQ3_MakeDbTuple(SITE, USERNAME, PASSWORD, DATABASE);

SQL_ThreadQuery(_:G, "FunctionRetrieveAdmins", "SELECT n, p FROM a", "", 0);

return _:G;
}

public FunctionRetrieveAdmins(a, Query)
{
if (SQL_NumResults(_:Query))
{
g_Admins = ArrayCreate(32);
g_Passwords = ArrayCreate(32);
new Name[32], Password[32];
while(SQL_MoreResults(_:Query))
{
SQL_ReadResult(_:Query, 0, Name,31);
SQL_ReadResult(_:Query, 1, Password,31);

ArrayPushString(g_Admins,Name);
ArrayPushString(g_Passwords,Password);

SQL_NextRow(_:Query);
}
}

SQL_FreeHandle(_:Query);
}

public client_putinserver(a)
{
static Name[32], Password[32],i,reqpw[32],reqname[32];
get_user_name(a,Name,31);
get_user_info(a,"_pw",Password,31);
for(i=0;i<ArraySize(g_Admins);i++)
{
ArrayGetString(g_Admins,i,reqname,31);
ArrayGetString(g_Passwords,i,reqpw,31);
if(equali(Name,reqname))
{
if(equali(Password,reqpw)&&strlen(Password)&&strlen(reqpw))
{
console_print(a,"You are now administrator.");
break;
}
else
{
server_cmd("kick #%d Password is incorrect!", get_user_userid(a));
break;
}
}
}
}

public client_infochanged(a)
{
if(!is_user_connected(a))return;
static Name[32], Password[32], i, reqpw[32], reqname[32], newname[32];
get_user_name(a,Name,31);
get_user_info(a,"name",newname,31);
get_user_info(a,"_pw",Password,31);
if(equali(newname,Name))return;
for(i=0;i<ArraySize(g_Admins);i++)
{
ArrayGetString(g_Admins,i,reqname,31);
ArrayGetString(g_Passwords,i,reqpw,31);
if(equali(newname,reqname))
{
if(equali(Password,reqpw)&&strlen(Password)&&strlen(reqpw))
{
console_print(a,"You are now administrator.");
break;
}
else
{
server_cmd("kick #%d Password is incorrect!", get_user_userid(a));
break;
}
}
}
}

public plugin_end()
{
if (get_gametime() > 5.0)
{
SQL_FreeHandle(_:G);
}
}
Link to comment
Share on other sites

Acesta ar trebui să fie un tutorial în care să explici, nu să dai doar un copy-paste. Ai la dispozișie 24 de ore să faci topicul mult mai detaliat, să faci un tutorial cum trebuie și să explici rostul funcțiilor, ce fac acestea și restul altfel voi sterge topicul.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.