/me ,/do,/b commands
#1

Well, I've been looking over tutorials, Only seen those commands with ZCMD, I am not willing to use the zcmd since i think it's fucked up, but anyways I need some help making /me etc with the normal format commands, could someone help me with it?
Reply
#2

Wait, what? Zeex's Command processor is "fucked up" for you? Do you know what you're saying? There's actually no disadvantages, it's even easier to use than using STRCMP (string compare) to check command typed by player.

But if you really need these commands in strcmp then look in really old Godfather gamemode's or something, you'll find them there easly.
Reply
#3

To be honest, it's my opinion, I think STRCMP is easier for me than ZCMD
Reply
#4

Are you sure strcmp

pawn Код:
if(!strcmp(cmdtext, "/mycommand"))
     {
        SendClientMessage(playerid, 0xFFFFFFFF, "Hello Player!");
        return 1;
     }
is harder

pawn Код:
CMD:mycommand(playerid, params[])
{
 return 1;
}
then ZCMD? Let's also include here that ZCMD is faster than strcmp.
Reply
#5

What's /do & /b, I mean what you the use of them, Can you explain more?
Reply
#6

Whatever way you're doing (you should honestly use Zcmd or Ycmd maybe, for the record I have a bit hard time understanding ycmd so using zcmd for now :P ), here is basically what you do:

1. You want people to get a message when they do any of the commands that they need to put a value or in this case a string. This is done by using sscanf. I hope you're using it and I have no clue if it works with normal string compare or not but yeah whatever.
Код:
new yourString[100];
if(sscanf(params, "s[100]", yourString)) return SendClientMessage(playerid, color, "You have to use /cmd [message]");

//or

if(sscanf(params, "s[100]", yourString))
{
SendClientMessage(playerid, color, "You have to use /cmd [message]");
return 1;
}
What will this do? This will first go into the if-statement and check if the player has not put any message/string after they have done the command. If they have not done this, the send client message will appear.


2. You want whatever the player did after the /cmd to be stored in a variable which it already is in yourString, but you want to print this out with the player's name. This is done by a magical thing called format.
Код:
new fullString[128];

format(fullString, sizeof(fullString), "%s: %s", GetPlayerName(playerid), yourString);

//or

format(fullString, 128, "%s: %s", GetPlayerName(playerid), yourString);
Now that might look like magic and it is.
First parameter (parameter = the stuff inbetween comas (",") and inside brackets ( "()" )) will do is to put everything that is in the other parameters inside that STRING (has to be string!!!).

Second parameter is the size of the string.

Third parameter is what you will "quote". The first %s stands for a string which we put as the fourth parameter. The second %s means whatever is in the fifth parameter. If we had put a integer (%i) inbetween the two %s's, the second %s would have been the sixth parameter and the interger %i would have been a number in the fifth parameter.

Fourth parameter will give the name.

Fifth parameter will set whatever the user wrote after "/cmd [here]".


3. You print it out, whether using:
- SendClientMessageToAll
- Any kind of proxDetector, dividing the units between players and stuff
- IsPlayerInRangeOfPoint version of proxdetector


This basically is the secret behind any normal roleplay command. They just change the format (third parameter) to look different. An /b command's format would maybe look something like this:
Код:
format(string, sizeof(string), "((Local OOC)) %s says: %s", GetPlayerName(playerid), yourFirstString);
While a /me or a /do would have it looking something like this:
Код:
format(string, sizeof(string), "** %s %s **", GetPlayerName(playerid), yourFirstString);

Example printed in the game like: "** Antonio Lombardi quickly forms his right palm into a fist and extends it forwards - punching player X in the face. **"
Код:
format(string, sizeof(string), "** %s ((%s))", yourFirstString, GetPlayerName(playerid));

Example printed in the game like: "** The table is broken. ((Antonio Lombardi))"
Reply
#7

Haha sorry double-post, accidently pressed quote instead of edit. Delete this haha. :P
Reply
#8

He might not use sscanf for it. Who knows how low-level his gamemode is. By the way, it's y_commands not y_cmd, and yeah, this include is awesome, way better than zcmd in my opinion and I am using y_commands now only.

Also I love the /help parameter, I don't have to create list of commands with their description

Anyway, just take these commands from old gamemode as I said.
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)