Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: PsyChO_KiLLeR on Mar 06, 2015, 08:21 AM

Title: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:21 AM
Well i have question can we use onplayercommand2 of ! because i see it in little whitey server 0.4
Title: Re: OnPlayerCommand2
Post by: . on Mar 06, 2015, 08:29 AM
Have you thought that it might be a custom function which is not a part of the official API? Well, if you want that '2' so much then why not:
function onPlayerCommand2(player, cmd, args)
{
// Like a boss!
}

function onPlayerCommand(player, cmd, args)
{
onPlayerCommand2(player, cmd, args);
}

Also, might this be some leaked script?
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:31 AM
where i add this? onPlayerCommand2(player, cmd, args);
in playercommand?
Title: Re: OnPlayerCommand2
Post by: . on Mar 06, 2015, 08:34 AM
Quote from: PsyChO_KiLLeR on Mar 06, 2015, 08:31 AMwhere i add this? onPlayerCommand2(player, cmd, args);
in playercommand?

Add it in there. You know. That place ;) That special place.
Title: Re: OnPlayerCommand2
Post by: jayant on Mar 06, 2015, 08:36 AM
Do that magic on that special event !! On that special event you have to assign your prefix "!" or it can b "a" etc.
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:36 AM
its not adding in onplayercommand it give error of expression expected
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:38 AM
i also add it in playerchat it say cmd does not exist
Title: Re: OnPlayerCommand2
Post by: MacTavish on Mar 06, 2015, 08:42 AM
Paste this in your cmds.nutonPlayerCommand2(player, cmd, text)
{
//just put your commands here
}
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:47 AM
nothing happen when i add just this on commands.nut and open server and type command with ! it didnt show anything and no error on console
Title: Re: OnPlayerCommand2
Post by: jayant on Mar 06, 2015, 08:47 AM
function onPlayerChat( player, text )
{
   
if ( text )
{
if ( text.slice( 0, 1 ) == "!" )//Here you assign prefix for your onPlayerCommand2
{
local i = NumTok( text, " " ), xp = null;

if ( i == 1 ) onPlayerCommand2( player, GetTok( text.slice( 1 ), " ", 1 ), xp );
else onPlayerCommand2( player, GetTok( text.slice( 1 ), " ", 1 ), GetTok( text.slice( 1 ), " ", 2, i ) );
}
        }
}
Ensure that you have Numtok and gettok...Or update them.
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:51 AM
nothing happen again no error on console
Title: Re: OnPlayerCommand2
Post by: . on Mar 06, 2015, 08:52 AM
Quote from: jayant on Mar 06, 2015, 08:47 AM...

Why slice when you can simply access the specific character :-\
local str = "test string";

print(str[0]); // Output should be 116
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 08:53 AM
what it is?
Title: Re: OnPlayerCommand2
Post by: jayant on Mar 06, 2015, 08:55 AM
Quote from: S.L.C on Mar 06, 2015, 08:52 AM
Quote from: jayant on Mar 06, 2015, 08:47 AM...

Why slice when you can simply access the specific character :-\
local str = "test string";

print(str[0]); // Output should be 116
I am not aware of that SLC. I will give that a try. :)
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 09:21 AM
can anyone help?
Title: Re: OnPlayerCommand2
Post by: karan20000000000 on Mar 06, 2015, 09:28 AM
u momo spammer
Put this code below onPlayerChat or replace ur old onPlayerChat
function onPlayerChat(player,text)
{
                        if(text[0].tochar().tostring()=="!") { local texto=split(text,"! "); local momo=""; for(local i=1;i<texto.len();i++){momo=momo+texto[i]+" ";} onPlayerCommand2(player,texto[0],momo); }
             //rest of stuff here
}

function onPlayerCommand2(player,cmd,text)
{
       //ur momo cmds here
}

Note: I haven't tested this ^
Title: Re: OnPlayerCommand2
Post by: EK.IceFlake on Mar 06, 2015, 09:31 AM
Quote from: PsyChO_KiLLeR on Mar 06, 2015, 09:21 AMcan anyone help?
Noone is helping you until you clearly and specifically tell us what you are trying to achieve.
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 10:13 AM
nothing happen again no error nothing
Title: Re: OnPlayerCommand2
Post by: MacTavish on Mar 06, 2015, 10:19 AM
Post your onPlayerChat function here
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 10:23 AM
function onPlayerChat(player,text)
{
if(text[0].tochar().tostring()=="!") { local texto=split(text,"! "); local momo=""; for(local i=1;i<texto.len();i++){momo=momo+texto[i]+" ";} onPlayerCommand2(player,texto[0],momo); }
             if ( text == "brb" )
     {

          Message( player.Name + " will Be Right Back! " );
          player.IsFrozen = true;

     }
    if ( text == "bbs" )
     {

          Message( player.Name + " will Be Back Soon! " );
          player.IsFrozen = true;

     }
     if ( text == "bbl" )
     {

          Message( player.Name + " will Be Back Later! " );
          player.IsFrozen = true;

     }
   if ( text == "back" )
     {

          Message( player.Name + " is Back! " );
          player.IsFrozen = false;

     }
if ( status[ player.ID ].mute == true )
{
ePrivMessage("pm >> Your Message was not sent because you're muted! By Admin", player);
return 0;
}
    Message("[" + player.ID +"] "+ player.Name + ": " + text.tostring() + "\n");
    Message(cred+"" + player.Name + " : "+cwhite+""+ text.tostring());
}
Title: Re: OnPlayerCommand2
Post by: MacTavish on Mar 06, 2015, 10:31 AM
Try this

