AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   General question 'loose indentation' (https://forums.alliedmods.net/showthread.php?t=24791)

XenomX 03-02-2006 15:27

General question 'loose indentation'
 
Hello, finally got my account activated :D.

I just have a general question, i get several errors when compiling my plugin, loose indentation (line 100)

Line 100 says:
sql = dbi_connect(mhost,muser,mpass,mdb,merror,128)

and another error refers to this line of code:
if(sql <= SQL_FAILED)

My question, what doen this mean, loos indentation? Do i need to declare something? sql is declared at the top as: new Sql:sql

Thanks in advance,
Xenom.

Freecode 03-02-2006 15:34

your spacing is wrong. Learn general/basic programming syntax.

XenomX 03-02-2006 15:45

Well, i've got the same errors with this plugin (SQLBAN for AMXX), that should work right? Approved plugin.

See below SQLBAN (amxbans.sma)

Code:
/* * *    Mysql Ban Management for STEAM *     *    Author: kaksi *    Email: <a href="mailto:[email protected]">[email protected]</a> *    Web: <a href="http://www.gbgonline.net/" target="_blank" rel="nofollow noopener">http://www.gbgonline.net/</a> * *    Thanks to: *    JustinHoMi - A lot of code comes from his MySQL Ban Management plugin *    n1ghtmr - I got a lot of inspiration from his MYSQL Ban control - By Wonid/ip and Rcon plugin *    Neurosis - Beta testing and debugging * *    INSTALLATION *     *    ->Create the database by using the schema below *    ->Add the following line to amx.cfg with you database info: *     *        amx_sqlban_host "127.0.0.1" - Adress to the SQL server *        amx_sqlban_user "root" - SQL Server username *        amx_sqlban_pass "" - SQL server password *        amx_sqlban_db "amx" - The database where you created the table * *    -> Compile the plugin and put in amx plugin folder *    -> Add the plugin to plugins.ini *    -> Restart you server and you are good to go * * *    INSTRUCTIONS * *    You can only ban players that are on the server * *    Ban EITHER SteamID or IP adress by typing: *    amx_ban1 <time> <name, userid, or ip> <reason> *    If ban is entered by name or userid the player is banned by steamid *    If ban is entered by IP adress the player is banned by ipaddres * *    Ban BOTH SteamID AND IP Adress by typing: *    xban <time> <name, userid or ip> <reason> *    If ban is enterd by name, userid or IP BOTH SteamID AND IP adress will be banned * */ /* SQL Schema CREATE TABLE `xbans` (   `player_steamid` varchar(100) NOT NULL default '',   `player_name` varchar(100) NOT NULL default '',   `player_ip` varchar(100) NOT NULL default '',   `reason` varchar(128) NOT NULL default '',   `bantype` varchar(50) NOT NULL default '',   `admin_steamid` varchar(100) NOT NULL default '',   `admin_name` varchar(100) NOT NULL default '',   `admin_ip` varchar(100) NOT NULL default '',   `length` int(10) unsigned NOT NULL default '0',   `time_created` timestamp(14) NOT NULL,   `server` varchar(25) NOT NULL default '',   PRIMARY KEY  (`player_steamid`) ) TYPE=MyISAM; */ #include <amxmodx>   #include <amxmisc>   #include <dbi> new Sql:sql new merror[128] new mhost[64]   new muser[32]   new mpass[32]   new mdb[32]   new server[128] //------------------------------------------------- START Plugin initilize ----------------------------------------// public plugin_init(){     register_plugin("SQLBan Mgr","0.1","kaksi")       register_concmd("amx_ban","sql_ban",ADMIN_BAN,"<mins> <nick|userid|> [reason]")     register_cvar("amx_sqlban_host","127.0.0.1")       register_cvar("amx_sqlban_user","user")       register_cvar("amx_sqlban_pass","pass")       register_cvar("amx_sqlban_db","amx")       register_cvar("amx_sqlban_prefix","")       return PLUGIN_CONTINUE   } //------------------------------------------------- END Plugin initilize ----------------------------------------// //------------------------------------------------- START CONNECT TO DATABASAE ----------------------------------------// public sql_init(){           //Get server and database info...     get_cvar_string("hostname",server,127)       get_cvar_string("amx_sql_host",mhost,64)       get_cvar_string("amx_sql_user",muser,32)       get_cvar_string("amx_sql_pass",mpass,32)       get_cvar_string("amx_sql_db",mdb,32)     sql = dbi_connect(mhost,muser,mpass,mdb,merror,128)     if(sql <= SQL_FAILED)         server_print("[AMXX][SQLBAN] MySQL error: could not connect : '%s'",merror)       else           server_print("[AMXX][SQLBAN] Successfully connected to the database.")     return PLUGIN_CONTINUE   } //------------------------------------------------- END CONNECT TO DATABASAE ----------------------------------------// //------------------------------------------------- START Player Connects Player ----------------------------------------// public client_connect(id){              new parm[1]       parm[0] = id     //Delay check, wait for steamid to be set     set_task(5.0,"check_delayed",0,parm,1)             return PLUGIN_HANDLED } //------------------------------------------------- End Player connects Player ----------------------------------------// //------------------------------------------------- START Delayed check connecting player ----------------------------------------// public check_delayed(parm[]){           //Load database connection function     sql_init()           //Get connecting clients steamid and ipadress     new client_steamid[40]       get_user_authid(parm[0],client_steamid,50)       new client_ip[16]       get_user_ip(parm[0],client_ip,15,1)     new client_name[40]     get_user_name(parm[0],client_name,40)           //Send a message to the server that a check is starting     server_print("[AMXX][SQLBAN] Checking if %s is in the databaase.",client_name)     //Format the database querry     new query[256]       format(query,255,"SELECT player_steamid,player_ip,reason,bantype,length,now()-time_created FROM xbans WHERE player_steamid='%s' OR player_ip='%s'",client_steamid,client_ip)       //Execute querry     dbi_query(mysql,query)       new merror[64]       dbi_error(mysql,merror,63)           //If an error occured     if (merror[0]){           server_print("[AMXX][SQLBAN] MYSQL error: %s",merror)         return PLUGIN_CONTINUE       }         //If a player was found in the database, fetch data and define     if(dbi_nextrow(mysql)>0){           new player_steamid[40],player_ip[20],reason[128],bantype[50],ban_length_s[10],ban_time_s[32]         dbi_field(mysql,1,player_steamid,39)         dbi_field(mysql,2,player_ip,19)         dbi_field(mysql,3,reason,127)         dbi_field(mysql,4,bantype,49)         dbi_field(mysql,5,ban_length_s,9)           dbi_field(mysql,6,ban_time_s,31)         //Get the new ban_lengt and bantime           new ban_length = str_to_num(ban_length_s)           new ban_time = str_to_num(ban_time_s)           //If the players bantime isn't up...         if ((ban_time < ban_length) || (ban_length == 0)){                       //If the ban_length is permanent, format the time message             new time_msg[32]               if (ban_length == 0){                   time_msg = "Permanent"             }             //If the time is not permanent, format the time message             else{                   new ban_left = (ban_length - ban_time) / 60                   format(time_msg,31,"%i minutes",ban_left)               }             //If the player is banned by steamid, send a message and disconnect the player             if(equal(bantype,"steamid")){                 //Check if the players SteamID is the same as in the dataase                 if(equal(client_steamid,player_steamid)){                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your SteamID has been banned from this server.^"")                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                       client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                     client_cmd(parm[0],"disconnect")                     server_print("servern hittade steamid i databasen")                     return PLUGIN_CONTINUE                 }             }                                   //If the player is banned by IP, send a message and disconnect the player             if(equal(bantype,"ip")){                 //Check if the players ip adress is the same as in the database                 if(equal(client_ip,player_ip)){                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your IP adress has been banned from this server.^"")                       client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                       client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                     client_cmd(parm[0],"disconnect")                     return PLUGIN_CONTINUE                 }             }                           //If the player is banned by BOTH SteamID and IP Adress, send a message and disconnect the player             if(equal(bantype,"all")){                 //Check if The players steamid is the same as in the database                 if(equal(client_steamid,player_steamid)){                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your SteamID and IP Adress has been banned from this server.^"")                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                       client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                     client_cmd(parm[0],"disconnect")                     server_print("servern hittade steamid i databasen")                     return PLUGIN_CONTINUE                 }                 //If the steamid doesnt math then check if the ip adress match                 else if(equal(client_ip,player_ip)){                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your SteamID and IP Adress has been banned from this server.^"")                     client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                       client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                     client_cmd(parm[0],"disconnect")                     server_print("servern hittade steamid i databasen")                     return PLUGIN_CONTINUE                 }                 }         }               //If the bantime has expired         else{                 //Remove the expired ban from the database                       //Format the querry             format(query,255,"DELETE from xbans where player_steamid='%s'",client_steamid)                         //Execute the querry             dbi_query(mysql,query)                  dbi_error(mysql,merror,63)                              //If an error uccures                if (merror[0]){                     server_print("[AMXX][SQLBAN] MYSQL error: %s",merror)                     return PLUGIN_HANDLED                  }                            //If the expired ban is removed completely                else{                     console_print(parm[0],"[AMXX][SQLBAN] Ban on steamid %s removed.",client_steamid)                  }          }       }     //If player wasn't in the database...     else{         server_print("[AMXX][SQLBAN] %s wans't in the database. Let him in...",client_name)     }     return PLUGIN_CONTINUE   } //------------------------------------------------- END Delayed check connecting player ----------------------------------------// //------------------------------------------------- START Ban Player by SteamID OR IP Adress ----------------------------------------// public sql_ban(id,level,cid){     //Load database connection function     sql_init()     //If the player you are trying to ban has admin rights the stop     if (!cmd_access(id,level,cid,4))       return PLUGIN_HANDLED           //Define the player identifier and read it from the given command     new player_ident[40]     read_argv(2,player_ident,39)     //Define the bantype variable     new bantype[20]     //See if you can find a matching player by nickname     new player = find_player("bl",player_ident)                          //If a player was found, check to see if there are more than one match        if (player){         new player2 = find_player("blj",player_ident)                   //If more than one match, then stop         if (player!=player2){               console_print(id,"There are more than one players matching your argument.")               return PLUGIN_CONTINUE         }         //If all went well and only one player was found, set bantype to steamid         bantype = "steamid"     }           //If no player was found by nickname, check if there is a match with userid       if (!player && player_ident[0]=='#' && player_ident[1])         player = find_player("k",str_to_num(player_ident[1]))           //If there was a player match with userid set bantype to steamid     bantype = "steamid"         //If no matching player with userid either, then check if there is a match with IP adress     if (!player){           player = find_player("d",player_ident)                   //If there was a match with IP adress set bantype to IP         bantype = "ip"     }       //If no match was found, abort...     if (!player){           console_print(id,"Client with that authid, nick, userid, or ip not found.")           return PLUGIN_CONTINUE       }       //Make sure we don't ban bots     if (is_user_bot(player)){                             new imname[32]           get_user_name(player,imname,31)           console_print(id,"You can not ban bots.")           return PLUGIN_CONTINUE       }         //Get ban length and convert to seconds       new ban_length_s[10],ban_length_s2[10]       read_argv(1,ban_length_s,9)       new multiplier = 60       new carg       if(contain(ban_length_s,"h") != -1){           multiplier = 60 * 60           carg = 'h'          }else        if(contain(ban_length_s,"d") != -1){           multiplier = 60 * 60 * 24           carg = 'd'       }else     if(contain(ban_length_s,"w") != -1){           multiplier = 60 * 60 * 24 * 7           carg = 'w'       }       copyc(ban_length_s2,9,ban_length_s,carg)       new ban_length = str_to_num(ban_length_s2) * multiplier       //Get reason and get ready to format it       new text[64],temp[10],temp2[33]       read_args(text,63)       parse(text,temp,9,temp2,32)       new length1 = strlen(temp)       new length2 = strlen(temp2)       new length = length1 + length2       length+=2         new reason[64]       read_args(reason,63)         //Get user and admin info to put in table       new player_steamid[40],player_name[33],player_ip[20],admin_steamid[40],admin_name[33],admin_ip[20]     get_user_authid(player,player_steamid,39)       get_user_name(player,player_name,32)     get_user_ip(player,player_ip,19,1)           get_user_authid(id,admin_steamid,39)       get_user_name(id,admin_name,32)     get_user_ip(id,admin_ip,19,1)         //Format the query       new query[512]       format(query,511,"INSERT into xbans (player_steamid,player_name,player_ip,reason,bantype,admin_steamid,admin_name,admin_ip,length,server) values('%s','%s','%s','%s','%s','%s','%s','%s','%i','%s')",player_steamid,player_name,player_ip,reason[length],bantype,admin_steamid,admin_name,admin_ip,ban_length,server)       // connect to database and insert data       dbi_query(mysql,query)       new merror[64]       dbi_error(mysql,merror,63)             //If an error uccures     if (merror[0]){           server_print("[AMXX][SQLBAN] MYSQL error: %s",merror)           return PLUGIN_HANDLED       }         // convert ban length back to minutes for display       ban_length = ban_length / 60         //Print ban to server     console_print(id,"[AMXX][SQLBAN] Banning %s for %i",player_name,ban_length)             //Format time message       new time_msg[32]     //If the ban length is 0 (permanent)     if (ban_length == 0)           time_msg = "Permanent"     //Else, formate the time message     else           format(time_msg,31,"%i minutes",ban_length)             //If the user is banned by steamid, print the message to the user     if(equal(bantype,"steamid")){               client_cmd(player,"echo ^"[AMXX][SQLBAN] Your SetamID has been banned from this server.^"")           client_cmd(player,"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)           client_cmd(player,"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)         client_cmd(player,"disconnect")                           return PLUGIN_CONTINUE     }               //If the user is banned by IP, print the message to the user     if(equal(bantype,"ip")){         client_cmd(player,"echo ^"[AMXX][SQLBAN] Your IP adress has been banned from this server.^"")           client_cmd(player,"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)           client_cmd(player,"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)         client_cmd(player,"disconnect")         return PLUGIN_CONTINUE     }                 //If there is a database connection, close it     if (mysql > 0)         dbi_close(mysql)                 return PLUGIN_HANDLED     }   //------------------------------------------------- END Ban Player by SteamID OR IP Adress ----------------------------------------//                 //If there is a database connection, close it     if (mysql > 0)         dbi_close(mysql)                 return PLUGIN_HANDLED     }   //------------------------------------------------- END Ban Player by BOTH SteamID AND IP Adress ----------------------------------------//

Brad 03-02-2006 16:01

Loose indentation means you have a mix of tab and space indentations instead of all tabs.

XenomX 03-02-2006 16:24

Ok.

So, 2 tabs and 2 spaces is wrong?
Or isn't that what you meant?

PM 03-02-2006 16:39

The compiler interpretes tabs as a specified number of spaces. I think you can set this up using #pragma tabsize or something.

XenomX 03-02-2006 16:46

Ok, im going to try this tommorow.
Going to bed now, thanks.

Brad 03-02-2006 19:31

Quote:

Originally Posted by XenomX
So, 2 tabs and 2 spaces is wrong?
Or isn't that what you meant?

What I mean is, choose one or the other. Either always use tabs or always use spaces to indent. Don't use both.

Jordan 03-02-2006 19:39

Code:
/*   *   *    Mysql Ban Management for STEAM   *       *    Author: kaksi   *    Email: <a href="mailto:[email protected]">[email protected]</a>   *    Web: <a href="http://www.gbgonline.net/" target="_blank" rel="nofollow noopener">http://www.gbgonline.net/</a>   *   *    Thanks to:   *    JustinHoMi - A lot of code comes from his MySQL Ban Management plugin   *    n1ghtmr - I got a lot of inspiration from his MYSQL Ban control - By Wonid/ip and Rcon plugin   *    Neurosis - Beta testing and debugging   *   *    INSTALLATION   *       *    ->Create the database by using the schema below   *    ->Add the following line to amx.cfg with you database info:   *       *        amx_sqlban_host "127.0.0.1" - Adress to the SQL server   *        amx_sqlban_user "root" - SQL Server username   *        amx_sqlban_pass "" - SQL server password   *        amx_sqlban_db "amx" - The database where you created the table   *   *    -> Compile the plugin and put in amx plugin folder   *    -> Add the plugin to plugins.ini   *    -> Restart you server and you are good to go   *   *   *    INSTRUCTIONS   *   *    You can only ban players that are on the server   *   *    Ban EITHER SteamID or IP adress by typing:   *    amx_ban1 <time> <name, userid, or ip> <reason>   *    If ban is entered by name or userid the player is banned by steamid   *    If ban is entered by IP adress the player is banned by ipaddres   *   *    Ban BOTH SteamID AND IP Adress by typing:   *    xban <time> <name, userid or ip> <reason>   *    If ban is enterd by name, userid or IP BOTH SteamID AND IP adress will be banned   *   */   /* SQL Schema   CREATE TABLE `xbans` (     `player_steamid` varchar(100) NOT NULL default '',     `player_name` varchar(100) NOT NULL default '',     `player_ip` varchar(100) NOT NULL default '',     `reason` varchar(128) NOT NULL default '',     `bantype` varchar(50) NOT NULL default '',     `admin_steamid` varchar(100) NOT NULL default '',     `admin_name` varchar(100) NOT NULL default '',     `admin_ip` varchar(100) NOT NULL default '',     `length` int(10) unsigned NOT NULL default '0',     `time_created` timestamp(14) NOT NULL,     `server` varchar(25) NOT NULL default '',     PRIMARY KEY  (`player_steamid`)   ) TYPE=MyISAM;   */   #include <amxmodx>   #include <amxmisc>   #include <dbi>   new Sql:mysql new Result:ret new merror[128] new mhost[64]   new muser[32]   new mpass[32]   new mdb[32]   new server[128]   new time_msg[32]   //------------------------------------------------- START Plugin initilize ----------------------------------------//   public plugin_init() {       register_plugin("SQLBan Mgr","0.1","kaksi")       register_concmd("amx_ban","sql_ban",ADMIN_BAN,"<mins> <nick|userid|> [reason]")       register_cvar("amx_sqlban_host","127.0.0.1")       register_cvar("amx_sqlban_user","user")       register_cvar("amx_sqlban_pass","pass")       register_cvar("amx_sqlban_db","amx")       register_cvar("amx_sqlban_prefix","")       return PLUGIN_CONTINUE   }   //------------------------------------------------- END Plugin initilize ----------------------------------------//   //------------------------------------------------- START CONNECT TO DATABASAE ----------------------------------------//   public sql_init() {       //Get server and database info...       get_cvar_string("hostname",server,127)       get_cvar_string("amx_sql_host",mhost,64)       get_cvar_string("amx_sql_user",muser,32)       get_cvar_string("amx_sql_pass",mpass,32)       get_cvar_string("amx_sql_db",mdb,32)       mysql = dbi_connect(mhost,muser,mpass,mdb,merror,128)     if(mysql <= SQL_FAILED)         server_print("[AMXX][SQLBAN] MySQL error: could not connect : '%s'",merror)       else           server_print("[AMXX][SQLBAN] Successfully connected to the database.")       return PLUGIN_CONTINUE   }   //------------------------------------------------- END CONNECT TO DATABASAE ----------------------------------------//   //------------------------------------------------- START Player Connects Player ----------------------------------------//   public client_connect(id) {       new parm[1]       parm[0] = id       //Delay check, wait for steamid to be set       set_task(5.0,"check_delayed",0,parm,1)           return PLUGIN_HANDLED   }   //------------------------------------------------- End Player connects Player ----------------------------------------//   //------------------------------------------------- START Delayed check connecting player ----------------------------------------//   public check_delayed(parm[]) {       //Load database connection function       sql_init()             //Get connecting clients steamid and ipadress       new client_steamid[40]       get_user_authid(parm[0],client_steamid,50)       new client_ip[16]       get_user_ip(parm[0],client_ip,15,1)       new client_name[40]       get_user_name(parm[0],client_name,40)             //Send a message to the server that a check is starting       server_print("[AMXX][SQLBAN] Checking if %s is in the databaase.",client_name)       //Format the database querry       new query[256]       format(query,255,"SELECT player_steamid,player_ip,reason,bantype,length,now()-time_created FROM xbans WHERE player_steamid='%s' OR player_ip='%s'",client_steamid,client_ip)       //Execute querry       dbi_query(mysql,query)       new merror[64]       dbi_error(mysql,merror,63)             //If an error occured       if (merror[0])     {           server_print("[AMXX][SQLBAN] MYSQL error: %s",merror)           return PLUGIN_CONTINUE       }             //If a player was found in the database, fetch data and define       if(dbi_nextrow(ret)>0)     {           new player_steamid[40],player_ip[20],reason[128],bantype[50],ban_length_s[10],ban_time_s[32]           dbi_field(ret,1,player_steamid,39)           dbi_field(ret,2,player_ip,19)           dbi_field(ret,3,reason,127)           dbi_field(ret,4,bantype,49)           dbi_field(ret,5,ban_length_s,9)           dbi_field(ret,6,ban_time_s,31)           //Get the new ban_lengt and bantime           new ban_length = str_to_num(ban_length_s)           new ban_time = str_to_num(ban_time_s)           //If the players bantime isn't up...           if ((ban_time < ban_length) || (ban_length == 0))         {                     //If the ban_length is permanent, format the time message           if (ban_length == 0)         {               time_msg = "Permanent"           }           //If the time is not permanent, format the time message           else         {               new ban_left = (ban_length - ban_time) / 60               format(time_msg,31,"%i minutes",ban_left)           }                   //If the player is banned by steamid, send a message and disconnect the player           if(equal(bantype,"steamid"))         {               //Check if the players SteamID is the same as in the dataase               if(equal(client_steamid,player_steamid))             {                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your SteamID has been banned from this server.^"")                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                   client_cmd(parm[0],"disconnect")                   server_print("servern hittade steamid i databasen")                   return PLUGIN_CONTINUE               }         }             }           //If the player is banned by IP, send a message and disconnect the player         if(equal(bantype,"ip"))         {               //Check if the players ip adress is the same as in the database               if(equal(client_ip,player_ip))             {                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your IP adress has been banned from this server.^"")                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                   client_cmd(parm[0],"disconnect")                   return PLUGIN_CONTINUE               }           }           //If the player is banned by BOTH SteamID and IP Adress, send a message and disconnect the player           if(equal(bantype,"all"))         {               //Check if The players steamid is the same as in the database               if(equal(client_steamid,player_steamid))             {                 client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your SteamID and IP Adress has been banned from this server.^"")                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                   client_cmd(parm[0],"disconnect")                   server_print("servern hittade steamid i databasen")                   return PLUGIN_CONTINUE               }               //If the steamid doesnt math then check if the ip adress match               else if(equal(client_ip,player_ip))             {                 client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Your SteamID and IP Adress has been banned from this server.^"")                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)                   client_cmd(parm[0],"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)                   client_cmd(parm[0],"disconnect")                   server_print("servern hittade steamid i databasen")                   return PLUGIN_CONTINUE               }           }        }                 //If the bantime has expired           else     {         //Remove the expired ban from the database         //Format the querry                   format(query,255,"DELETE from xbans where player_steamid='%s'",client_steamid)                 //Execute the querry                   dbi_query(mysql,query)           dbi_error(mysql,merror,63)                 //If an error uccures           if (merror[0])         {             server_print("[AMXX][SQLBAN] MYSQL error: %s",merror)               return PLUGIN_HANDLED         }                         //If the expired ban is removed completely                     else         {               console_print(parm[0],"[AMXX][SQLBAN] Ban on steamid %s removed.",client_steamid)           }       }             //If player wasn't in the database...     server_print("[AMXX][SQLBAN] %s wans't in the database. Let him in...",client_name)       return PLUGIN_CONTINUE   }   //------------------------------------------------- END Delayed check connecting player ----------------------------------------//   //------------------------------------------------- START Ban Player by SteamID OR IP Adress ----------------------------------------//   public sql_ban(id,level,cid) {       //Load database connection function       sql_init()       //If the player you are trying to ban has admin rights the stop       if (!cmd_access(id,level,cid,4))           return PLUGIN_HANDLED             //Define the player identifier and read it from the given command       new player_ident[40]       read_argv(2,player_ident,39)       //Define the bantype variable       new bantype[20]       //See if you can find a matching player by nickname       new player = find_player("bl",player_ident)                       //If a player was found, check to see if there are more than one match       if (player)     {           new player2 = find_player("blj",player_ident)                   //If more than one match, then stop           if (player!=player2)         {               console_print(id,"There are more than one players matching your argument.")               return PLUGIN_CONTINUE           }             //If all went well and only one player was found, set bantype to steamid           bantype = "steamid"       }             //If no player was found by nickname, check if there is a match with userid       if (!player && player_ident[0]=='#' && player_ident[1])           player = find_player("k",str_to_num(player_ident[1]))             //If there was a player match with userid set bantype to steamid       bantype = "steamid"             //If no matching player with userid either, then check if there is a match with IP adress       if (!player)     {           player = find_player("d",player_ident)                 //If there was a match with IP adress set bantype to IP           bantype = "ip"       }       //If no match was found, abort...       if (!player)     {           console_print(id,"Client with that authid, nick, userid, or ip not found.")           return PLUGIN_CONTINUE       }       //Make sure we don't ban bots       if (is_user_bot(player))     {                             new imname[32]           get_user_name(player,imname,31)           console_print(id,"You can not ban bots.")           return PLUGIN_CONTINUE       }             //Get ban length and convert to seconds       new ban_length_s[10],ban_length_s2[10]       read_argv(1,ban_length_s,9)       new multiplier = 60       new carg       if(contain(ban_length_s,"h") != -1)     {           multiplier = 60 * 60           carg = 'h'       }     else if(contain(ban_length_s,"d") != -1)     {           multiplier = 60 * 60 * 24           carg = 'd'       }     else if(contain(ban_length_s,"w") != -1)     {           multiplier = 60 * 60 * 24 * 7           carg = 'w'       }       copyc(ban_length_s2,9,ban_length_s,carg)       new ban_length = str_to_num(ban_length_s2) * multiplier       //Get reason and get ready to format it       new text[64],temp[10],temp2[33]       read_args(text,63)       parse(text,temp,9,temp2,32)       new length1 = strlen(temp)       new length2 = strlen(temp2)       new length = length1 + length2       length+=2             new reason[64]       read_args(reason,63)             //Get user and admin info to put in table       new player_steamid[40],player_name[33],player_ip[20],admin_steamid[40],admin_name[33],admin_ip[20]       get_user_authid(player,player_steamid,39)       get_user_name(player,player_name,32)       get_user_ip(player,player_ip,19,1)               get_user_authid(id,admin_steamid,39)       get_user_name(id,admin_name,32)       get_user_ip(id,admin_ip,19,1)       //Format the query       new query[512]       format(query,511,"INSERT into xbans (player_steamid,player_name,player_ip,reason,bantype,admin_steamid,admin_name,admin_ip,length,server) values('%s','%s','%s','%s','%s','%s','%s','%s','%i','%s')",player_steamid,player_name,player_ip,reason[length],bantype,admin_steamid,admin_name,admin_ip,ban_length,server)       // connect to database and insert data       dbi_query(mysql,query)       new merror[64]       dbi_error(mysql,merror,63)             //If an error uccures       if (merror[0])     {           server_print("[AMXX][SQLBAN] MYSQL error: %s",merror)           return PLUGIN_HANDLED       }             // convert ban length back to minutes for display       ban_length = ban_length / 60             //Print ban to server       console_print(id,"[AMXX][SQLBAN] Banning %s for %i",player_name,ban_length)             //Format time message       new time_msg[32]       //If the ban length is 0 (permanent)       if (ban_length == 0)           time_msg = "Permanent"       //Else, formate the time message       else           format(time_msg,31,"%i minutes",ban_length)               //If the user is banned by steamid, print the message to the user       if(equal(bantype,"steamid"))     {           client_cmd(player,"echo ^"[AMXX][SQLBAN] Your SetamID has been banned from this server.^"")           client_cmd(player,"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)           client_cmd(player,"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)           client_cmd(player,"disconnect")                   return PLUGIN_CONTINUE       }                   //If the user is banned by IP, print the message to the user       if(equal(bantype,"ip"))     {           client_cmd(player,"echo ^"[AMXX][SQLBAN] Your IP adress has been banned from this server.^"")           client_cmd(player,"echo ^"[AMXX][SQLBAN] Reason: %s.^"",reason)           client_cmd(player,"echo ^"[AMXX][SQLBAN] Time left: %s.^"",time_msg)           client_cmd(player,"disconnect")           return PLUGIN_CONTINUE       }                   //If there is a database connection, close it       if (mysql == SQL_OK)     {         dbi_close(mysql)         return PLUGIN_HANDLED     }                 return PLUGIN_HANDLED     }   //------------------------------------------------- END Ban Player by SteamID OR IP Adress ----------------------------------------//
Compiles with no errors.

mysticssjgoku4 03-02-2006 20:12

If you're just re-indenting a plugin, and not starting from scratch, I recommend you use AMXX Studio's indentation function.
But, if your coding from scratch, remember, after each { make a new line and tab over 1 more time than the previous line.

Example:
Code:
public function(id) // This is the first line | Notice it is not indented. { // This would technically be the second line, but it doesn't count since it is a starting bracket containing code below it.     new authid[32] // This is the true second line, notice this is tabbed over just once.     get_user_authid(id,authid,31)     client_print(id,print_chat,"SteamID: %s",authid)     return PLUGIN_HANDLED } public function(id) // First Line { // ---------     if(!is_user_connected(id)) // Second Line | Notice it is tabbed 1 time.     { // ----         return PLUGIN_HANDLED // Third Line | Notice it is tabbed 2 times.     }         new authid[32] // Sixth Line | Notice it is tabbed 1 time.     get_user_authid(id,authid,31)     client_print(id,print_chat,"SteamID: %s",authid)     return PLUGIN_HANDLED }

Notice how it should be formatted. Just apply those basic rules to your future works.
I personally prefer tabs, because they are much easier to work with, and to do instead of hitting the spacebar 5 times.


All times are GMT -4. The time now is 20:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.