SA-MP Forums Archive
string showing wrong value? - 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: string showing wrong value? (/showthread.php?tid=598799)



string showing wrong value? (solved) - Counterafk - 16.01.2016



As you can see on the image above it says "115" wins the round, which is a completely random value, trying to understand where I messed up. Here's the code.


(intendation is messed up ova here)
Код:
	new Player;
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	         if(roundKills[i] > roundKills[Player]) Player = i;
	    }
	}
	

	new pname[MAX_PLAYER_NAME];
	GetPlayerName(Player, pname, sizeof(pname));
	
	new string2[120];
	format(string2,sizeof(string2),"%d wins the round with %d kills.", pname, roundKills[Player]);
	SendClientMessageToAll(-1, string2);
Thank you for taking your time


Re: string showing wrong value? - radiobizza - 16.01.2016

%d - shows a number and %s a name. replace
PHP код:
format(string2,sizeof(string2),"%d wins the round with %d kills."pnameroundKills[Player]); 
with this:
PHP код:
format(string2,sizeof(string2),"%s wins the round with %d kills."pnameroundKills[Player]); 



Re: string showing wrong value? - Counterafk - 17.01.2016

Ah. Thanks!