Get playerid from listitem.
#7

Quote:
Originally Posted by Kane_
View Post
If it's ever not conveniently formatted to use with sscanf, you could always do something like:

pawn Code:
new tmpstr[80];

format(tmpstr, sizeof(tmpstr), "PLIST_%i_USERID", countPlayers);
SetPVarInt(playerid, tmpstr, get_players_id);
That would be inside your iteration. How do you use it?

pawn Code:
new tmpstr[80], get_player_id;

format(tmpstr, sizeof(tmpstr), "PLIST_%i_USERID", listitem);
get_player_id = GetPVarInt(playerid, tmpstr);
Inside your OnDialogResponse. Delete it after.

We're using the listitem the player would be at in OnDialogResponse and setting their ID through the PVar.

listitems start at 0 and as does your countPlayers variable.

It's pretty simple and self explanatory but if you don't understand, let me know and I'll explain further.
Why using PVar for this? Because they are slow, and especially when you us them with the format function. You could just use an array and store the ID's of the players in it...

I should do it like this:
PHP Code:
// Somewhere above your script (global variable), not inside any functions:
new dialogPlayerStatsList[MAX_PLAYERS][MAX_PLAYERS];
// Inside your foreach loop where you generate the list of players:
foreach(Characteri){
    if(
PlayerInQueue[i] == true){
        
format(playerssizeof(players), "%s"GetPlayerName(i));
        
strcat(string"\n");
        
strcat(stringplayers);
        
        
dialogPlayerStatsList[playerid][countPlayers] = i;
        
countPlayers++;
    }
}
// OnDialogResponse:
if(dialogid == 34){
    if(
response){
        
// Selected playerid:
        
new selected_playerid dialogPlayerStatsList[playerid][listitem];
        
GivePlayerMoney(selected_playerid1337); // Give selected player from list money (example)
    
}

Reply


Messages In This Thread
Get playerid from listitem. - by CherryMond - 02.01.2019, 17:41
Re: Get playerid from listitem. - by NaS - 02.01.2019, 17:50
Re: Get playerid from listitem. - by CherryMond - 02.01.2019, 18:12
Re: Get playerid from listitem. - by RoboN1X - 03.01.2019, 03:34
Re: Get playerid from listitem. - by Kane - 03.01.2019, 08:40
Re: Get playerid from listitem. - by CherryMond - 03.01.2019, 20:27
Re: Get playerid from listitem. - by BlackBank - 03.01.2019, 22:33
Re: Get playerid from listitem. - by cessil - 03.01.2019, 23:04
Re: Get playerid from listitem. - by BlackBank - 03.01.2019, 23:11
Re: Get playerid from listitem. - by Y_Less - 04.01.2019, 00:16
Re: Get playerid from listitem. - by Threshold - 04.01.2019, 05:58
Re: Get playerid from listitem. - by cessil - 04.01.2019, 07:10
Re: Get playerid from listitem. - by Y_Less - 04.01.2019, 11:12
Re: Get playerid from listitem. - by BlackBank - 04.01.2019, 19:50
Re: Get playerid from listitem. - by CherryMond - 04.01.2019, 22:54
Re: Get playerid from listitem. - by Pottus - 05.01.2019, 04:17

Forum Jump:


Users browsing this thread: 1 Guest(s)