Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: kokia on Jul 22, 2015, 03:35 PM

Title: unban probelm
Post by: kokia on Jul 22, 2015, 03:35 PM
hello all in script when i ban player it works but unban not works pls help no error comes the code is :
else if ( cmd == "unban" )
{
   if ( IsNoob( player, cmd ) ) return 0;
   else if ( !text ) ePrivMessage( "Syntax, / " + cmd + " <Full Nick>", player );
   else if ( CheckBan( text ) == 0 ) ePrivMessage( "Error - " + text + " is not Banned.", player );
   else DelBan( player, text );
}
delban:
function DelBan( admin, banned )
{
    QuerySQL( db, "DELETE FROM Bans WHERE Name='" + banned + "'" );
rMessage( "** Admin " + admin + " UnBanned Player:[ " + banned + " ]" );
}
Title: Re: unban probelm
Post by: [VSS]Shawn on Jul 22, 2015, 03:38 PM
can u post which error show on console?
Title: Re: unban probelm
Post by: kokia on Jul 22, 2015, 03:38 PM
no erro
Title: Re: unban probelm
Post by: EK.IceFlake on Jul 22, 2015, 03:43 PM
Query where you create tables?
(CREATE TABLE IF NOT EXISTS Bans ...)
Title: Re: unban probelm
Post by: kokia on Jul 22, 2015, 03:48 PM
here
▄︻̷̿┻̿═━一
QuerySQL( db, "CREATE TABLE IF NOT EXISTS Bans ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT )" );
. [̲̅$̲̅(̲̅5̲̅)̲̅$̲̅].
Title: Re: unban probelm
Post by: kokia on Jul 23, 2015, 04:56 AM
plz help
Title: Re: unban probelm
Post by: [VSS]Shawn on Jul 23, 2015, 05:21 AM
set rMessage to Message
Title: Re: unban probelm
Post by: Thijn on Jul 23, 2015, 05:43 AM
What actually happens? Do you get every message you should get, but aren't being unbanned?
And post your ban command.
Title: Re: unban probelm
Post by: kokia on Jul 23, 2015, 07:04 AM
i dont get any msg i will post my ban cmd once i am on my pc wait
Title: Re: unban probelm
Post by: EK.IceFlake on Jul 23, 2015, 07:29 AM
rMessage( "** Admin " + admin + " UnBanned Player:[ " + banned + " ]" );
Find the problem with it.
[spoiler]You passed admin as instance, now trying to put it in string. Fix it yourself.
[spoiler]Change "admin" to "admin.Name"[/spoiler][/spoiler]
Title: Re: unban probelm
Post by: [VSS]Shawn on Jul 23, 2015, 07:59 AM
On Command DelBan( player, text )
In function DelBan( admin, banned ) Wow

Use this DelBan Function


function DelBan( player, text )
{
    QuerySQL( db, "DELETE FROM Bans WHERE Name='" + text + "'" );
 Message( "** Admin " + player.Name + " UnBanned Player: " + text + "." );
}
Title: Re: unban probelm
Post by: DizzasTeR on Jul 23, 2015, 08:16 AM
Quote from: [VSS]Shawn on Jul 23, 2015, 07:59 AMOn Command DelBan( player, text )
In function DelBan( admin, banned ) Wow

You stupid moron, we can change the defined variables differently, that doesn't affect the script at all as long as the arguments passed are correct. So:

function onScriptLoad() {
    local msg = "Hello world!";
    local fact = "Shawn can't script";

    PrintData( msg, fact );
}

function PrintData( strine, totally_correct ) {
    print( format( "%s %s", string, totally_correct ) )

}

I know you won't even try to learn from that and end up having an error on this small script which you can't fix yourself.

As for the topic, provide enough info and code so it is atleast possible to check for errors..

Crystal caught the error already.
Title: Re: unban probelm
Post by: kokia on Jul 23, 2015, 08:24 AM
Quote from: [VSS]Shawn on Jul 23, 2015, 07:59 AMOn Command DelBan( player, text )
In function DelBan( admin, banned ) Wow

Use this DelBan Function


function DelBan( player, text )
{
    QuerySQL( db, "DELETE FROM Bans WHERE Name='" + text + "'" );
 Message( "** Admin " + player.Name + " UnBanned Player: " + text + "." );
}

not works
my ban cmd
        else if ( cmd == "ban" )
        {
   if ( IsNoob( player, cmd ) ) return 0;
   else if ( !text ) PrivMessage( "Syntax, /" + cmd + " <nick> <reason>", player );
   local plr = GetPlayer( GetTok( text, " ", 1 ) );
   if ( !plr ) PrivMessage( "Invalid Player Nick /ID!", player );
   else
   {
      local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
  if ( reason == null ) reason = "None";
  Ban( plr, player, reason );
   }
}
this ban cmd works
now error even with crystal's script is
[SCRIPT]  OnPlayerCommand Error: the index 'Name' does not exist
Title: Re: unban probelm
Post by: KAKAN on Jul 23, 2015, 08:27 AM
In which line does it shows, and plz post that line too
Title: Re: unban probelm
Post by: kokia on Jul 23, 2015, 08:27 AM
no line it just say that index name doesnt exists
Title: Re: unban probelm
Post by: Thijn on Jul 23, 2015, 08:36 AM
Removed your try { } catch block from the onPlayerCommand.
Title: Re: unban probelm
Post by: kokia on Jul 23, 2015, 08:42 AM
yes no work
Title: Re: unban probelm
Post by: MacTavish on Jul 23, 2015, 08:45 AM
Post the following things

Unban function
A screenshot of your ban table
Title: Re: unban probelm
Post by: Thijn on Jul 23, 2015, 08:54 AM
Quote from: Beztone on Jul 23, 2015, 08:45 AMPost the following things

Unban function
A screenshot of your ban table
He posted all those.
Title: Re: unban probelm
Post by: KAKAN on Jul 23, 2015, 09:00 AM
Post ur onPlayerCommand
Title: Re: unban probelm
Post by: MacTavish on Jul 23, 2015, 09:17 AM
Try it

else if ( cmd == "unban" )
{
if ( IsNoob( player, cmd ) ) return 0;
   else if ( !text ) MessagePlayer("/" + cmd + " <Full Nick>", player );
        else
{
local q = QuerySQL( db, "SELECT * FROM Bans WHERE Name='" + text + "' COLLATE NOCASE" );
if ( GetSQLColumnData(q, 0) )
                {
    QuerySQL(db, "DELETE FROM Bans WHERE Name='" + text + "'");
EchoMessage("Admin " + player.Name + " Has Un-Banned " + text + "");
   Message("Admin " + player.Name + " Has Un-Banned " + text + "");
    }
    else MessagePlayer("Invalid Nick/ID Specified!",player );
    FreeSQLQuery( q );
    }
}


If it didnt work then do as @Thijn says here (http://forum.vc-mp.org/?topic=1094.msg7281#msg7281)
Title: Re: unban probelm
Post by: KAKAN on Jul 23, 2015, 09:51 AM
Yup post ur ban function as well as the ban cmd
Title: Re: unban probelm
Post by: kokia on Jul 23, 2015, 10:24 AM
@beztone thanks