SA-MP Forums Archive
code to get player position. - 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: code to get player position. (/showthread.php?tid=283025)



code to get player position. - budelis - 13.09.2011

Hi all.Now i very need help to do one thing,it player position of score.I Don't know how to do this code,i try to do that format:

pawn Код:
mysql_query( "SELECT Exp FROM playerdata ORDER BY Exp" );
mysql_store_result();
But what to do next i don't know...


Re: code to get player position. - Kingunit - 13.09.2011

Click here!


Re: code to get player position. - budelis - 13.09.2011

OMG,i don't have me POS...It's like what is your position in the top like that:

pawn Код:
Your position is %d of %d with %d score.



Re: code to get player position. - Zonoya - 13.09.2011

Код:
 

// Command to get the position / Score
new Float:X, Float:Y, Float:Z
GetPlayerPos(playerid,Z,Y,Z);

new string[128];
format(string, sizeof(string), "Score: %i Position %f, %f, %f")",GetPlayerScore(playerid), X, Y, Z);
SendClientMessage(playerid, 0xFFFFFFAA, string);
UNTESTED


Re: code to get player position. - budelis - 13.09.2011

No no no.How to explane for you...ok i give examples:

pawn Код:
1.Player 5000XP
2.Player 4000XP
3.Player 2000XP
4.Player 500XP(It's me)
5.Player 250XP

Your position is 4 with 500 XP.
I think now you understand what i want to do.I want with mysql get my place by score like that table who i show.But this 1.Player 555XP i have do this,but how i say i don't know you do this?

pawn Код:
Your position is 4 with 500 XP.



Re: code to get player position. - Berky - 13.09.2011

Код:
new rank[MAX_PLAYERS];
for(new i = 0; i < MAX_PLAYERS; i++)
{
	for(new h = 0; h < 1000; h++) // 1000 = Max Score someone could get to be the #1 on the list.
	{
	    if(GetPlayerScore(i) >= 100) rank[i] = 10;
	    if(GetPlayerScore(i) >= 200) rank[i] = 9;
	    if(GetPlayerScore(i) >= 300) rank[i] = 8;
	    if(GetPlayerScore(i) >= 400) rank[i] = 7;
	    if(GetPlayerScore(i) >= 500) rank[i] = 6;
    }
}
Something like this perhaps?


Re: code to get player position. - budelis - 14.09.2011

no no....Why you all don't understand?first of all i need to do that wil mysql!!!second how much time I say,i want to get player place of all players by score of registered peoples.It's like "Player top".For example register 5 peoples,first player have 5000XP,second player have 4000XP,third player have 2000XP,fourth 1000XP,fiveth 500XP,then first people of this all peoples by score have place "1".Now i think you understand....


Re: code to get player position. - Universal - 14.09.2011

Quote:
Originally Posted by budelis
Посмотреть сообщение
no no....Why you all don't understand?first of all i need to do that wil mysql!!!second how much time I say,i want to get player place of all players by score of registered peoples.It's like "Player top".For example register 5 peoples,first player have 5000XP,second player have 4000XP,third player have 2000XP,fourth 1000XP,fiveth 500XP,then first people of this all peoples by score have place "1".Now i think you understand....
Relax. Lietuviskai supranti?


Re: code to get player position. - budelis - 15.09.2011

Look at this code:

pawn Код:
COMMAND:myplace(playerid,params[])
{
mysql_query( "SELECT * FROM `playerdata` ORDER BY `Exp`" );
mysql_store_result();
new MyPlace = mysql_fetch_int();
printf("Your Place %d: Score: %d", MyPlace, GetPlayerScore(playerid));
mysql_free_result();
return 1;
}
What here is wrong?


Re: code to get player position. - budelis - 16.09.2011

I'am very sorry for double posts,but i very need do this.