Jump to content
  • 0

Ban System


celmaitarevip

Question

[pawn]#if defined BanSystem

----------( CREDITS )----------

  SQLite  - SA-MP Team

  ZCMD    - Zeex

  sscanf2 - Y_Less

  GPVSEx  - Zh3r0

  Script  - Hardwell

----------( CREDITS )----------

#endif

#include    <a_samp>

#include    <zcmd>

#include    <sscanf2>

main() { }

#define R  "{F81414}"

#define B  "{00C0FF}"

#define W  "{FFFFFF}"

#define C_R 0xF81414FF

#define C_B 0x00C0FFFF

#define C_G 0xC3C3C3FF

#define SCM SendClientMessage

new DB:DB;

public OnGameModeInit()

{

DB = db_open("Bans.db");

db_query(DB,"CREATE TABLE IF NOT EXISTS `Bans`(`Name` TEXT,\

  `IP` TEXT,\

  `BanDate` TEXT,\

  `byAdmin` TEXT,\

  `Reason` TEXT)");

return 1;

}

public OnGameModeExit()

{

db_close(DB);

return 1;

}

public OnPlayerConnect(playerid)

{

new

Query[129],

DBResult:Result;

format(Query,sizeof(Query),"SELECT * FROM `Bans` WHERE `Name` = '%s' OR `IP` = '%s'",GetName(playerid),GetIP(playerid));

Result = db_query(DB,Query);

if(Result)

{

if(db_num_rows(Result))

{

    new Field[128];

db_get_field_assoc(Result,"BanDate",Field,sizeof(Field)); SetPVarString(playerid,"BanDate",Field);

db_get_field_assoc(Result,"byAdmin",Field,sizeof(Field)); SetPVarString(playerid,"byAdmin",Field);

db_get_field_assoc(Result,"Reason",Field,sizeof(Field));  SetPVarString(playerid,"Reason",Field);

new bStr[256];

format(bStr,sizeof(bStr),""W"Ban Date: "B"%s\n\

    "W"by Admin: "B"%s\n\

    "W"Reason: "B"%s",GPVSEx(playerid,"BanDate"),GPVSEx(playerid,"byAdmin"),GPVSEx(playerid,"Reason"));

ShowPlayerDialog(playerid,5000,DIALOG_STYLE_MSGBOX,""R"Banned",bStr,"Close","");

SetTimerEx("KickAfter",2 * 1000,false,"i",playerid);

}

}

return 1;

}

forward KickAfter(playerid);

public KickAfter(playerid) Kick(playerid);

CMD:ban(playerid,params[])

{

if(sscanf(params,"us[129]",params[0],params[1])) return SCM(playerid,C_B,"USAGE: "W"/ban <id> [reason]");

if(!IsPlayerConnected(params[0])) return SCM(playerid,C_R,"ERROR: "W"Player is not connected!");

if(params[0] == playerid) return SCM(playerid,C_R,"ERROR: "W"Player entered is you!");

new Query[256];

format(Query,sizeof(Query),"INSERT INTO `Bans`(`Name`,\

  `IP`,\

  `BanDate`,\

  `byAdmin`,\

  `Reason`) VALUES ('%s','%s','%s','%s','%s')",GetName(params[0]),GetIP(params[0]),GetDate(),GetName(playerid),params[1]);

db_query(DB,Query);

Kick(params[0]);

return 1;

}

CMD:unban(playerid,params[])

{

if(sscanf(params,"s",params[0])) return SCM(playerid,C_B,"USAGE: "W"/unban <name>");

new

Query[129],

    DBResult:Result;

format(Query,sizeof(Query),"SELECT * FROM `Bans` WHERE `Name` = '%s'",params[0]);

Result = db_query(DB,Query);

if(Result)

{

if(db_num_rows(Result))

{

format(Query,sizeof(Query),"DELETE FROM `Bans` WHERE `Name` = '%s'",params[0]);

db_query(DB,Query);

SCM(playerid,C_G,"INFO: Name has been unbaned.");

}

else SCM(playerid,C_R,"ERROR: "W"This name is not banned!");

}

db_free_result(Result);

return 1;

}

GetName(playerid)

{

new szName[MAX_PLAYER_NAME];

GetPlayerName(playerid,szName,sizeof(szName));

return szName;

}

GetIP(playerid)

{

new szIP[20];

GetPlayerIp(playerid,szIP,sizeof(szIP));

return szIP;

}

GetDate()

{

new

    dStr[30],

    D[6];

   

getdate(D[0],D[1],D[2]);

gettime(D[3],D[4],D[5]);

format(dStr,sizeof(dStr),"%i/%i/%i %i:%i:%i",D[2],D[1],D[0],

D[3],D[4],D[5]);

return dStr;

}

GPVSEx(playerid,pvstr[])

{

new pStr[129];

GetPVarString(playerid,pvstr,pStr,sizeof(pStr));

return pStr;

}[/pawn]

[glow=green,2,300]Vreau sa fac sistemu asta pentru admin nivel 5.Nu pentru rcon. Am incercat cu:[/glow]

[pawn]if(AccInfo[playerid][Level] >= 5))[/pawn]

[glow=green,2,300]Dar imi da erori. Tin sa va zic ca sunt nou in scripting si nu ma prea pricep. Sper ca ma ajuta si pe mine cineva. Multumesc mult  :grin:[/glow]

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

[glow=green,2,300]Ce am modificat[/glow]

[pawn]#if defined BanSystem

----------( CREDITS )----------

  SQLite  - SA-MP Team

  ZCMD    - Zeex

  sscanf2 - Y_Less

  GPVSEx  - Zh3r0

  Script  - Hardwell

----------( CREDITS )----------

#endif

#include    <a_samp>

#include    <zcmd>

