OnPlayerCommand2

Started by PsyChO_KiLLeR, Mar 06, 2015, 08:21 AM

Previous topic - Next topic

PsyChO_KiLLeR

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?
.

PsyChO_KiLLeR

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.
.

jayant

Do that magic on that special event !! On that special event you have to assign your prefix "!" or it can b "a" etc.

PsyChO_KiLLeR

its not adding in onplayercommand it give error of expression expected

PsyChO_KiLLeR

i also add it in playerchat it say cmd does not exist

MacTavish

Paste this in your cmds.nutonPlayerCommand2(player, cmd, text)
{
//just put your commands here
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

PsyChO_KiLLeR

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

jayant

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.

PsyChO_KiLLeR

nothing happen again no error on console

.

#11
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
.

PsyChO_KiLLeR


jayant

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. :)

PsyChO_KiLLeR