SA-MP Forums Archive
Need help with /help [message] command. - 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: Need help with /help [message] command. (/showthread.php?tid=226717)



Need help with /help [message] command. - Randomai - 16.02.2011

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


Re: Need help with /help [message] command. - park4bmx - 16.02.2011

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


Re: Need help with /help [message] command. - Mean - 16.02.2011

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?


Re: Need help with /help [message] command. - Randomai - 16.02.2011

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?


Re: Need help with /help [message] command. - wups - 16.02.2011

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." );
}



Re: Need help with /help [message] command. - Randomai - 16.02.2011

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?


Re: Need help with /help [message] command. - park4bmx - 16.02.2011

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


Re: Need help with /help [message] command. - HyperZ - 16.02.2011

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



Re: Need help with /help [message] command. - JaTochNietDan - 16.02.2011

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



Re: Need help with /help [message] command. - Calgon - 16.02.2011

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.