como reparar funcion /ban

Started by kennedyarz, Mar 29, 2016, 12:03 AM

Previous topic - Next topic

kennedyarz

tengo un problema y no se como resolverlo, tengo una función de prohibir muy fácil pero al momento de prohibir un jugador coloco /ban nombre de jugador ejemplo:

/ban EL_CAPO(ARZ)          y sale:

[BAN] Admin (kennedyarz) banned (kennedyarz)

en realidad si prohibe pero quero la funcion de pubico al que selecciones pero el el chat aparece eso



ahora lo que necesito es la función de receptor osea repito
/ban EL_CAPO(ARZ) y aparezca

[BAN] Admin kennedyarz banned EL_CAPO(ARZ)

link pastebin:

http://pastebin.com/1s53ZDrW

Mötley

#1
I do not understand the language, But::

If I read that code correctly if I am on the server when you are not then anyone can use your user_name and lock you out of the server and ban every player. Not a very wise choice.

When someone joins the server and uses kennedyarZ when you are on the server you will also obtain a glitch were the server will give them admin status/usage

Luis_Labarca

in inglesh : one translator all hey bro usa what you post in the forum of the third must be in English
in Spanish : oye bro usa un traductor todo lo que publiques en el forum del vcmp tiene que ser en ingles

translator : http://www.bing.com/translator/


You can use this function is what I use


agg in onPlayerCommand

function onPlayerCommand( player, cmd, text )
{

else if ( cmd == "ban" )
{
if ( !text ) MessagePlayer("Usage: /"+cmd+" [Nick/ID] [reason]", player );
else if ( Stats[ player.ID ].Level < 4 ) MessagePlayer( " you're not admin.", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("Unknown player", player );
else {
local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
if ( !reason ) MessagePlayer("Usage: /"+cmd+" [Nick/ID] [reason]", player );
else {
Banned( plr, player, reason );
}
}
}
}


else if ( cmd == "unban" )
{
local q = QuerySQL(Bans, "SELECT * FROM Banneds WHERE Name='"+text+"'" );
if ( !text ) MessagePlayer("Usage: /" + cmd + " [Full/Nick]", player );
else if ( Stats[ player.ID ].Level < 4 ) MessagePlayer("you're not admin.", player );
else if ( GetSQLColumnData(q, 0 ) != text ) MessagePlayer("played not this banned :[ "+text+" ] .", player );
else {
MessagePlayer("Admin ["+player.Name+"] Unbanned to :[ "+text+" ].",player);
QuerySQL( Bans, "DELETE FROM Banneds WHERE Name='"+text+"'" );
}
}

}









at the bottom in functions

