Well i have question can we use onplayercommand2 of ! because i see it in little whitey server 0.4
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?
where i add this? onPlayerCommand2(player, cmd, args);
in playercommand?
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.
Do that magic on that special event !! On that special event you have to assign your prefix "!" or it can b "a" etc.
its not adding in onplayercommand it give error of expression expected
i also add it in playerchat it say cmd does not exist
Paste this in your cmds.nutonPlayerCommand2(player, cmd, text)
{
//just put your commands here
}
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
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.
nothing happen again no error on console
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
what it is?
Quote from: S.L.C on Mar 06, 2015, 08:52 AMQuote 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. :)
can anyone help?
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 ^
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.
nothing happen again no error nothing
Post your onPlayerChat function here
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());
}
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());
}
not working no error
If there's no error then it means it's working. Except you don't see it ;)
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)
:-\ :-[
i always type !lol
its not working
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)
:-\ :-[
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 .
Did you actually added the command you wanted to onPlayerCommand2?
yeah thijn this is command
if ( cmd == "champ" )
{
MessagePlayer( "Loser", player );
}
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 .
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 AMQuotecate 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.
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