SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/01/2019, 07:10 AM   #11
cessil
High-roller
 
cessil's Avatar
 
Join Date: Apr 2009
Posts: 1,346
Reputation: 296
Default Re: Get playerid from listitem.

Quote:
Originally Posted by ****** View Post
Replace “PVar” with “format”…
with format and pvar you still need to enter the thousands for it to start taking over 1ms
cessil is online now   Reply With Quote
Old 04/01/2019, 07:50 PM   #12
BlackBank
Gangsta
 
Join Date: Dec 2010
Location: The Netherlands
Posts: 522
Reputation: 437
Default Re: Get playerid from listitem.

Quote:
Originally Posted by cessil View Post
when you say PVars are slow you're talking tens of thousands of a millisecond like 0.00023 ms according to some speed tests, meaning you'd have to use over ten thousand in the one function to notice any slow down
Quote:
Originally Posted by cessil View Post
with format and pvar you still need to enter the thousands for it to start taking over 1ms
Well i did some benchmarking, and it takes like 1ms when you iterate over 900 items and with 10.000 it takes 5ms to run the code. Ofcourse almost nobody will reach more then 900 players and for a dialog list is it okay to use it this way yeah, but it still takes some time to run this, then what you did stated.

Also the code i use to benchmark it:
PHP Code:
    new tick GetTickCount();
    new 
string[20];
    for (new 
0!= 10000; ++i) {
        
format(stringsizeof(string), "stats_%d_player"i);
        
SetPVarInt(playeridstringi);
    }
    
printf("End: %dms", (GetTickCount() - tick)); 
BlackBank is offline   Reply With Quote
Old 04/01/2019, 10:54 PM   #13
CherryMond
Little Clucker
 
CherryMond's Avatar
 
Join Date: Feb 2018
Posts: 28
Reputation: 0
Default Re: Get playerid from listitem.

Thank you all for your interest in the thread. Is fine.
CherryMond is offline   Reply With Quote
Old 05/01/2019, 04:17 AM   #14
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,885
Reputation: 1337
Default Re: Get playerid from listitem.

https://forum.sa-mp.com/showthread.php?t=570904

Further to the point above, "SendClientMessage" uses "playerid" NOT "pid". "OnPlayerConnect" is called when the player connects, "Response" is called when the player clicks something on the dialog (which could be many hours later if they're AFK). Despite this fact, you can still use "playerid" (and any other variable from the enclosing function) inside "Response" thanks to a feature called "closures".

That eliminates the need for a two dimensional array.
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GivePlayerMoney(playerid, PlayerInfo[playerid][pNovac]); Problem Theepiccoder Scripting Help 6 03/07/2016 02:13 PM
[Ajuda] listitem Comanfis157 Português/Portuguese 0 12/04/2014 09:17 PM
double public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) TiXz0r Scripting Help 1 07/11/2013 08:12 PM
What's wrong with skins? GetPlayerSkin(playerid) & SetPlayerSkin(playerid, skin) McSquizzy Help Archive 7 16/04/2010 02:27 PM


All times are GMT. The time now is 05:50 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.