[Beginner] [Help] /b Command -
Crayon - 06.10.2010
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!
Re: [Beginner] [Help] /b Command -
LarzI - 06.10.2010
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.
Re: [Beginner] [Help] /b Command -
Crayon - 06.10.2010
Thanks so much Larz.
Re: [Beginner] [Help] /b Command -
zack3021 - 07.10.2010
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.
Re: [Beginner] [Help] /b Command -
LarzI - 07.10.2010
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 ']'
Re: [Beginner] [Help] /b Command -
Crayon - 08.10.2010
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.
Re: [Beginner] [Help] /b Command -
TheHoodRat - 08.10.2010
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.
Re: [Beginner] [Help] /b Command -
Crayon - 08.10.2010
It's the one in the thread creator post, TheHoodRat. Thanks if you can help me. I'll edit the post and put <pawn>
Re: [Beginner] [Help] /b Command -
Crayon - 08.10.2010
I apologize for double posting, did anyone solve this? D:
Re: [Beginner] [Help] /b Command -
TheHoodRat - 08.10.2010
First show me another command because using the wrong line to define the /command can fuck up your server.