Format Problem - 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)
+--- Thread: Format Problem (
/showthread.php?tid=282062)
Format Problem -
Grant Johnston - 09.09.2011
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
Re: Format Problem -
Bumbis - 09.09.2011
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;
}
Re: Format Problem -
JaTochNietDan - 09.09.2011
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
Re: Format Problem -
iJumbo - 09.09.2011
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
Re: Format Problem -
Grant Johnston - 09.09.2011
Thanks Guys. That Helped me a Fair bit. :P