SA-MP Forums Archive
Onplayercommandtext - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Onplayercommandtext (/showthread.php?tid=244543)



Onplayercommandtext - Bam23 - 27.03.2011

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/secret", cmdtext, true, 10) == 0)
    {
    OnPlayerCommandText(playerid,"secret");
    OnPlayerCommandText(playerid,"secret");
        return 1;
    }
    return 0;
}
Ok im making a filter script..
I have this just like this..
No errors..
Untill i want to make another command like /secret.
I use secret due to people stealing ideas..

Please someone tell me how to add another command under this or like this without getting this
Error:
pawn Код:
C:\Users\Darian.Jennifer-PC\Desktop\pawno\xx\new.pwn(95) : warning 217: loose indentation
C:\Users\Darian.Jennifer-PC\Desktop\pawno\xx\new.pwn(101) : error 021: symbol already defined: "OnPlayerCommandText"
C:\Users\Darian.Jennifer-PC\Desktop\pawno\xx\new.pwn(106) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Then it said Unable to compile ****** - Name


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/pg", cmdtext, true, 10) == 0)
    {
    OnPlayerCommandText(playerid,"/me Unzips dufflebag. Takes a weapon out of his dufflebag and Flicks Safety OFF");
    OnPlayerCommandText(playerid,"/do **ZIPS**");
        return 1;
    }

    return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/pg", cmdtext, true, 10) == 0)
    {
    OnPlayerCommandText(playerid,"/me Unzips dufflebag. Takes a weapon out of his dufflebag and Flicks Safety OFF");
    OnPlayerCommandText(playerid,"/do **ZIPS**");
        return 1;
    }

    return 0;
}

Someone tell me how to do this?


Re: Onplayercommandtext - Stigg - 27.03.2011

You can only have one:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
In your script.

Read this:
https://sampwiki.blast.hk/wiki/OnPlayerCommandText


Re: Onplayercommandtext - Bam23 - 27.03.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
You can only have one:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
In your script.

Read this:
https://sampwiki.blast.hk/wiki/OnPlayerCommandText
Im still confused how do i make more commands then?? Like how do i add more the link is confusing too. Sorry. I might be a pain in the ass...

Like can i have an example on how to repeat this for more commands?


Re: Onplayercommandtext - Stigg - 27.03.2011

Quote:
Originally Posted by Bam23
Посмотреть сообщение
Im still confused how do i make more commands then?? Like how do i add more the link is confusing too. Sorry. I might be a pain in the ass...

Like can i have an example on how to repeat this for more commands?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cmd1", cmdtext, true, 10) == 0)
    {
        //DO YOUR THING
        return 1;
    }
    if (strcmp("/cmd2", cmdtext, true, 10) == 0)
    {
        //DO YOUR THING
        return 1;
    }
    //ECT....
    return 0;
}



Re: Onplayercommandtext - mikeeee - 01.12.2011

Yo bro when you make a new line make it like this

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cmd1", cmdtext, true, 10) == 0)
    {
        //DO YOUR THING
        return 1;
    }
    else if (strcmp("/cmd2", cmdtext, true, 10) == 0)
    {
        //DO YOUR THING
        return 1;
    }
    //ECT....
    return 0;
}



Re: Onplayercommandtext - Rob_Maate - 01.12.2011

Lmao did you just copy that?


Re: Onplayercommandtext - Thresholdold - 01.12.2011

xD Yup...


Re: Onplayercommandtext - grand.Theft.Otto - 02.12.2011

Quote:
Originally Posted by Rob_Maate
Посмотреть сообщение
Lmao did you just copy that?
Quote:
Originally Posted by Threshold
Посмотреть сообщение
xD Yup...
He didn't " Copy " it.

All he did was add " else " to the second " if " statement.


Re: Onplayercommandtext - ProdrifterX - 02.12.2011

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/pg", cmdtext, true, 10) == 0)
{
OnPlayerCommandText(playerid,"/me Unzips dufflebag. Takes a weapon out of his dufflebag and Flicks Safety OFF");
OnPlayerCommandText(playerid,"/do **ZIPS**");
return 1;
}

return 0;
}
{
else if (strcmp("/cmd2", cmdtext, true, 10) == 0)
{
OnPlayerCommandText(playerid,"/me Unzips dufflebag. Takes a weapon out of his dufflebag and Flicks Safety OFF");
OnPlayerCommandText(playerid,"/do **ZIPS**");
return 1;
}

return 0;
}

if have little error fix it.or tell me


Re: Onplayercommandtext - Rudy_ - 02.12.2011

Edit: i mean like this
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
            SendClientMessage(playerid,COLOR_WHITE, "your Message"); // define the color
        return 1;
    }
    return 0;
}