Attemp to call string

Started by CopyPaste, Jul 17, 2015, 12:46 PM

Previous topic - Next topic

CopyPaste

if ( cmd == "kick" )
    {
      if ( !text ) MessagePlayer( "Correct syntax : /kick <id> <reason>", player );
      else if ( split(text, " ").len() < 2) return MessagePlayer("Correct syntax : /kick <id> <reason>", player )
      else
   {
   local a = split(text, " "), plr = FindPlayer( text.tointeger() ), player = FindPlayer( text.tointeger() );
if ( !IsNum( a[0] ) || text( a[1] )) MessagePlayer( "Format: /kick <id> <reason>", player );
      else {
  KickPlayer( a[0].tointeger() );
  Message( "Format: /kick <"+a[0]+"> <"+a[1]">" );
  }
      }
   }

Error : Attempt to call String

DizzasTeR

Alright hold on, ABRA KADABRA!

.
.
.

Well looks like there is no magic we can use to get the line number automatically that causes the error.

CopyPaste

>.< It is kickplayer not working

.

How faking hard is it to understand a message like that :-\

local dafuq = "you're trying to do";

print( dafuq() );

// 'dafuq' is a string.
// why 'dafuq' are you trying to use it as a function?
.

[VSS]Shawn

cant understand yor code if u want use this

if ( cmd == "kick" )
    {
      if ( !text ) MessagePlayer( "Correct syntax : /kick <id> <reason>", player );
      else
   {
   local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "Invalid ID", player );
       else {
   KickPlayer( plr );
   Message( "Admin " + player.Name + " kick " + plr.Name + "." );
   }
      }
   }

DizzasTeR

KickPlayer( FindPlayer( a[0].tointeger() ) );

Don't look at the crap what shawn posted, its the same command except the thing that command has gotten the player instance, which you didn't, the KickPlayer function needs an instance not a string.

KAKAN

#6
Quote from: [VSS]Shawn on Jul 17, 2015, 01:50 PMcant understand yor code if u want use this

if ( cmd == "kick" )
    {
      if ( !text ) MessagePlayer( "Correct syntax : /kick <id> <reason>", player );
      else
   {
   local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "Invalid ID", player );
       else {
   KickPlayer( plr );
   Message( "Admin " + player.Name + " kick " + plr.Name + "." );
   }
      }
   }

Woa, if someone will type the ID there, the cmd is not gonna work
Its a copy paste from somewhere

EDIT:
You have just pasted this, with some edits,, right??

EDIT #2:
Better use my code
    else if ( cmd == "kick" )
{
       if ( !text ) MessagePlayer( "Error - Syntax: /kick <player> <reason>", player);
       else
       {
         local plr = GetPlayer( GetTok( text, " ", 1 ) );
         if ( !plr ) MessagePlayer( "Error - Unknown player.", player);
         else
         {
           local reason = GetTok( text, " ", 2 );
           if ( !reason ) reason = "None";
           Message( "" + plr.Name + " have been kicked. Reason: " + reason + "" );
           EchoMessage( "" + plr.Name + " have been kicked. Reason: " + reason + "" );
           plr.Kick();
         }
       }
    }
oh no

CopyPaste

Please help me how to fix  i changed that line to
if ( !IsNum( a[0] ) || !text( a[1] )) MessagePlayer( "Format: /kick <id> <reason>", player );
     

.

#8
Quote from: CopyPaste on Jul 17, 2015, 04:00 PMPlease help me how to fix

Oh go F* your self. I'm pretty much getting tired of retards like you coming here with some shitty code and a simple error message. Never saying where the error occurs or giving some proper information that would help people to locate the issue.

So we're pretty much forced to guess and shit around the code you posted because we can't possibly test code just like that out of context. And when we finally give you the code you're like "I don't understaaaaand!". Well, f* me. Why did you even ask in the first place?

IF YOU CAN'T PROPERLY ASK A FAKIN QUESTION THEN STOP ASKING AND GET THE F* OUT OF HERE BECAUSE WE'RE PRETTY MUCH TIRED OF SHITBAGS LIKE YOU
.

Ksna

#9
hey bro You need this?

if ( cmd == "kick" ){
      if ( !text ) MessagePlayer( "Correct syntax : /kick <id> <reason>", player );
      else if ( split(text, " ").len() < 2) return MessagePlayer("Correct syntax : /kick <id> <reason>", player )
      else {
local a = split(text, " ");
if ( !IsNum( a[0] ) || IsNum( a[1] ) ) MessagePlayer( "Format: /kick <id> <reason>", player );
else {
KickPlayer( FindPlayer( a[0].tointeger() ) );
Message( "You have Kicked <"+FindPlayer( a[0].tointeger())+"> <"+text.slice(a[0].len() + 1)+">" );
}
}
   }

If you need any other help pm me  :)

CopyPaste

Exactly , that was what I want thanks   :)

and sorry slc im noob at scripting please don't read my topics :(

DizzasTeR

Quote from: CopyPaste on Jul 17, 2015, 05:04 PMExactly , that was what I want thanks   :)

Just tell me what the hell did I post up there, compare your whole command, and check whats the main difference in Ksna's command and your command and then check my reply...

You people really don't deserve help, you just want ready-to-use scripts.

[VSS]Shawn

Lol Fucking Kakan Check out your code GetPlayer does not exist fucker
add function and i am not copy paster like u

MatheuS

GetPlayer Function:

function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return false;
        }
    else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return false;
        }
    }
    else return false;
}
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Thijn

Perma-Banned CopyPaste. He and Ksna are the same person. So for some reason he does come up with the right script.
If you can do it yourself, or copy it from somewhere else. Great! Just don't come here with another account and answer your own question like that.
S.L.C. gave you the reason why it wasn't working, and you did nothing with that answer.



Quote from: MatheuS on Jul 17, 2015, 06:54 PMGetPlayer Function:
..
That code makes no sense.

if ( plr ) { .. }
else { plr = FindPlayer( plr ); }

When is that ever going to work? Sure if you actually specify plr the function works, but that else makes no sense at all.