SA-MP Forums Archive
Problem with this - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with this (/showthread.php?tid=268777)



Problem with this - EdeniaGaming - 13.07.2011

Код:
new currank[64];
          		if(PlayerInfo[playerid][pDivision] == 1) { currank = "(NA)"; }
          		else if(PlayerInfo[playerid][pDivision] == 2) { currank = "(II)"; }
          		else if(PlayerInfo[playerid][pDivision] == 3) { currank = "(FTO)"; }
          		else if(PlayerInfo[playerid][pDivision] == 4) { currank = "(IA)"; }
          		else if(PlayerInfo[playerid][pDivision] == 5) { currank = "(SWAT)"; }
          		else { currank = "(NA)"; }
				if(PlayerInfo[playerid][pRank] == 10) { format(string, sizeof(string), "** Chief %s %d #%d: %s, over. **", str,currank,PlayerInfo[playerid][pBadgeNumber], result); }
Well this is a simple /radio command for cops etc anyway

Suppose to be

(IA) Because im set to Division 4
**Cheif John Miller (IA) #102 : test, over **

but its saying
**Cheif John Miller 60 #102 : test, over **

why is this ??


Re: Problem with this - Calgon - 13.07.2011

Because you incorrectly formatted the string. You set your 'currank' string to format as an integer (%d), which is incorrect. Strings are to be formatted using the '%s' placeholder. Replace your 'format' statement with this code:

pawn Код:
format(string, sizeof(string), "** Chief %s %s #%d: %s, over. **", str,currank,PlayerInfo[playerid][pBadgeNumber], result);



Re: Problem with this - sleepysnowflake - 13.07.2011

currank is a string not an integer. change #d to #s