| whosyourdaddy |
08-29-2008 17:59 |
read from mysql
ok well this is what im trying to do, i want the thing to read from a certain table in the mysql and if the person isnt in the tables then it will the the (!in_file) function if they are it will the the else if statements... this is what i have
Code:
public MYSQL_AllowedLevel(id)
{
if ( !MYSQLX_Connection_Available() )
return;
new bool:in_file = false;
new iUniqueID = DB_GetUniqueID( id ); // gets there id in database
new szKey[66], szKeyName[32];
DB_GetKey( id, szKey, 65 );
DB_GetKeyName( szKeyName, 31 );
new szQuery[512];
format(szQuery, 255, "SELECT `allowed_level` FROM `wc3_allowed` WHERE ( `player_id` = '%d' );", iUniqueID );
new Handle:query = SQL_PrepareQuery( g_DBConn, szQuery );
if ( !SQL_Execute( query ) )
{
MYSQLX_Error( query, szQuery, 2 );
return;
}
if(user is in the table)
{
in_file = true;
MAX_LEVEL = read data from the table under allowed_level ( should be allowed level);
if(MAX_LEVEL == 14)
{
client_print(id,print_chat, "[sFx] You have reached your max level. Join our forums to unlock the rest of the levels. ")
p_data[id][P_XP] = 240000
p_data_b[id][PB_RESETSKILLS] = true;
}
else if(MAX_LEVEL == 15 && p_data[id][P_XP] > 300000)
{
client_print(id,print_chat, "[sFx] You have reached your max level. Join our forums to unlock the rest of the levels. ")
p_data[id][P_XP] = 290000
p_data_b[id][PB_RESETSKILLS] = true;
}
else if(MAX_LEVEL == 16 && p_data[id][P_XP] > 350000)
{
client_print(id,print_chat, "[sFx] You have reached your max level. Join our forums to unlock the rest of the levels. ")
p_data[id][P_XP] = 340000
p_data_b[id][PB_RESETSKILLS] = true;
}
else if(MAX_LEVEL == 17 && p_data[id][P_XP] > 400000)
{
client_print(id,print_chat, "[sFx] CONGRATS FROM THE [sFx] COMMUNITY ON YOUR LEVEL 17. ")
}
}
if( !in_file )
{
if(p_data[id][P_XP] > 200000)
{
client_print(id,print_chat, "[sFx] You have reached your max level. Join our forums to unlock the rest of the levels. ")
p_data[id][P_XP] = 190000
p_data_b[id][PB_RESETSKILLS] = true;
}
}
// Free the handle
SQL_FreeHandle( query );
}
i just dont know how to make it read the info and see if the user is in the database and i dont know how to make it read the allowed_level
|