function onPlayerChat(player,text)
{
if ( status[ player.ID ].mute == true )
{
 ePrivMessage("pm >> Your Message was not sent because you're muted! By Admin", player);
 return 0;
}
if ( text )
{
if ( text.slice( 0, 1 ) == "!" )
{
local i = NumTok( text, " " ), xp = null;

if ( i == 1 ) onPlayerCommand2( player, GetTok( text.slice( 1 ), " ", 1 ), xp );
else onPlayerCommand2( player, GetTok( text.slice( 1 ), " ", 1 ), GetTok( text.slice( 1 ), " ", 2, i ) );
}
    }
             if ( text == "brb" )
     {

          Message( player.Name + " will Be Right Back! " );
          player.IsFrozen = true;

     }
    else if ( text == "bbs" )
     {

          Message( player.Name + " will Be Back Soon! " );
          player.IsFrozen = true;

     }
     else if ( text == "bbl" )
     {

          Message( player.Name + " will Be Back Later! " );
          player.IsFrozen = true;

     }
   else if ( text == "back" )
     {

          Message( player.Name + " is Back! " );
          player.IsFrozen = false;

     }
     Message("[" + player.ID +"] "+ player.Name + ": " + text.tostring() + "\n");
    Message(cred+"" + player.Name + " : "+cwhite+""+ text.tostring());
}
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 10:34 AM
not working no error
Title: Re: OnPlayerCommand2
Post by: . on Mar 06, 2015, 10:41 AM
If there's no error then it means it's working. Except you don't see it ;)
Title: Re: OnPlayerCommand2
Post by: MacTavish on Mar 06, 2015, 10:42 AM
I wanna die, I wanna die, I wanna die, (https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fwww.sherv.net%2Fcm%2Femoticons%2Ffighting%2Fbash-head.gif&hash=7586c528d2a216303acc8ddcbcc7c1fa02e8ccd5)

 :-\ :-[
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 06, 2015, 10:46 AM
i always type !lol
its not working
Title: Re: OnPlayerCommand2
Post by: KingOfVC on Mar 06, 2015, 11:01 AM
Quote from: PsyChO_KiLLeR on Mar 06, 2015, 10:46 AMi always type !lol
its not working

Quote from: Beztone on Mar 06, 2015, 10:42 AMI wanna die, I wanna die, I wanna die, (https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fwww.sherv.net%2Fcm%2Femoticons%2Ffighting%2Fbash-head.gif&hash=7586c528d2a216303acc8ddcbcc7c1fa02e8ccd5)

 :-\ :-[
Title: Re: OnPlayerCommand2
Post by: Kratos_ on Mar 06, 2015, 11:09 AM
If its neither working nor throwing any error on the console then try to locate whether there are more than one functions with the same ID . Its maybe possible that due to 2 callbacks , one is getting skipped by the server which will going to execute your desired result . Post the screenshot & explain that where have you put it .
Unless & until you do not explain your problem correctly , you will less likely to attract convincing responses from others . By explaining the problem , you are taking a step forward to help yourself as people will get your Intentions .
Title: Re: OnPlayerCommand2
Post by: Thijn on Mar 06, 2015, 06:46 PM
Did you actually added the command you wanted to onPlayerCommand2?
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 07, 2015, 04:12 AM
yeah thijn this is command

if ( cmd == "champ" )
{
     MessagePlayer( "Loser", player );
}
Title: Re: OnPlayerCommand2
Post by: EK.IceFlake on Mar 07, 2015, 04:25 AM
Press CTRL+F and search for function onPlayerCommand(. If more than one are found, remove the useless ones.
QuoteIf its neither working nor throwing any error on the console then try to locate whether there are more than one functions with the same ID . Its maybe possible that due to 2 callbacks , one is getting skipped by the server which will going to execute your desired result . Post the screenshot & explain that where have you put it .
Title: Re: OnPlayerCommand2
Post by: Thijn on Mar 07, 2015, 11:28 AM
Quote from: NE.CrystalBlue on Mar 07, 2015, 04:25 AMPress CTRL+F and search for function onPlayerCommand(. If more than one are found, remove the useless ones.
QuoteIf its neither working nor throwing any error on the console then try to lo


Quote from: NE.CrystalBlue on Mar 07, 2015, 04:25 AM
Quotecate whether there are more than one functions with the same ID . Its maybe possible that due to 2 callbacks , one is getting skipped by the server which will going to execute your desired result . Post the screenshot & explain that where have you put it .
Its not the onPlayerCommand, its onPlayerChat and onPlayerCommand2.



Did you actually try !champ?
Try adding a print with all the arguments to check if the onPlayerCommand2 actually gets called the way you think it does.
Title: Re: OnPlayerCommand2
Post by: PsyChO_KiLLeR on Mar 07, 2015, 12:26 PM
well work the error was on these lines

Message("[" + player.ID +"] "+ player.Name + ": " + text.tostring() + "\n");
    Message(cred+"" + player.Name + " : "+cwhite+""+ text.tostring());


when i remove them it work but thnx for help