DCMD String Help me.
#1

[color=brown]Hello. I have a new error, this time I cannot figure out what to do for my function, to give out the Value inside of the String.

Example:
Quote:

Hello, my name is bob. I am [Function Value Here] Years old.

The text of the string comes up, just not the %s part.

Here's my code, help me to get it like Above ^

Код:
public OnPlayerCommandText(playerid, cmdtext[]) {
	dcmd(checksober, 10, cmdtext);
	return 0;
}
 
dcmd_checksober(playerid, params[])
{
	new
		id,
		abc[64];
	if (strlen(params))
	{
		id = strval(params);
		if (IsPlayerConnected(id))
		{
			GetPlayerDrunkTime(id);
			format(abc, sizeof (abc), "The Player's Drunk Level is %s.");
			SendClientMessage(id, 0x00FF00AA, "You have been tested for your Soberness");
			SendClientMessage(playerid, 0x00FF00AA, abc);
		}
		else
		{
			SendClientMessage(playerid, 0xFF0000AA, "Player not found");
		}
	}
	else
	{
		SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/checksober <playerid>\"");
	}
	return 1;
}
Reply
#2

Do you have this filterscript in the filterscripts folder?

Show your 'filterscripts' line from server.cfg.
Reply
#3

I have looked up and down the Wiki, and just cannot find what I need.
Reply
#4

* New Error, didn't want to make new topic..bumping, I need this solved quickly. *
Reply
#5

uh.. if it's strval, the nwhy use %s? if it's a value (decimal/integer) use %d or %i...
Reply
#6

Quote:
Originally Posted by Ignas1337
uh.. if it's strval, the nwhy use %s? if it's a value (decimal/integer) use %d or %i...
Thanks for the Help,

Now I get this:

Quote:

Player's Drunk Level is 0.

Even though it isn't zero.
Reply
#7

Because you never assign %d to something so it's 0..


Change this
pawn Код:
GetPlayerDrunkTime(id);
format(abc, sizeof (abc), "The Player's Drunk Level is %s.");
to
pawn Код:
format(abc, sizeof (abc), "The Player's Drunk Level is %d.", GetPlayerDrunkTime(id));
Reply
#8

Quote:
Originally Posted by 0rb
Because you never assign %d to something so it's 0..


Change this
pawn Код:
GetPlayerDrunkTime(id);
format(abc, sizeof (abc), "The Player's Drunk Level is %s.");
to
pawn Код:
format(abc, sizeof (abc), "The Player's Drunk Level is %d.", GetPlayerDrunkTime(id));
Hmm, I did this. But still doesn't seem to work

Just gives the 0, each time.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)