Iffy characters - 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: Iffy characters (
/showthread.php?tid=417040)
Iffy characters -
DanLore - 19.02.2013
Hello...
Got an issue right now, can't seem to repair it and mind-boggled as to what would cause such an issue to occur.
pawn Код:
public updateExperienceCounter(playerid)
{
if(IsPlayerConnected(playerid))
{
if(playerData[playerid][playerLoggedIn])
{
new minusValue, finalXP[8];
minusValue = 8 - strlen(playerData[playerid][playerXP]); // 300 xp -> 3 length 8 - 3 = 5, need to add 5 zeros.
format(finalXP, sizeof(finalXP), "%i", playerData[playerid][playerXP]); // so... finalXP would be "300" for now.
while(minusValue > 0)
{
if(strlen(finalXP) <= 8)
{
strins(finalXP, "0", 0, sizeof(finalXP)); // add a 0 at the beginning of it...
minusValue--; // the minus value needs to be decreased so it doesnt keep adding 0s and continue the loop
new message[128];
format(message, sizeof(message), "{B7B7B7}[DEBUG] {FFFFFF}playerXP: %i || Current progress: %s", playerData[playerid][playerXP], finalXP);
SendClientMessage(playerid, COLOR_WHITE, message);
}
}
PlayerTextDrawSetString(playerid, playerExperience[playerid], finalXP);
}
}
}
If you can't tell, from this I'm adding 0s to the start of the players XP count, 350 -> 00000350, 3500 -> 00003500 etc.
However, in-game this is what I'm receiving.
Код:
[14:48:47] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 1150 || Current progress: 01150
[14:48:47] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 1150 || Current progress: 001150
[14:48:47] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 1150 || Current progress: 0001150
[14:48:47] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 1150 || Current progress: 00001150яx Њ¬ d
--
[14:48:51] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 350 || Current progress: 0350
[14:48:51] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 350 || Current progress: 00350
[14:48:51] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 350 || Current progress: 000350
[14:48:51] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 350 || Current progress: 0000350
[14:48:51] {B7B7B7}[DEBUG] {FFFFFF}playerXP: 350 || Current progress: 00000350яx Њ¬ d
So it works perfectly fine up until the final zero, any ideas why?
Re: Iffy characters -
SuperViper - 19.02.2013
Try increasing the size of the string to 9 or 10.
Re: Iffy characters -
DanLore - 19.02.2013
Problem sorted, for anyone else in a similar predicament... refer to this helpful post:
http://forum.sa-mp.com/showpost.php?...postcount=1936