Report system

Started by gamingpro, Mar 28, 2023, 10:50 PM

Previous topic - Next topic

gamingpro

function onScriptLoad()
[noae]
rp <- ConnectSQL("Reports.db");
QuerySQL(rp, "CREATE TABLE IF NOT EXISTS Report( plr TEXT, player TEXT, Reason TEXT)");
print("report system has been loaded successfully by gamingpro...");
[/noae]
function onScriptUnload()
[noae]
DisconnectSQL( rp );
[/noae]
function onPlayerCommand( player, command, text )
[noae]
local cmd;
cmd = command.tolower();
if(cmd == "report"){
if(!text) MessagePlayer("[#FF0000]Error: [#FFFFFF]Correct Syntax /"+cmd+" <Player> <Reason>",player);
else {
local plr = GetPlayer(GetTok(text, " ",1));
local reason = GetTok(text, " ",2 NumTok(text, " "));
if(!plr) MessagePlayer("[#FF0000]Error: [#FFFFFF]Unknow player...",player);
else if(plr.Name == player.Name) MessagePlayer("[#FF0000]Error: [#FFFFFF]You can't report your self!.",player);
else {
if(!reason) reason = "No_Reason";
QuerySQL(rp, "INSERT INTO Report(plr,player,Reason) VALUES('"+plr.Name+"', '"+player.Name+"', '"+reason

+"')");
MessagePlayer("[#00FF00][REPORT]: [#FFFFFF]Thank you for your report admins now have notifed!.",player);
Message("[#00FF00][REPORT]: [#FFFFFF]"+player.Name+" Has reported:[ "+plr.Name+" ] For Reason: "+reason);
}
}
}
else if(cmd == "reportlist"){
local q = QuerySQL(rp, "SELECT * FROM Report"), i = 1;
if(!q) MessagePlayer("[#FFFFFF]No players currently have report!.",player);
else {
while( GetSQLColumnData(q,0) != null ){
MessagePlayer("[#00FF00][REPORT]: [#FFFFFF]Reporter:[ "+GetSQLColumnData(q,1)+" ], Suspected:[ "+GetSQLColumnData(q,0)+" ], Reason: "+GetSQLColumnData(q,2),player);
GetSQLNextRow(q);
i++;
}
}
}
[/noae]
if You have this functions don't add it again
[noae]
function GetTok( string, separator, n, ... )
{
 local m = ( vargv.len() > 0 ) ? vargv[ 0 ] : n, tokenized = split( string, separator ), text = "";

 if ( ( n > tokenized.len() ) || ( n < 1 ) ) return null;

 for ( ; n <= m; n++ )
 {
  text += text == "" ? tokenized[ n - 1 ] : separator + tokenized[ n - 1 ];
 }

 return text;
}
function NumTok(string, separator)
{
    local tokenized = split(string, separator);
    return tokenized.len();
}
function GetPlayer( target )
{
 local target1 = target.tostring();

 if ( IsNum( target ) )
 {
  target = target.tointeger();

  if ( FindPlayer( target) ) return FindPlayer( target );
  else return null;
 }
 else if ( FindPlayer( target ) ) return FindPlayer( target );
 else return null;
}
[/noae]

habi

You could instead of saying 'Report System',  tell a bit more:  what is it, what does it dowhat are the commands..

*says to himself: 'that spammer from somewhere is gone' (yesterday the forum was flooded)

gamingpro

#2
ah ah it's if players spammed or hacks or any thing u mean that ?.