SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 26/03/2010, 03:56 PM   #1
Torran
High-roller
 
Join Date: Jan 2010
Posts: 1,779
Reputation: 1
Default Pvars question?

What exactly are they
What do they do?
Torran is offline  
Old 26/03/2010, 04:06 PM   #2
Kyosaur
Gangsta
 
Kyosaur's Avatar
 
Join Date: Mar 2008
Location: USA - California
Posts: 973
Reputation: 349
Default Re: Pvars question?

They're pretty much just global variables that are declared by the sa-mp server, i guess you could say.

They seem useless for people who know their way around pawn. I personally wont be switching everything over to this new system, as i dont see a gain. The only thing that really appeals to me about them is that they can be accessed from other scripts (i normally use callremotefunction, this isnt a bad method, but it is slower. Its not noticeable unless you have your function call in a loop tho).
Kyosaur is offline  
Old 26/03/2010, 04:11 PM   #3
Kyosaur
Gangsta
 
Kyosaur's Avatar
 
Join Date: Mar 2008
Location: USA - California
Posts: 973
Reputation: 349
Default Re: Pvars question?

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Kyosaur!!
They're pretty much just global variables that are declared by the sa-mp server, i guess you could say.

They seem useless for people who know their way around pawn. I personally wont be switching everything over to this new system, as i dont see a gain. The only thing that really appeals to me about them is that they can be accessed from other scripts (i normally use callremotefunction, this isnt a bad method, but it is slower. Its not noticeable unless you have your function call in a loop tho).
It's a tiny bit slower. You will not notice any difference unless your loop is looping thousands. Regardless, this new system is definitely a gain and even prevents you from declaring the variable on your script. It also prevents you from using enums.
Enum variable:
PlayerInfo[playerid][pStats]
PVar:
GetPVarInt(playerid, "stats");
Simple as is.

I wouldnt say prevents, you can still use enums with the pvars (Dont really know why you would want to/need to tho...).


EDIT: I still dont see whats wrong with declaring MAX_PLAYER arrays, im fine losing 2kb of ram. The only thing im NOT content about is looping through them.


Can alter the a_samp include, or even do something like:

Code:
for(new a=0,b=GetMaxPlayers(); a<b; a++)
but still not very efficient for releases.
Kyosaur is offline  
Old 26/03/2010, 05:11 PM   #4
Kyosaur
Gangsta
 
Kyosaur's Avatar
 
Join Date: Mar 2008
Location: USA - California
Posts: 973
Reputation: 349
Default Re: Pvars question?

Quote:
Originally Posted by Seif_
I always do:
for(new playerid, m = GetMaxPlayers(); playerid < m; playerid++)
This is faster than doing:
for(new playerid; playerid < GetMaxPlayers(); playerid++)
because you find GetMaxPlayers value and use it in the whole loop instead of finding it in every loop.
I also redefined MAX_PLAYERS to my max players slot. I do think we need a SetVVar(Int/Float/String) as well for vehicles.
I REALLY agree with that lol. Maybe just a better variable system all together (instead of pvar,vvar,ovar ... just have a single system).


Hmmm subject got a little offtopic... sorry lol.
Kyosaur is offline  
Old 26/03/2010, 05:53 PM   #5
playbox12
High-roller
 
playbox12's Avatar
 
Join Date: Feb 2010
Location: Netherlands
Posts: 1,318
Reputation: 216
Default Re: Pvars question?

Quote:
Hmmm subject got a little offtopic... sorry lol.
Indeed, but he defintley has his anwser now!
playbox12 is offline  
 

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
Pvars Steven82 Help Archive 0 26/05/2010 08:52 PM
Looping Pvars Dark_Kostas Help Archive 4 06/04/2010 07:18 AM
PVars Question(s) XGh0stz Help Archive 0 02/04/2010 08:08 PM
Pvars... biltong Help Archive 8 26/03/2010 01:31 PM


All times are GMT. The time now is 12:55 AM.


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