[Beginner] [Help] /b Command
#1

Hi guys I'm trying to create a RP script without editing another script, just creating one from scratch. A lot of work but for a beginner scripter I think it's the best way to get the basics down and become advanced.


I'm able to create a /b function shown below of my code:

pawn Код:
if(!strcmp(cmdtext, "/b", true, 2))
    {
        if(!cmdtext[2])return SendClientMessage(playerid, COLOR_GREY, "USAGE: /b [OOC CHAT]");
        new str[128];
        GetPlayerName(playerid,str, sizeof(str));
        format(str, sizeof(str), "%s ((%s))", str, cmdtext[2]);
        SendClientMessageToAll (COLOR_WHITE, str);
        return 1;
    }
Problem:

If you type something such as "/b hello" It'll appear in the chat box " ((Hello)) " obviously.

Though if you type something such as

"/boobies" ----> /boobies is NOT a registered command

It'll turn up in chat as "oobies", thinking that /b was the OOC function, and type "oobies"

How can I fix this?

Thank you!
Reply
#2

pawn Код:
if(!strcmp(cmdtext, "/b", true)) //Lenght is optional, so I'd rather not use it
{
    if(!cmdtext[2] || (cmdtext[2] == '\1' && !cmdtext[3])
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /b [OOC CHAT]");
    if(cmdtext[2] != '\1')
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /b [OOC CHAT] (don't forget to put a space between /b and your message)");
    new str[128];
    GetPlayerName(playerid,str, sizeof(str));
    format(str, sizeof(str), "%s ((%s))", str, cmdtext[3]);
    SendClientMessageToAll (COLOR_WHITE, str);
    return 1;
}
Problem solved

\1 = space ' '

pawn Код:
if(!cmdtext[2] || (cmdtext[2] == '\1' && !cmdtext[3])
Is doing the same as isnull does, aka recommended to use.
Reply
#3

Thanks so much Larz.
Reply
#4

And put your code between [pawn] [pawn] and add a "/" before the "p" in the last "[pawn]" Thats the best i can explain, hope it helped.
Reply
#5

Quote:
Originally Posted by Crayon
Посмотреть сообщение
Thanks so much Larz.
No problem.

Quote:
Originally Posted by zack3021
Посмотреть сообщение
And put your code between [pawn] [pawn] and add a "/" before the "p" in the last "[pawn]" Thats the best i can explain, hope it helped.
True.
It's much easier to read code inside PAWN or code boxes (pawn preferred when it's pawn code)

<pawn> </pawn>

Switch '<' and '>' with '[' and ']'
Reply
#6

Sorry I just tested the new script and it still doesn't work correctly. Now it does something wrong with my /do function and still has the same problem as before.
Reply
#7

Quote:
Originally Posted by Crayon
Посмотреть сообщение
Sorry I just tested the new script and it still doesn't work correctly. Now it does something wrong with my /do function and still has the same problem as before.
Post your script and maybe I can help you.
Reply
#8

It's the one in the thread creator post, TheHoodRat. Thanks if you can help me. I'll edit the post and put <pawn>
Reply
#9

I apologize for double posting, did anyone solve this? D:
Reply
#10

First show me another command because using the wrong line to define the /command can fuck up your server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)