#include    <sscanf2>

main() { }

#define R  "{F81414}"

#define B  "{00C0FF}"

#define W  "{FFFFFF}"

#define C_R 0xF81414FF

#define C_B 0x00C0FFFF

#define C_G 0xC3C3C3FF

#define SCM SendClientMessage

new DB:DB;

public OnGameModeInit()

{

DB = db_open("Bans.db");

db_query(DB,"CREATE TABLE IF NOT EXISTS `Bans`(`Name` TEXT,\

  `IP` TEXT,\

  `BanDate` TEXT,\

  `byAdmin` TEXT,\

  `Reason` TEXT)");

return 1;

}

public OnGameModeExit()

{

db_close(DB);

return 1;

}

public OnPlayerConnect(playerid)

{

new

Query[129],

DBResult:Result;

format(Query,sizeof(Query),"SELECT * FROM `Bans` WHERE `Name` = '%s' OR `IP` = '%s'",GetName(playerid),GetIP(playerid));

Result = db_query(DB,Query);

if(Result)

{

if(db_num_rows(Result))

{

    new Field[128];

db_get_field_assoc(Result,"BanDate",Field,sizeof(Field)); SetPVarString(playerid,"BanDate",Field);

db_get_field_assoc(Result,"byAdmin",Field,sizeof(Field)); SetPVarString(playerid,"byAdmin",Field);

db_get_field_assoc(Result,"Reason",Field,sizeof(Field));  SetPVarString(playerid,"Reason",Field);

new bStr[256];

format(bStr,sizeof(bStr),""W"Ban Date: "B"%s\n\

    "W"by Admin: "B"%s\n\

    "W"Reason: "B"%s",GPVSEx(playerid,"BanDate"),GPVSEx(playerid,"byAdmin"),GPVSEx(playerid,"Reason"));

ShowPlayerDialog(playerid,5000,DIALOG_STYLE_MSGBOX,""R"Banned",bStr,"Close","");

SetTimerEx("KickAfter",2 * 1000,false,"i",playerid);

}

}

return 1;

}

forward KickAfter(playerid);

public KickAfter(playerid) Kick(playerid);

CMD:ban(playerid,params[])

{

if(AccInfo[playerid][Level] >= 5)

{

if(sscanf(params,"us[129]",params[0],params[1])) return SCM(playerid,C_B,"USAGE: "W"/ban <id> [reason]");

if(!IsPlayerConnected(params[0])) return SCM(playerid,C_R,"ERROR: "W"Player is not connected!");

if(params[0] == playerid) return SCM(playerid,C_R,"ERROR: "W"Player entered is you!");

new Query[256];

format(Query,sizeof(Query),"INSERT INTO `Bans`(`Name`,\

  `IP`,\

  `BanDate`,\

  `byAdmin`,\

  `Reason`) VALUES ('%s','%s','%s','%s','%s')",GetName(params[0]),GetIP(params[0]),GetDate(),GetName(playerid),params[1]);

db_query(DB,Query);

Kick(params[0]);

return 1;

}

CMD:unban(playerid,params[])

{

if(AccInfo[playerid][Level] >= 5)

{

if(sscanf(params,"s",params[0])) return SCM(playerid,C_B,"USAGE: "W"/unban <name>");

new

Query[129],

    DBResult:Result;

format(Query,sizeof(Query),"SELECT * FROM `Bans` WHERE `Name` = '%s'",params[0]);

Result = db_query(DB,Query);

if(Result)

{

if(db_num_rows(Result))

{

format(Query,sizeof(Query),"DELETE FROM `Bans` WHERE `Name` = '%s'",params[0]);

db_query(DB,Query);

SCM(playerid,C_G,"INFO: Name has been unbaned.");

}

else SCM(playerid,C_R,"ERROR: "W"This name is not banned!");

}

db_free_result(Result);

return 1;

}

GetName(playerid)

{

new szName[MAX_PLAYER_NAME];

GetPlayerName(playerid,szName,sizeof(szName));

return szName;

}

GetIP(playerid)

{

new szIP[20];

GetPlayerIp(playerid,szIP,sizeof(szIP));

return szIP;

}

GetDate()

{

new

    dStr[30],

    D[6];

   

getdate(D[0],D[1],D[2]);

gettime(D[3],D[4],D[5]);

format(dStr,sizeof(dStr),"%i/%i/%i %i:%i:%i",D[2],D[1],D[0],

D[3],D[4],D[5]);

return dStr;

}

GPVSEx(playerid,pvstr[])

{

new pStr[129];

GetPVarString(playerid,pvstr,pStr,sizeof(pStr));

return pStr;

}[/pawn]

[glow=green,2,300]Erorile:[/glow]

[pawn]BanSystem.pwn(56) : error 017: undefined symbol "GetName"

BanSystem.pwn(72) : error 017: undefined symbol "GPVSEx"

BanSystem.pwn(86) : error 017: undefined symbol "AccInfo"

BanSystem.pwn(86) : warning 215: expression has no effect

BanSystem.pwn(86) : error 001: expected token: ";", but found "]"

BanSystem.pwn(86) : error 029: invalid expression, assumed zero

BanSystem.pwn(86) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

6 Errors.[/pawn]

[glow=green,2,300]Nu stiu cum sa fac :(( , ma poti ajuta te rog frumos?[/glow]

Link to comment
Share on other sites

Invatati sa aranjati un script, i-a NotePad++ si aranjeaza intregul script, cu acolade paranteze cum trebuie si vei vedea ca sunt 2 acolade care sunt puse bine dar nu se inchid bine ! ... daca nu scriptati aranjat logic ca aveti erori 8-|


F*ck everybody who want and who try to judge me for who I am, b*star*s !

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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. For more details you can also review our Terms of Use and Privacy Policy.