Format Problem
#1

Hi there, Just having a problem with Format. Im not very good at it as All the Examples and small chunks of Tutorial has been hard for me to understand.

Could you please arrange this properly?"
Код:
	iff(strcmp(cmd, "/mats", true) == 0)
 	{
	new mats = PlayerInfo[playerid][pMats];
	SendClientMessage(playerid, COLOR_WHITE, "Amount of Materials....");
        format(string,sizeof(mats),"%s");
        SendClientMessage(playerid, COLOR_WHITE, string);
		return 1;
	}
Errors:
Код:
There isn't a Compiling error.
Its Just that when Im ingame my Materials is Actually like 20 But when string is being sent its just blank.
:(
Apart from helping my script, It would help me further Understand Format.

Thanks a bunch
Reply
#2

pawn Код:
if(strcmp(cmd, "/mats", true) == 0)
    {
    new mats = PlayerInfo[playerid][pMats];
    SendClientMessage(playerid, COLOR_WHITE, "Amount of Materials....");
        format(string,sizeof(string),"%s",mats);
        SendClientMessage(playerid, COLOR_WHITE, string);
        return 1;
    }
Reply
#3

Okay since the above poster didn't explain the problem...(and didn't fix the other problems)

The problem is that you're trying to use an array in format called "string", but that array does not exist, so you need to make one. There's also no need to create another variable just to get a value from another variable, additionally you're using %s for strings and I assume this is an integer so you need to use %i.

Here's an example:

pawn Код:
if(strcmp(cmd, "/mats", true) == 0)
{
    new string[8];
    SendClientMessage(playerid, COLOR_WHITE, "Amount of Materials....");
    format(string,sizeof(string),"%d", PlayerInfo[playerid][pMats]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
}
That's all you need, although why not juse have the "Amount of Materials: %d" in the format, instead of having them as separate messages on separate lines
Reply
#4

pawn Код:
if(strcmp(cmd, "/mats", true) == 0)
{
        new string[27];
    format(string,sizeof(string),"Amount of Materials : %d",PlayerInfo[playerid][pMats]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
}

send same time of JaTochNietDan xDD
Reply
#5

Thanks Guys. That Helped me a Fair bit. :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)