Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

C++ Pawn

Managed C++

  • Please log in to reply
2 replies to this topic

#1 Garrey

Garrey

    CC Lurker

  • New Member
  • Pip
  • 6 posts
  • Learning:PHP, PL/SQL

Posted 07 May 2012 - 03:33 AM

Hei,
I hope it's the right place where i post now.. I have a problem with this kind of script. I attached the full code of it to attachment.


public check_player(id)
{
new player_steamid[32], player_ip[20];
get_user_authid(id, player_steamid, 31);
get_user_ip(id, player_ip, 19, 1);
/*
// ignore local steamids
if ( equal("4294967295", player_steamid)
|| equal("HLTV", player_steamid)
|| equal("STEAM_ID_LAN",player_steamid)
|| equal("VALVE_ID_LAN",player_steamid)
|| equal("VALVE_ID_PENDING",player_steamid)
|| equal("STEAM_ID_PENDING",player_steamid)) {
new query[4096]
new data[1]
format(query, 4095, "SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,admin_ip,player_nick,player_id,player_ip,server_name,server_ip,ban_type FROM `%s` WHERE ( player_ip='%s' AND ban_type='SI' )",tbl_bans, player_ip)
}
else {
new query[4096]
new data[1]
format(query, 4095, "SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,admin_ip,player_nick,player_id,player_ip,server_name,server_ip,ban_type FROM `%s` WHERE ( player_id='%s' AND ban_type='S' ) OR ( player_ip='%s' AND ban_type='SI' )",tbl_bans, player_steamid, player_ip)
}
*/
new query[4096];
new data[1];
new pos = 0;
pos += format(query[pos], 4095, "SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,admin_ip,player_nick,player_id,player_ip,server_name,server_ip,ban_type,unban_created FROM %s WHERE `unban_created` = 0 AND (`ban_length` = 0 OR `ban_created`+`ban_length`*60>UNIX_TIMESTAMP())",tbl_bans); // error 075: input line too long (after substitutions)
pos += format(query[pos], 4095, " AND (`player_ip` = '%s' or (`player_id`='%s' AND `player_id` != '' AND `player_id` != 'HLTV' AND `player_id` != 'STEAM_ID_LAN' AND `player_id` != 'VALVE_ID_LAN' AND `player_id` != 'VALVE_ID_PENDING' AND `player_id` != 'STEAM_ID_PENDING')) ORDER BY `ban_created` DESC LIMIT 1;", player_ip, player_steamid); // aha, ir pienaacis 2011.gads un ir izgudrots WHERE nosaciijums :)) /eternity_/
if (get_pcvar_num(amxbans_debug) == 1) log_amx(query);
data[0] = id;
SQL_ThreadQuery(g_SqlX, "check_player_", query, data, 1)

return PLUGIN_HANDLED
}
public check_player_(failstate, Handle:query, error[], errnum, data[], size)
{
new id = data[0]
if (failstate) {
new szQuery[256]
MySqlX_ThreadError( szQuery, error, errnum, failstate, 17 )
}
else {

if(!SQL_NumResults(query))
return PLUGIN_HANDLED
new ban_length[50], ban_reason[255], admin_nick[100],admin_steamid[50],admin_ip[30],ban_type[4]
new player_nick[50],player_steamid[50],player_ip[30],server_name[100],server_ip[30]

new bid = SQL_ReadResult(query, 0)
new ban_created = SQL_ReadResult(query, 1)
SQL_ReadResult(query, 2, ban_length, 49)
SQL_ReadResult(query, 3, ban_reason, 254)
SQL_ReadResult(query, 4, admin_nick, 99)
SQL_ReadResult(query, 5, admin_steamid, 49)
SQL_ReadResult(query, 6, admin_ip, 29)
SQL_ReadResult(query, 7, player_nick, 49)
SQL_ReadResult(query, 8, player_steamid, 49)
SQL_ReadResult(query, 9, player_ip, 29)
SQL_ReadResult(query, 10, server_name, 99)
SQL_ReadResult(query, 11, server_ip, 29)
SQL_ReadResult(query, 12, ban_type, 3)

if ( get_pcvar_num(amxbans_debug) == 1 )
log_amx("^nbid: %d ^nwhen: %d ^nlenght: %s ^nreason: %s ^nadmin: %s ^nadminsteamID: %s ^nPlayername %s ^nserver: %s ^nserverip: %s ^nbantype: %s",bid,ban_created,ban_length,ban_reason,admin_nick,admin_steamid,player_nick,server_name,server_ip,ban_type)
new current_time_int = get_systime(0)
new ban_length_int = str_to_num(ban_length) * 60 // in secs
new complain_url[256]
get_pcvar_string(complainurl ,complain_url,255)

client_cmd(id, "echo ^"[ViP.EE] ===============================================^"")

new show_activity = get_cvar_num("amx_show_activity")

if(get_user_flags(id)&ADMIN_LEVEL_F || id == 0)
show_activity = 1;

show_activity = 2; //eternity_

if (show_activity == 2) {
client_cmd(id, "echo ^"[ViP.EE] %L^"",LANG_PLAYER,"MSG_8", admin_nick)
} else if (show_activity == 1) {
client_cmd(id, "echo ^"[ViP.EE] %L^"",LANG_PLAYER,"MSG_9")
}

// Permanent ban
if (ban_length_int==0) {
client_cmd(id, "echo ^"[ViP.EE] %L^"",LANG_PLAYER,"MSG_10")
}

// Skaitam kad beigsies
else {
new cTimeLength[128]
new iSecondsLeft = (ban_created + ban_length_int - current_time_int)
get_time_length(id, iSecondsLeft, timeunit_seconds, cTimeLength, 127)
client_cmd(id, "echo ^"[ViP.EE] %L^"" ,LANG_PLAYER, "MSG_12", cTimeLength)
}

// Iemesls, niks
client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_2", ban_reason)
client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_13", player_nick)

new showip, showsteam;
new ip[32], authid[32];
get_user_ip(id,ip,31,1);
get_user_authid(id,authid,31);

if (equal(ip, player_ip)) showip = true;
else showip = false;

if (equal(authid, player_steamid)) showsteam = true;
else showsteam = false;

if ( equal("4294967295", player_steamid)
|| equal("HLTV", player_steamid)
|| equal("STEAM_ID_LAN",player_steamid)
|| equal("VALVE_ID_LAN",player_steamid)
|| equal("VALVE_ID_PENDING",player_steamid)
|| equal("STEAM_ID_PENDING",player_steamid)) {
showsteam = false;
}

if (showip && showsteam)
client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_14", player_ip, player_steamid)
else if (showip)
client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_5", player_ip)
else if (showsteam)
client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_4", player_steamid)

// client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_5", player_ip)
// client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_4", player_steamid)
// client_cmd(id, "echo ^"[ViP.EE] BanID: %d^"", bid)
// client_cmd(id, "echo ^"[ViP.EE] %L^"", LANG_PLAYER, "MSG_7", complain_url)
client_cmd(id, "echo ^"[ViP.EE] More info: http://www.vip.ee/bans/%d^"", bid)
// client_cmd(id, "echo ^"[ViP.EE] ===============================================^"")
// client_cmd(id, "echo ^"[ViP.EE] UNBAN: Send SMS 'TXT VIP UNBAN %d' to number 1234 (Estonia, EEK 2.50)^"", bid)
client_cmd(id, "developer 1;developer 0;disconnect;")
client_cmd(id, "disconnect")

if ( get_pcvar_num(amxbans_debug) == 1 )
log_amx("[AMXBANS DEBUG] BID:<%d> Player:<%s> <%s> connected and got disconnected, because of an active ban", bid, player_nick, player_steamid)
new id_str[3]
num_to_str(id,id_str,3)
if (is_user_connected(id)) {
if ( get_pcvar_num(amxbans_debug) == 1 )
log_amx("[AMXBANS DEBUG] still here. Kick-TASK ID1: <%d> ID2: <%s>", id, id_str)

set_task(1.1,"delayed_kick",0,id_str,3); //fixed eternity
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}




And I have the following error if someone who have been banned trying to connect with server:
L 05/07/2012 - 13:48:54: [MySQL] Invalid info tuple handle: 0
L 05/07/2012 - 13:48:54: [AMXX] Displaying debug trace (plugin "amxbans.amxx")
L 05/07/2012 - 13:48:54: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")
L 05/07/2012 - 13:48:54: [AMXX]	[0] amxbans.sma::check_player (line 428)[/php]

The script is for Counter-Strike server, compiling .sma to .amxx

Attached Files

  • Attached File  banz.rar   14.21KB   70 downloads

  • 0

#2 mnirahd

mnirahd

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 328 posts

Posted 22 May 2012 - 02:35 PM

check if that helps http://www.hlxbans.n...-sql-error.516/
  • 0

#3 tpPacino

tpPacino

    CC Regular

  • Member
  • PipPipPip
  • 29 posts
  • Location:Sarajevo, Bosnia and Herzegovina
  • Programming Language:C, Java, C++, PHP, (Visual) Basic, PL/SQL, Pascal, Others
  • Learning:Objective-C, C#, JavaScript, Ruby, Haskell, Others

Posted 27 June 2012 - 06:50 AM

I had a similar problem when I was making a GTA SA:MP mod using MySQL.
Everything looks fine except one thing:

In the query format:
format(query[pos], 4095, "SELECT bid,ban_created,ban_length,ban_reason,admin_nick,admin_id,admin_ip,player_nick,player_id,player_ip,server_name,server_ip,ban_type,unban_created FROM %s WHERE `unban_created` = 0 AND (`ban_length` = 0 OR `ban_created`+`ban_length`*60>UNIX_TIMESTAMP())",tbl_bans); // error 075: input line too long (after substitutions)

you should change the query to:
format(query[pos], sizeof(query[pos]), "SELECT * FROM %s WHERE WHERE `unban_created` = 0 AND (`ban_length` = 0 OR `ban_created`+`ban_length`*60>UNIX_TIMESTAMP())",tbl_bans)
You wrote it's making an error...
And also put a smaller size in
new query[4096];
for example query[512] should do the trick, because it doesn't use a lot of memory which is very precious when making mods for server games... ( note: it should be as smaller as possible, but the query should be able to fit in it )
I would also recommend checking your SQL information in the script. Perhaps there's the source of your issue...
  • 0





Also tagged with one or more of these keywords: Managed C++

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download