function CheckBanned( p )
{
local q = QuerySQL( Bans, "SELECT * FROM Banneds WHERE UniqueID='" + p.UniqueID + "'" );
local uid = GetSQLColumnData( q, 2 );
if ( uid ) return 1;
else return 0;
}


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( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
       else
        {
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

agg in onplayer join



function onPlayerJoin( player )
{
if ( CheckBanned( player ) == 1 )
{
Message("[#7FFF00]Auto-Kick:[ "+player.Name+" ] Reason:[ Banned From This Server ].");
KickPlayer( player );
}
}




agg in onscriptload

function onScriptLoad()
{

Bans <- ConnectSQL( "Bans.db" );
QuerySQL(Bans,"CREATE TABLE IF NOT EXISTS Banneds(Name VARCHAR(32), IP TEXT, UniqueID VARCHAR(25), Admin TEXT, Reason TEXT )" );
}


men if there a bug let me know ;)

ysc3839

Quote from: Luis_Labarca on Mar 29, 2016, 04:25 AMin inglesh : one translator all hey bro usa what you post in the forum of the third must be in English
in Spanish : oye bro usa un traductor todo lo que publiques en el forum del vcmp tiene que ser en ingles

translator : http://www.bing.com/translator/


You can use this function is what I use


agg in onPlayerCommand

function onPlayerCommand( player, cmd, text )
{

else if ( cmd == "ban" )
{
if ( !text ) MessagePlayer("Usage: /"+cmd+" [Nick/ID] [reason]", player );
else if ( Stats[ player.ID ].Level < 4 ) MessagePlayer( " you're not admin.", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("Unknown player", player );
else {
local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
if ( !reason ) MessagePlayer("Usage: /"+cmd+" [Nick/ID] [reason]", player );
else {
Banned( plr, player, reason );
}
}
}
}


else if ( cmd == "unban" )
{
local q = QuerySQL(Bans, "SELECT * FROM Banneds WHERE Name='"+text+"'" );
if ( !text ) MessagePlayer("Usage: /" + cmd + " [Full/Nick]", player );
else if ( Stats[ player.ID ].Level < 4 ) MessagePlayer("you're not admin.", player );
else if ( GetSQLColumnData(q, 0 ) != text ) MessagePlayer("played not this banned :[ "+text+" ] .", player );
else {
MessagePlayer("Admin ["+player.Name+"] Unbanned to :[ "+text+" ].",player);
QuerySQL( Bans, "DELETE FROM Banneds WHERE Name='"+text+"'" );
}
}

}









at the bottom in functions

function CheckBanned( p )
{
local q = QuerySQL( Bans, "SELECT * FROM Banneds WHERE UniqueID='" + p.UniqueID + "'" );
local uid = GetSQLColumnData( q, 2 );
if ( uid ) return 1;
else return 0;
}


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( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
       else
        {
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

agg in onplayer join



function onPlayerJoin( player )
{
if ( CheckBanned( player ) == 1 )
{
Message("[#7FFF00]Auto-Kick:[ "+player.Name+" ] Reason:[ Banned From This Server ].");
KickPlayer( player );
}
}




agg in onscriptload

function onScriptLoad()
{

Bans <- ConnectSQL( "Bans.db" );
QuerySQL(Bans,"CREATE TABLE IF NOT EXISTS Banneds(Name VARCHAR(32), IP TEXT, UniqueID VARCHAR(25), Admin TEXT, Reason TEXT )" );
}


men if there a bug let me know ;)

Don't use VARCHAR in SQLite, because it doesn't have VARCHAR and will treat VARCHAR as TEXT.

MatheuS

Simple and easy to fix this

if ( cmd == "ban" )
    {
        if ( player.Name == "kennedyarz" )
        {
            if ( text )
            {
           local plr = FindPlayer( text );
               if ( plr )
               {
               Message( "[#AC9000][BANNED] ADMIN [#ffffff]" + player.Name + "  [#ff1111]Banned [#ffffff]" + player.Name );
               BanPlayer( plr );
               }
               else MessagePlayer( "[#ffffff]Invalid Player " , player );
            }
            else MessagePlayer( "[#ffffff]Type /ban <player> " , player );
        }
        else MessagePlayer( "[#F02F0F] comando utilizado por admin nivel [#ac9000][:::#3#:::]. " , player )
    }
}
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

EK.IceFlake

No, VARCHAR allows supposedly infinite characters according to SQLite. There are no arguments. This is a matter of fact. I have tested it.

Mötley

#6
I can guarantee using if ( player.Name == "kennedyarz" ) is horrible In the aspect that anyone could lock the owner out of the server ( or crash the owner)  and use his name. As well in VC:MP I could use the name KennedyarZ and become admin, Extremly possible if kennedyarz is on the server the same time as the altered name.

:: Suggestion do not use if ( player.Name == "kennedyarz" ) if you do not have a admin system use hidden cmd names that only you know

example:

Replace

if ( cmd == "ban" )to
if ( cmd == "logitech" ) for you ban instead of player,name

maybe create a /command message so you can see the hidden admin commands
I did this on one of my servers. as i didnt take the time to build the admin system

Example:::

if ( cmd == "logitech" )
{
    if ( !text ) MessagePlayer( "[#ff0000]!![#ffffff]SOMTHINGS WRONG[#ff0000]!!")
    eles if ( text )
    {
       local plr = FindPlayer(text.tointeger());//Now you just type the players ID
       if ( plr )
       {
           Message( "[#AC9000][BANNED] ADMIN [#ffffff]" + player.Name + "  [#ff1111]Banned [#ffffff]" + plr.Name );
           BanPlayer( plr );
       }
    }
}

just a modified version of MatheuS code

KAKAN

Quote from: NE.CrystalBlue on Mar 29, 2016, 05:38 PMNo, VARCHAR allows supposedly infinite characters according to SQLite. There are no arguments. This is a matter of fact. I have tested it.
255 or 555 is the max limit. You can check it in phpMyAdmin( MySQL )
oh no

Luis_Labarca

Quote from: ysc3839 on Mar 29, 2016, 05:43 AM
Quote from: Luis_Labarca on Mar 29, 2016, 04:25 AMin inglesh : one translator all hey bro usa what you post in the forum of the third must be in English
in Spanish : oye bro usa un traductor todo lo que publiques en el forum del vcmp tiene que ser en ingles

translator : http://www.bing.com/translator/


You can use this function is what I use


agg in onPlayerCommand

function onPlayerCommand( player, cmd, text )
{

else if ( cmd == "ban" )
{
if ( !text ) MessagePlayer("Usage: /"+cmd+" [Nick/ID] [reason]", player );
else if ( Stats[ player.ID ].Level < 4 ) MessagePlayer( " you're not admin.", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer("Unknown player", player );
else {
local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
if ( !reason ) MessagePlayer("Usage: /"+cmd+" [Nick/ID] [reason]", player );
else {
Banned( plr, player, reason );
}
}
}
}


else if ( cmd == "unban" )
{
local q = QuerySQL(Bans, "SELECT * FROM Banneds WHERE Name='"+text+"'" );
if ( !text ) MessagePlayer("Usage: /" + cmd + " [Full/Nick]", player );
else if ( Stats[ player.ID ].Level < 4 ) MessagePlayer("you're not admin.", player );
else if ( GetSQLColumnData(q, 0 ) != text ) MessagePlayer("played not this banned :[ "+text+" ] .", player );
else {
MessagePlayer("Admin ["+player.Name+"] Unbanned to :[ "+text+" ].",player);
QuerySQL( Bans, "DELETE FROM Banneds WHERE Name='"+text+"'" );
}
}

}









at the bottom in functions

function CheckBanned( p )
{
local q = QuerySQL( Bans, "SELECT * FROM Banneds WHERE UniqueID='" + p.UniqueID + "'" );
local uid = GetSQLColumnData( q, 2 );
if ( uid ) return 1;
else return 0;
}


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( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
       else
        {
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}

agg in onplayer join



function onPlayerJoin( player )
{
if ( CheckBanned( player ) == 1 )
{
Message("[#7FFF00]Auto-Kick:[ "+player.Name+" ] Reason:[ Banned From This Server ].");
KickPlayer( player );
}
}




agg in onscriptload

function onScriptLoad()
{

Bans <- ConnectSQL( "Bans.db" );
QuerySQL(Bans,"CREATE TABLE IF NOT EXISTS Banneds(Name VARCHAR(32), IP TEXT, UniqueID VARCHAR(25), Admin TEXT, Reason TEXT )" );
}


men if there a bug let me know ;)

Don't use VARCHAR in SQLite, because it doesn't have VARCHAR and will treat VARCHAR as TEXT.

good men I have as well and work me so then I put it to text thank you for the help

Luis_Labarca

Quote from: kennedyarz on Mar 29, 2016, 12:03 AMtengo un problema y no se como resolverlo, tengo una función de prohibir muy fácil pero al momento de prohibir un jugador coloco /ban nombre de jugador ejemplo:

/ban EL_CAPO(ARZ)          y sale:

[BAN] Admin (kennedyarz) banned (kennedyarz)

en realidad si prohibe pero quero la funcion de pubico al que selecciones pero el el chat aparece eso



ahora lo que necesito es la función de receptor osea repito
/ban EL_CAPO(ARZ) y aparezca

[BAN] Admin kennedyarz banned EL_CAPO(ARZ)

link pastebin:

http://pastebin.com/1s53ZDrW


hey men usa un sistema de level para que quites el  if ( player.Name == "kennedyarz" ) porque si yo entro a tu server con tu nombre podria dar ban a todos

Mötley

Es por eso que dice que sólo tiene que utilizar cmd ocultos

Motivo (Para que pueda centrarse en el diseño del servidor en lugar de un sistema de administración)
Él puede hacer esto en otro momento

.

@Thijn move this from the snippets section, please.
.