28.07.2012, 06:23
Code:
stock BanPlayer(playerid,AdministratorID,Reason[],Time) { new String[150]; format(String,150,"INSERT INTO `Bans` SET `BanUserName` = '%s',`BanUserIp` = '%s',`BanAdministratorName` = '%s',`BanReason` = '%s',`BanTime` = '%i'",UserName[playerid],UserIp[playerid],UserName[AdministratorID],Reason,Time); new DBResult:DatabaseResult = db_query(Database,String); db_free_result(DatabaseResult); Kick(playerid); return 1; }
Code:
public OnPlayerConnect(playerid) { GetPlayerName(playerid,UserName[playerid],30); GetPlayerIp(playerid,UserIp[playerid],30); BanPlayer(playerid,playerid,"Nothing",30324); new DBResult:DatabaseResult = db_query(Database,"SELECT * FROM `Bans` WHERE `BanUserReason` = 'Nothing`"); if(db_num_rows(DatabaseResult)) { new String[150]; db_get_field_assoc(DatabaseResult,"BanUserName",String,30); printf(String); db_get_field_assoc(DatabaseResult,"BanUserIp",String,30); printf(String); db_get_field_assoc(DatabaseResult,"BanAdministratorName",String,30); printf(String); db_get_field_assoc(DatabaseResult,"BanUserReason",String,150); printf(String); db_get_field_assoc(DatabaseResult,"BanUserTime",String,30); printf(String); } db_free_result(DatabaseResult); return 1; }
Code:
#include <a_samp> #define MAXIMAL_PLAYERS 500 new DB:Database; new UserName[MAXIMAL_PLAYERS][30]; new UserIp[MAXIMAL_PLAYERS][30]; public OnGameModeInit() { Database = db_open("Server.db"); new DBResult:DatabaseResult = db_query(Database,"CREATE TABLE IF NOT EXISTS `Bans` (`BanUserName` VARCHAR(30),`BanUserIp` VARCHAR(30),`BanAdministratorName` VARCHAR(30),`BanReason` VARCHAR(150),`BanTime` INT(30));"); db_free_result(DatabaseResult); return 1; } public OnGameModeExit() { db_close(Database); return 1; }