SA-MP Forums Archive
/do CMD [RP] - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /do CMD [RP] (/showthread.php?tid=267156)



/do CMD [RP] - 963852741 - 07.07.2011

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;
    } 



Re: /do CMD [RP] - Wesley221 - 07.07.2011

Well, a code should help. Post us your command


Re: /do CMD [RP] - 963852741 - 07.07.2011

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


Re: /do CMD [RP] - Harry_Sandhu - 07.07.2011

SORRY

OFFTOPIC: Where you live??


Re: /do CMD [RP] - 963852741 - 07.07.2011

why is that ?
i just want answer.


Re: /do CMD [RP] - HyperZ - 07.07.2011

I suggest you to use Zcmd and Sscanf2 .


Re: /do CMD [RP] - Wesley221 - 07.07.2011

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;
}



Re: /do CMD [RP] - Babul - 07.07.2011

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]


Re: /do CMD [RP] - Elorreli - 07.07.2011

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.


Re: /do CMD [RP] - Wesley221 - 07.07.2011

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.