Need help with /help [message] command.
#1

Here is my code:

Код:
	if(strcmp(cmd, "/help", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
	    if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
		new string[250];
		format(string, sizeof(string), "[ ! ] %s[ID:%d] asks help:%s", name, playerid, strlen(tmp));
		SendClientMessageToAdmins(string);
		SendClientMessage(playerid, GREEN, "You Message Has Been Sent To Online Admins.");
	}
And my problem is, if i write /help this is just example

It will say to admins: [ ! ] Paul_Newton ask help: his

But if i write /help thisisjustexample

It will say to admins: [ ! ] Paul_Newton ask help: hisisjustexample
Reply
#2

i dont exactly get what the problam is
You type /Help thisisjustexample
And it comes up with [ ! ] Paul_Newton ask help: thisisjustexample
So what is the problem
Reply
#3

pawn Код:
if( strcmp( cmd, "/help", true ) == 0 )
{
    if( !strlen( cmdtext ) ) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[ 128 ]; // 128 is the max chat string!
    format( string, sizeof string, "[ ! ] %s[ID:%d] asks help:%s", name, playerid, cmdtext );
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "You Message Has Been Sent To Online Admins." );
}
Maaybe?
Reply
#4

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
if( strcmp( cmd, "/help", true ) == 0 )
{
    if( !strlen( cmdtext ) ) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[ 128 ]; // 128 is the max chat string!
    format( string, sizeof string, "[ ! ] %s[ID:%d] asks help:%s", name, playerid, cmdtext );
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "You Message Has Been Sent To Online Admins." );
}
Maaybe?

It works, exept when i write /help How to use car?

It says: [ ! ] Paul_Newton asks help: /help How to use car?

Can you make fix it?
Reply
#5

pawn Код:
if( strcmp( cmd, "/help", true ) == 0 )
{
    if( !strlen( cmdtext ) ) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[ 128 ]; // 128 is the max chat string!
    format( string, sizeof string, "[ ! ] %s[ID:%d] asks help:%s", name, playerid, cmdtext[4] );
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "You Message Has Been Sent To Online Admins." );
}
Reply
#6

Quote:
Originally Posted by wups
Посмотреть сообщение
pawn Код:
if( strcmp( cmd, "/help", true ) == 0 )
{
    if( !strlen( cmdtext ) ) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    new string[ 128 ]; // 128 is the max chat string!
    format( string, sizeof string, "[ ! ] %s[ID:%d] asks help:%s", name, playerid, cmdtext[4] );
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "You Message Has Been Sent To Online Admins." );
}
it's not still working perfectly, when i type /help How to use car?

it says: [ ! ]Paul_Newton asks help: pHow to use car?
Reply
#7

Ther ya go
pawn Код:
if( strcmp(cmd,"/help",true ) == 0)
{
if(!strlen(cmdtext)) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
new string[123];
format( string, sizeof string, "[!] %s[ID:%d] asks help: %s", name, playerid, cmdtext[5] ); //Use 5 becouse 4 doesn't get rid of the last letter of HELP witch is P thats why it comes up with p.....
SendClientMessageToAdmins(string);
SendClientMessage( playerid, GREEN, "You Message Has Been Sent To Online Admins." );
}
TELL ME IF IT WORKES
Reply
#8

Use ZCMD + SSCANF.

pawn Код:
CMD:help( playerid, params[ ] )
{
    new string[ 128 ];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    format(string, sizeof(string), "[!] %s[ID:%d] asks help: %s", name, playerid, params);
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "Your Message Has Been Sent To Online Admins." );
    return 1;
}
Reply
#9

Quote:
Originally Posted by Clive
Посмотреть сообщение
Use ZCMD + SSCANF.

pawn Код:
CMD:help( playerid, params[ ] )
{
    new string[ 128 ];
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    format(string, sizeof(string), "[!] %s[ID:%d] asks help: %s", name, playerid, params);
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "Your Message Has Been Sent To Online Admins." );
    return 1;
}
Why do you need to use sscanf on a string that doesn't need to be split? Just check its length, for example:

pawn Код:
CMD:help( playerid, params[ ] )
{
    new string[ 128 ];
    if(!strlen(params)) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    format(string, sizeof(string), "[!] %s[ID:%d] asks help: %s", name, playerid, params);
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "Your Message Has Been Sent To Online Admins." );
    return 1;
}
Reply
#10

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Why do you need to use sscanf on a string that doesn't need to be split? Just check its length, for example:

pawn Код:
CMD:help( playerid, params[ ] )
{
    new string[ 128 ];
    if(!strlen(params)) return SendClientMessage(playerid, ERROR, "Use: /help [MESSAGE]");
    format(string, sizeof(string), "[!] %s[ID:%d] asks help: %s", name, playerid, params);
    SendClientMessageToAdmins( string );
    SendClientMessage( playerid, GREEN, "Your Message Has Been Sent To Online Admins." );
    return 1;
}
Actually, with zcmd you have to use isnull() instead of strlen() to confirm the string size as strlen() doesn't count null-terminated strings, afaik.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)