CreateJob Help.. Scanff + ZCMD
#1

HI, I have been looking at multiple ways to do this but i cannot figure out why it will not work.

This is the code

Код:
CMD:createjob(playerid, params[])
	{
	    new jobname;
		new string[128];
  		if(isnull(params)) return SendClientMessage(playerid, COLOR_RED1, "ERROR: /createquest <jobname>");
		{
		    if (sscanf(params, "c", jobname))
			{
			    format(string, sizeof(string), "You named your job: %s", jobname);
			    SendClientMessage(playerid, COLOR_RED1, string);
 				return 1;
			}
   		}
   		return 1;
	}
In game it says "You named your job: " and it just stays blank. What am i doing wrong. I have searched and searched but cannot figure it out..

PS it compiles fine
Reply
#2

If you've sscanf2 try:

PHP код:
CMD:createjob(playeridparams[])
{
        new 
jobname;
        new 
string[128];
          if(
isnull(params)) return SendClientMessage(playeridCOLOR_RED1"ERROR: /createquest <jobname>");
        {
            if (
sscanf(params"sz"jobname))
            {
                
format(stringsizeof(string), "You named your job: %s"jobname);
                
SendClientMessage(playeridCOLOR_RED1string);
                 return 
1;
            }
           }
         return 
1;

Reply
#3

Thanks for your suggestion however it just comes up with "Unknown command" in game now
Reply
#4

Код:
CMD:createjob(playerid, params[])
{
	new jobname[35];
	new string[128];
  	if(sscanf(params, "s[35]", jobname)) return SendClientMessage(playerid, COLOR_RED1, "ERROR: /createquest <jobname>");
  	
	format(string, sizeof(string), "You named your job: %s", jobname);
  	SendClientMessage(playerid, COLOR_RED1, string);
 	return 1;
}
No need to use isnull if you are using sscanf. Here is the code^

Also s is appropriate for strings.

EDIT: missed the size!
Reply
#5

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Код:
CMD:createjob(playerid, params[])
{
	new jobname[35];
	new string[128];
  	if(sscanf(params, "s", jobname)) return SendClientMessage(playerid, COLOR_RED1, "ERROR: /createquest <jobname>");
  	
	format(string, sizeof(string), "You named your job: %s", jobname);
  	SendClientMessage(playerid, COLOR_RED1, string);
 	return 1;
}
No need to use isnull if you are using sscanf. Here is the code^

Also s is appropriate for strings.
Needs to be "s[35]" though.
Reply
#6

Don't even need sscanf. Your only parameter is a string. Simply use isnull to verify that it's not empty.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)