/do CMD [RP]
#1

hi,
i have a problem.
i created the command /do, and when i am doing it, it says "Unknown Command", but above it, it looks: /do [action]
I will give you a picture:

When I am writing the action, it does doing it, but it is very limited.
EDIT:
PHP код:
    if(strcmpcmd"/me"true ) == )
    {
    if(
IsPlayerConnected(playerid))
    {
    new 
tmp[128];
    
tmp strtok(cmdtext,idx);
    if(!
strlen(tmp))
    {
    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /me [action]");
    return 
0;
    }
    new 
sendername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    new 
str[128];
    
format(str,sizeof(str),"*%s %s",sendernametmp);
    
ProxDetector(10.0playeridstrCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
    }
     return 
1;
    } 
Reply
#2

Well, a code should help. Post us your command
Reply
#3

sorry for the double, but it actually /me command also
Reply
#4

SORRY

OFFTOPIC: Where you live??
Reply
#5

why is that ?
i just want answer.
Reply
#6

I suggest you to use Zcmd and Sscanf2 .
Reply
#7

You should start using ZCMD & Sscanf.
https://sampforum.blast.hk/showthread.php?tid=120356
https://sampforum.blast.hk/showthread.php?tid=91354
pawn Код:
COMMAND:me(playerid, cmdtext[])
{
    new Message, name[24], string[128];
    GetPlayerName(playerid, name, sizeof name);
    if(!sscanf(cmdtext, "s", Message))
    {
        format(string, sizeof string, " * %s said %s ", name, Message);
        // Prox thingy here
    } else return SendClientMessage(playerid, -1, "Usage: /me [text]");
    return 1;
}
Reply
#8

the reason for the double chat spamis the return 0;
Код:
if(strcmp( cmd, "/me", true ) == 0 )
{
	if(IsPlayerConnected(playerid))
	{
		new tmp[128];
		tmp = strtok(cmdtext,idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
			return 1;// here it was 0; returning a false (0) will result in "unknown command", return true (1) stops the spam
		}
		new sendername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, sendername, sizeof(sendername));
		new str[128];
		format(str,sizeof(str),"*%s %s",sendername, tmp);
		ProxDetector(10.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	}
	return 1;
}
edit: Wesley221's solution +1 btw
Код:
COMMAND:me(playerid, cmdtext[])
{
    new Message[128], name[24], string[128];
    GetPlayerName(playerid, name, sizeof name);
    if(!sscanf(cmdtext, "s[128]", Message))
    {
        format(string, sizeof string, " * %s said %s ", name, Message);
        // Prox thingy here
    } else return SendClientMessage(playerid, -1, "Usage: /me [text]");
    return 1;
}
fixed the string size... [128]
Reply
#9

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
You should start using ZCMD & Sscanf.
https://sampforum.blast.hk/showthread.php?tid=120356
https://sampforum.blast.hk/showthread.php?tid=91354
pawn Код:
COMMAND:me(playerid, cmdtext[])
{
    new Message, name[24], string[128];
    GetPlayerName(playerid, name, sizeof name);
    if(!sscanf(cmdtext, "s", Message))
    {
        format(string, sizeof string, " * %s said %s ", name, Message);
        // Prox thingy here
    } else return SendClientMessage(playerid, -1, "Usage: /me [text]");
    return 1;
}
Answer the question instead of suggesting this, I'm sick of people constantly suggesting zcmd In every single topic they see.
Reply
#10

Quote:
Originally Posted by Elorreli
Посмотреть сообщение
Answer the question instead of suggesting this, I'm sick of people constantly suggesting zcmd In every single topic they see.
Stop posting useless things, I'm sick of people constantly doing this in every single topic i see.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)