Command Problem
#1

Hello, i need help about my commands.
So, the first command is just "/" this.
It should say "USAGE: /say (message) - Enter Your Message"
And the second command is "/say"

So, this is my script about this / command

Код:
if (strcmp("/", cmdtext, true, 10) == 0)
{
	SendClientMessage(playerid, COLOR_RED, "USAGE /say (message) - Enter A Message");
 	return 1;
}


But it says:



And the script for the second command:

Код:
CMD:say(playerid, params[])
{
	new text[128], string[148];
	if(sscanf(params, "s", text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /say (message) - Enter A Message");
	format(string, sizeof(string), "%s: {FFFFFF}%s", PlayerName(playerid), text);
	SendClientMessageToAll(GetPlayerColor(playerid), text);
	return 1;
}


But it says:

Reply
#2

I don't know if you can use / as a command. As for the second problem replace text with string in SendClientMessageToAll
Reply
#3

Oh, i forgot it thanks but the second command was working fine.
Reply
#4

Quote:
Originally Posted by Unstoppable
Посмотреть сообщение
Oh, i forgot it thanks but the second command was working fine.
If you want "/" to say "use /say" so you can do the following:-

pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success ) // this was added in ZCMD afaik
{
   if( !success ) return SendClientMessage( playerid, -1, "USAGE /say (message) - Enter A Message" ); // this will work when you have typed any command which does not exist and even if you type a trailing slash.
    return 1;
}
and if you have some problem in the second command which is /say I've re-written it:-

pawn Код:
CMD:say( playerid, params[ ] )
{
    if( isnull( params ) ) return SendClientMessage( playerid, COLOR_RED, "USAGE: /say (message) - Enter A Message" ); // we will be using params [parameters] as our TEXT which will be written after "/say "
   
    new szStr[ 128 ];
   
    format( szStr, sizeof( szStr ), "%s: {FFFFFF}%s", PlayerName( playerid ), params );
    SendClientMessageToAll( GetPlayerColor( playerid ), szStr );
   
    return 1;
}

stock PlayerName( playerid ) // if you don't have this stock you can use this
{
    new szPlayerName[ MAX_PLAYER_NAME ]; // declaring a local var
    GetPlayerName( playerid, szPlayerName, sizeof( szPlayerName ) ); // saving the player's name in the var
    return szPlayerName; // returning the string of the name
}
I guess this will help you

Regards,
FalconX
Reply
#5

FalconX i just changed the command system to ocmd because i want use OnPlayerCommandText too.

Problem solved you can ~close this.
Reply
#6

Quote:
Originally Posted by Unstoppable
Посмотреть сообщение
FalconX i just changed the command system to ocmd because i want use OnPlayerCommandText too.

Problem solved you can ~close this.
Alright, I always recommend people to use ZCMD or YCMD.

Good luck!

Regards,
FalconX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)