Cant figure out how to format playerid and player name
#1

well after cracking my head to find a way to sort data, so i can enlist them, i can't figure out how the hell can i possibly send the names of the players properly. This is how the code is:

pawn Код:
stock toplist()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(ffaon == true && ffaopen == false && playingffa[i] == true && IsPlayerConnected(i))
    t_FeedInfo(i, GetPVarInt(i, "pPoints"));
    }
    new rank[3];
    new p3[MAX_PLAYER_NAME];
    new p2[MAX_PLAYER_NAME];
    new p1[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(rank[0], p1, sizeof(p1));
    GetPlayerName(rank[1], p2, sizeof(p2));
    GetPlayerName(rank[2], p3, sizeof(p3));
    for(new i=0; i<3; ++i)
    {
    rank[i] =  t_GetPlayer(i+1, 1);
    format(string, sizeof(string), "1st place - [%d]%s", rank[0]);
    format(string, sizeof(string), "2nd place - [%d]%s", rank[1]);
    format(string, sizeof(string), "3rd place - [%d]%s", rank[2]);
    SendClientMessageToAll(-1, string);
    }
    return 1;
}
What i want to do is where [%d] to display their id, and %s to show their name. But my brains just burned out after trying to understand the whole include concept, which i barely did, if still didn't. Plus, the whole gets repeated over and over again after the message is sent, whats wrong with my loop aswell?
Reply
#2

You messed up all the variable thing.

https://sampwiki.blast.hk/wiki/Scripting_Basics

Check this out
Reply
#3

Thats just not quite exactly what i need, lets put it like that. Its just unclear to me how to list it properly, because right now i can't read my own code itself, if you looked above, rather than just throwing the link around here.
Reply
#4

Quote:
Originally Posted by GwENiko
Посмотреть сообщение
i can't figure out how the hell can i possibly send the names of the players properly.

What i want to do is where [%d] to display their id, and %s to show their name.
So ask question better.

If you know how to deal with variables you will know how to fix this.
Reply
#5

pawn Код:
new rank[3]; //new means you've made a NEW empty variable, which the value is null
    new p3[MAX_PLAYER_NAME]; //^^
    new p2[MAX_PLAYER_NAME]; //^^
    new p1[MAX_PLAYER_NAME]; //^^
    new string[128]; //^^
pawn Код:
new variable = 3; //different than this, you've made a new variable with value 3
Learn how to scripting first.
Reply
#6

Quote:
Originally Posted by RenovanZ
Посмотреть сообщение
pawn Код:
new rank[3]; //new means you've made a NEW empty variable, which the value is null
    new p3[MAX_PLAYER_NAME]; //^^
    new p2[MAX_PLAYER_NAME]; //^^
    new p1[MAX_PLAYER_NAME]; //^^
    new string[128]; //^^
pawn Код:
new variable = 3; //different than this, you've made a new variable with value 3
Learn how to scripting first.
Please, dont be like that. Let me make this clear, see i understand exactly what i am doing as i wrote the code myself, but i am using an "include" from a tutorial to sort out this data. Furthermore, i am using arrays for a reason. But, due to me looping my code, i lost sight of what i was doing. What i am trying to say, i can't get the player name and format it, into the message, without causing the loop go over and over again, unstoppably, and please dont show me links to basic looping tutorials, the only problem is that i can't concentrate into the script, all i need is somebody else's eyes.
Reply
#7

Can I see your t_GetPlayer function ? And what it does ?
Reply
#8

Here: http://pastebin.com/yXdjFn88

PS: this is acclaimed to be [MM]RoXoR[FS]'s include.
Reply
#9

There, i got it working, ty.
Reply
#10

help me guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)